mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Fix cluster start calculation for FAT32.
This commit is contained in:
@@ -115,16 +115,14 @@ namespace DiscImageChef.Filesystems.FAT
|
||||
|
||||
for(int i = 0; i < clusters.Length; i++)
|
||||
{
|
||||
byte[] buffer =
|
||||
image.ReadSectors(firstClusterSector + (ulong)((clusters[i] - (fat32 ? 2 : 0)) * sectorsPerCluster),
|
||||
sectorsPerCluster);
|
||||
byte[] buffer = image.ReadSectors(firstClusterSector + clusters[i] * sectorsPerCluster,
|
||||
sectorsPerCluster);
|
||||
Array.Copy(buffer, 0, directoryBuffer, i * bytesPerCluster, bytesPerCluster);
|
||||
}
|
||||
|
||||
currentDirectory = new Dictionary<string, CompleteDirectoryEntry>();
|
||||
byte[] lastLfnName = null;
|
||||
byte lastLfnChecksum = 0;
|
||||
List<string> LFNs = new List<string>();
|
||||
byte[] lastLfnName = null;
|
||||
byte lastLfnChecksum = 0;
|
||||
|
||||
for(int pos = 0; pos < directoryBuffer.Length; pos += Marshal.SizeOf<DirectoryEntry>())
|
||||
{
|
||||
|
||||
@@ -56,8 +56,7 @@ namespace DiscImageChef.Filesystems.FAT
|
||||
|
||||
if(fileBlock >= clusters.Length) return Errno.InvalidArgument;
|
||||
|
||||
deviceBlock = (long)(firstClusterSector +
|
||||
(ulong)((clusters[fileBlock] - (fat32 ? 2 : 0)) * sectorsPerCluster));
|
||||
deviceBlock = (long)(firstClusterSector + clusters[fileBlock] * sectorsPerCluster);
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
@@ -103,9 +102,8 @@ namespace DiscImageChef.Filesystems.FAT
|
||||
{
|
||||
if(i + firstCluster >= clusters.Length) return Errno.InvalidArgument;
|
||||
|
||||
byte[] buffer =
|
||||
image.ReadSectors(firstClusterSector + (ulong)((clusters[i + firstCluster] - (fat32 ? 2 : 0)) * sectorsPerCluster),
|
||||
sectorsPerCluster);
|
||||
byte[] buffer = image.ReadSectors(firstClusterSector + clusters[i + firstCluster] * sectorsPerCluster,
|
||||
sectorsPerCluster);
|
||||
|
||||
ms.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
@@ -192,9 +192,8 @@ namespace DiscImageChef.Filesystems.FAT
|
||||
|
||||
// First root directory sector
|
||||
firstClusterSector =
|
||||
(ulong)((fat32Bpb.root_cluster - 2) * fat32Bpb.spc + fat32Bpb.big_spfat * fat32Bpb.fats_no +
|
||||
fat32Bpb.rsectors) * sectorsPerRealSector;
|
||||
sectorsForRootDirectory = 1;
|
||||
(ulong)(fat32Bpb.big_spfat * fat32Bpb.fats_no + fat32Bpb.rsectors) * sectorsPerRealSector -
|
||||
2 * sectorsPerCluster;
|
||||
|
||||
if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End)
|
||||
{
|
||||
@@ -396,8 +395,7 @@ namespace DiscImageChef.Filesystems.FAT
|
||||
foreach(uint cluster in rootDirectoryClusters)
|
||||
{
|
||||
byte[] buffer =
|
||||
imagePlugin.ReadSectors(firstClusterSector + (cluster - 2) * sectorsPerCluster,
|
||||
sectorsPerCluster);
|
||||
imagePlugin.ReadSectors(firstClusterSector + cluster * sectorsPerCluster, sectorsPerCluster);
|
||||
|
||||
rootMs.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
@@ -129,8 +129,7 @@ namespace DiscImageChef.Filesystems.FAT
|
||||
|
||||
foreach(uint cluster in rootDirectoryClusters)
|
||||
{
|
||||
byte[] buffer = image.ReadSectors(firstClusterSector + (cluster - 2) * sectorsPerCluster,
|
||||
sectorsPerCluster);
|
||||
byte[] buffer = image.ReadSectors(firstClusterSector + cluster * sectorsPerCluster, sectorsPerCluster);
|
||||
|
||||
eaMs.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user