Fix calculation of FAT size in Xbox 360 FAT filesystem.

This commit is contained in:
2019-04-14 16:37:07 +01:00
parent a45e5aa0e3
commit 2fbc979f14
2 changed files with 26 additions and 10 deletions

View File

@@ -72,7 +72,7 @@ namespace DiscImageChef.Filesystems.FATX
if(fatxSb.magic != FATX_MAGIC) return;
int logicalSectorsPerPhysicalSectors = partition.Offset == 0 ? 8 : 1;
int logicalSectorsPerPhysicalSectors = partition.Offset == 0 && !bigEndian ? 8 : 1;
StringBuilder sb = new StringBuilder();

View File

@@ -73,7 +73,7 @@ namespace DiscImageChef.Filesystems.FATX
DicConsole.DebugWriteLine("Xbox FAT plugin",
littleEndian ? "Filesystem is little endian" : "Filesystem is big endian");
int logicalSectorsPerPhysicalSectors = partition.Offset == 0 ? 8 : 1;
int logicalSectorsPerPhysicalSectors = partition.Offset == 0 && littleEndian ? 8 : 1;
DicConsole.DebugWriteLine("Xbox FAT plugin", "logicalSectorsPerPhysicalSectors = {0}",
logicalSectorsPerPhysicalSectors);
@@ -105,19 +105,19 @@ namespace DiscImageChef.Filesystems.FATX
FreeBlocks = 0 // Requires traversing the FAT
};
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.ClusterSize", XmlFsType.ClusterSize);
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeName", XmlFsType.VolumeName);
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeSerial", XmlFsType.VolumeSerial);
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Blocks", statfs.Blocks);
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.FilenameLength", statfs.FilenameLength);
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Id", statfs.Id);
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Type", statfs.Type);
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.ClusterSize: {0}", XmlFsType.ClusterSize);
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeName: {0}", XmlFsType.VolumeName);
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeSerial: {0}", XmlFsType.VolumeSerial);
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Blocks: {0}", statfs.Blocks);
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.FilenameLength: {0}", statfs.FilenameLength);
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Id: {0}", statfs.Id.Serial32);
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Type: {0}", statfs.Type);
byte[] buffer;
fatStartSector = FAT_START / imagePlugin.Info.SectorSize + partition.Start;
uint fatSize;
DicConsole.DebugWriteLine("Xbox FAT plugin", "fatStartSector", fatStartSector);
DicConsole.DebugWriteLine("Xbox FAT plugin", "fatStartSector: {0}", fatStartSector);
if(statfs.Blocks > MAX_XFAT16_CLUSTERS)
{
@@ -125,6 +125,14 @@ namespace DiscImageChef.Filesystems.FATX
fatSize = (uint)(statfs.Blocks * sizeof(uint) / imagePlugin.Info.SectorSize);
if((uint)(statfs.Blocks * sizeof(uint) % imagePlugin.Info.SectorSize) > 0) fatSize++;
if(!littleEndian)
{
long fatClusters = fatSize * imagePlugin.Info.SectorSize / XmlFsType.ClusterSize;
if(fatSize * imagePlugin.Info.SectorSize % XmlFsType.ClusterSize > 0) fatClusters++;
fatSize = (uint)(fatClusters * XmlFsType.ClusterSize / imagePlugin.Info.SectorSize);
}
DicConsole.DebugWriteLine("Xbox FAT plugin", "FAT is {0} sectors", fatSize);
buffer = imagePlugin.ReadSectors(fatStartSector, fatSize);
@@ -144,6 +152,14 @@ namespace DiscImageChef.Filesystems.FATX
fatSize = (uint)(statfs.Blocks * sizeof(ushort) / imagePlugin.Info.SectorSize);
if((uint)(statfs.Blocks * sizeof(ushort) % imagePlugin.Info.SectorSize) > 0) fatSize++;
if(!littleEndian)
{
long fatClusters = fatSize * imagePlugin.Info.SectorSize / XmlFsType.ClusterSize;
if(fatSize * imagePlugin.Info.SectorSize % XmlFsType.ClusterSize > 0) fatClusters++;
fatSize = (uint)(fatClusters * XmlFsType.ClusterSize / imagePlugin.Info.SectorSize);
}
DicConsole.DebugWriteLine("Xbox FAT plugin", "FAT is {0} sectors", fatSize);
buffer = imagePlugin.ReadSectors(fatStartSector, fatSize);