From e4b48d27120349b836ec028ce384d52a8c91b897 Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Thu, 25 Feb 2010 14:55:42 +0000 Subject: [PATCH] *Another fix for ntfs write --- HBC/META.XML | 4 ++-- source/libntfs/gekko_io.c | 20 +++++--------------- source/usbloader/usbstorage2.c | 4 ++++ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/HBC/META.XML b/HBC/META.XML index 63d174e8..fac5cf7b 100644 --- a/HBC/META.XML +++ b/HBC/META.XML @@ -2,8 +2,8 @@ USB Loader GX USB Loader GX Team - 1.0 r915 - 201002222143 + 1.0 r916 + 201002251225 Loads games from USB-devices USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times. The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller. diff --git a/source/libntfs/gekko_io.c b/source/libntfs/gekko_io.c index c03dec93..708f5067 100644 --- a/source/libntfs/gekko_io.c +++ b/source/libntfs/gekko_io.c @@ -421,21 +421,11 @@ static s64 ntfs_device_gekko_io_writebytes(struct ntfs_device *dev, s64 offset, // Read the first and last sectors of the buffer from disc (if required) // NOTE: This is done because the data does not line up with the sector boundaries, // we just read in the buffer edges where the data overlaps with the rest of the disc - if(offset % fd->sectorSize != 0) { - if (!ntfs_device_gekko_io_readsectors(dev, sec_start, 1, buffer)) { - ntfs_log_perror("read failure @ sector %d\n", sec_start); - ntfs_free(buffer); - errno = EIO; - return -1; - } - } - if((count % fd->sectorSize != 0) || buffer_offset > 0) { - if (!ntfs_device_gekko_io_readsectors(dev, sec_start + sec_count-1, 1, buffer + ((sec_count - 1) * fd->sectorSize))) { - ntfs_log_perror("read failure @ sector %d\n", sec_start + sec_count); - ntfs_free(buffer); - errno = EIO; - return -1; - } + if (!ntfs_device_gekko_io_readsectors(dev, sec_start, sec_count, buffer)) { + ntfs_log_perror("read failure @ sector %d\n", sec_start); + ntfs_free(buffer); + errno = EIO; + return -1; } // Copy the data into the write buffer diff --git a/source/usbloader/usbstorage2.c b/source/usbloader/usbstorage2.c index be167bb7..488a87e9 100644 --- a/source/usbloader/usbstorage2.c +++ b/source/usbloader/usbstorage2.c @@ -273,6 +273,10 @@ s32 USBStorage2_WriteSectors(u32 sector, u32 numSectors, const void *buffer) /* Write data */ ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_WRITE_SECTORS, "ii:d", sector, numSectors, buf, len); + /* Free memory */ + if (buf != buffer) + iosFree(hid, buf); + return ret; }