mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Fix calculation of FAT size in Xbox 360 FAT filesystem.
This commit is contained in:
@@ -72,7 +72,7 @@ namespace DiscImageChef.Filesystems.FATX
|
|||||||
|
|
||||||
if(fatxSb.magic != FATX_MAGIC) return;
|
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();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace DiscImageChef.Filesystems.FATX
|
|||||||
DicConsole.DebugWriteLine("Xbox FAT plugin",
|
DicConsole.DebugWriteLine("Xbox FAT plugin",
|
||||||
littleEndian ? "Filesystem is little endian" : "Filesystem is big endian");
|
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}",
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "logicalSectorsPerPhysicalSectors = {0}",
|
||||||
logicalSectorsPerPhysicalSectors);
|
logicalSectorsPerPhysicalSectors);
|
||||||
|
|
||||||
@@ -105,19 +105,19 @@ namespace DiscImageChef.Filesystems.FATX
|
|||||||
FreeBlocks = 0 // Requires traversing the FAT
|
FreeBlocks = 0 // Requires traversing the FAT
|
||||||
};
|
};
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.ClusterSize", XmlFsType.ClusterSize);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.ClusterSize: {0}", XmlFsType.ClusterSize);
|
||||||
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeName", XmlFsType.VolumeName);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeName: {0}", XmlFsType.VolumeName);
|
||||||
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeSerial", XmlFsType.VolumeSerial);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeSerial: {0}", XmlFsType.VolumeSerial);
|
||||||
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Blocks", statfs.Blocks);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Blocks: {0}", statfs.Blocks);
|
||||||
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.FilenameLength", statfs.FilenameLength);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.FilenameLength: {0}", statfs.FilenameLength);
|
||||||
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Id", statfs.Id);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Id: {0}", statfs.Id.Serial32);
|
||||||
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Type", statfs.Type);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "stat.Type: {0}", statfs.Type);
|
||||||
|
|
||||||
byte[] buffer;
|
byte[] buffer;
|
||||||
fatStartSector = FAT_START / imagePlugin.Info.SectorSize + partition.Start;
|
fatStartSector = FAT_START / imagePlugin.Info.SectorSize + partition.Start;
|
||||||
uint fatSize;
|
uint fatSize;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Xbox FAT plugin", "fatStartSector", fatStartSector);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "fatStartSector: {0}", fatStartSector);
|
||||||
|
|
||||||
if(statfs.Blocks > MAX_XFAT16_CLUSTERS)
|
if(statfs.Blocks > MAX_XFAT16_CLUSTERS)
|
||||||
{
|
{
|
||||||
@@ -125,6 +125,14 @@ namespace DiscImageChef.Filesystems.FATX
|
|||||||
|
|
||||||
fatSize = (uint)(statfs.Blocks * sizeof(uint) / imagePlugin.Info.SectorSize);
|
fatSize = (uint)(statfs.Blocks * sizeof(uint) / imagePlugin.Info.SectorSize);
|
||||||
if((uint)(statfs.Blocks * sizeof(uint) % imagePlugin.Info.SectorSize) > 0) fatSize++;
|
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);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "FAT is {0} sectors", fatSize);
|
||||||
|
|
||||||
buffer = imagePlugin.ReadSectors(fatStartSector, fatSize);
|
buffer = imagePlugin.ReadSectors(fatStartSector, fatSize);
|
||||||
@@ -144,6 +152,14 @@ namespace DiscImageChef.Filesystems.FATX
|
|||||||
|
|
||||||
fatSize = (uint)(statfs.Blocks * sizeof(ushort) / imagePlugin.Info.SectorSize);
|
fatSize = (uint)(statfs.Blocks * sizeof(ushort) / imagePlugin.Info.SectorSize);
|
||||||
if((uint)(statfs.Blocks * sizeof(ushort) % imagePlugin.Info.SectorSize) > 0) fatSize++;
|
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);
|
DicConsole.DebugWriteLine("Xbox FAT plugin", "FAT is {0} sectors", fatSize);
|
||||||
|
|
||||||
buffer = imagePlugin.ReadSectors(fatStartSector, fatSize);
|
buffer = imagePlugin.ReadSectors(fatStartSector, fatSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user