mirror of
https://github.com/Maschell/libntfs-wiiu.git
synced 2024-12-17 23:51:50 +01:00
*Allow sector sizes other than 512 bytes per sector
*Use internal NTFS-3G device sync function to sync the device
This commit is contained in:
parent
520fc5f305
commit
86f2292aae
@ -112,25 +112,35 @@ static int ntfs_device_gekko_io_open(struct ntfs_device *dev, int flags)
|
||||
}
|
||||
|
||||
// Check that there is a valid NTFS boot sector at the start of the device
|
||||
NTFS_BOOT_SECTOR boot;
|
||||
if (interface->readSectors(fd->startSector, 1, &boot)) {
|
||||
if (!ntfs_boot_sector_is_ntfs(&boot)) {
|
||||
errno = EINVALPART;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
NTFS_BOOT_SECTOR *boot = (NTFS_BOOT_SECTOR *) ntfs_malloc(MAX_SECTOR_SIZE);
|
||||
if(boot == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!interface->readSectors(fd->startSector, 1, boot)) {
|
||||
ntfs_log_perror("read failure @ sector %d\n", fd->startSector);
|
||||
errno = EIO;
|
||||
ntfs_free(boot);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ntfs_boot_sector_is_ntfs(boot)) {
|
||||
errno = EINVALPART;
|
||||
ntfs_free(boot);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Parse the boot sector
|
||||
fd->hiddenSectors = le32_to_cpu(boot.bpb.hidden_sectors);
|
||||
fd->sectorSize = le16_to_cpu(boot.bpb.bytes_per_sector);
|
||||
fd->sectorCount = sle64_to_cpu(boot.number_of_sectors);
|
||||
fd->hiddenSectors = le32_to_cpu(boot->bpb.hidden_sectors);
|
||||
fd->sectorSize = le16_to_cpu(boot->bpb.bytes_per_sector);
|
||||
fd->sectorCount = sle64_to_cpu(boot->number_of_sectors);
|
||||
fd->pos = 0;
|
||||
fd->len = (fd->sectorCount * fd->sectorSize);
|
||||
fd->ino = le64_to_cpu(boot.volume_serial_number);
|
||||
fd->ino = le64_to_cpu(boot->volume_serial_number);
|
||||
|
||||
// Free memory for boot sector
|
||||
ntfs_free(boot);
|
||||
|
||||
// Mark the device as read-only (if required)
|
||||
if (flags & O_RDONLY) {
|
||||
@ -507,6 +517,7 @@ static int ntfs_device_gekko_io_sync(struct ntfs_device *dev)
|
||||
|
||||
// Mark the device as clean
|
||||
NDevClearDirty(dev);
|
||||
NDevClearSync(dev);
|
||||
|
||||
// Flush any sectors in the disc cache (if required)
|
||||
if (fd->cache) {
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <gccore.h>
|
||||
#include <ogc/disc_io.h>
|
||||
|
||||
#define MAX_SECTOR_SIZE 4096
|
||||
|
||||
/**
|
||||
* gekko_fd - Gekko device driver descriptor
|
||||
*/
|
||||
|
@ -99,7 +99,7 @@ int ntfsFindPartitions (const DISC_INTERFACE *interface, sec_t **partitions)
|
||||
int i;
|
||||
|
||||
union {
|
||||
u8 buffer[512];
|
||||
u8 buffer[MAX_SECTOR_SIZE];
|
||||
MASTER_BOOT_RECORD mbr;
|
||||
EXTENDED_BOOT_RECORD ebr;
|
||||
NTFS_BOOT_SECTOR boot;
|
||||
|
@ -247,7 +247,7 @@ void ntfsDeinitVolume (ntfs_vd *vd)
|
||||
//}
|
||||
|
||||
// Force the underlying device to sync
|
||||
vd->dev->d_ops->sync(vd->dev);
|
||||
ntfs_device_sync(vd->dev);
|
||||
|
||||
// Unlock
|
||||
ntfsUnlock(vd);
|
||||
@ -647,7 +647,7 @@ int ntfsUnlink (ntfs_vd *vd, const char *path)
|
||||
}
|
||||
|
||||
// Force the underlying device to sync
|
||||
vd->dev->d_ops->sync(vd->dev);
|
||||
ntfs_device_sync(vd->dev);
|
||||
|
||||
// ntfs_delete() ALWAYS closes ni and dir_ni; so no need for us to anymore
|
||||
dir_ni = ni = NULL;
|
||||
@ -696,7 +696,7 @@ int ntfsSync (ntfs_vd *vd, ntfs_inode *ni)
|
||||
res = ntfs_inode_sync(ni);
|
||||
|
||||
// Force the underlying device to sync
|
||||
vd->dev->d_ops->sync(vd->dev);
|
||||
ntfs_device_sync(vd->dev);
|
||||
|
||||
// Unlock
|
||||
ntfsUnlock(vd);
|
||||
|
Loading…
Reference in New Issue
Block a user