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,8 +115,7 @@ namespace DiscImageChef.Filesystems.FAT
|
|||||||
|
|
||||||
for(int i = 0; i < clusters.Length; i++)
|
for(int i = 0; i < clusters.Length; i++)
|
||||||
{
|
{
|
||||||
byte[] buffer =
|
byte[] buffer = image.ReadSectors(firstClusterSector + clusters[i] * sectorsPerCluster,
|
||||||
image.ReadSectors(firstClusterSector + (ulong)((clusters[i] - (fat32 ? 2 : 0)) * sectorsPerCluster),
|
|
||||||
sectorsPerCluster);
|
sectorsPerCluster);
|
||||||
Array.Copy(buffer, 0, directoryBuffer, i * bytesPerCluster, bytesPerCluster);
|
Array.Copy(buffer, 0, directoryBuffer, i * bytesPerCluster, bytesPerCluster);
|
||||||
}
|
}
|
||||||
@@ -124,7 +123,6 @@ namespace DiscImageChef.Filesystems.FAT
|
|||||||
currentDirectory = new Dictionary<string, CompleteDirectoryEntry>();
|
currentDirectory = new Dictionary<string, CompleteDirectoryEntry>();
|
||||||
byte[] lastLfnName = null;
|
byte[] lastLfnName = null;
|
||||||
byte lastLfnChecksum = 0;
|
byte lastLfnChecksum = 0;
|
||||||
List<string> LFNs = new List<string>();
|
|
||||||
|
|
||||||
for(int pos = 0; pos < directoryBuffer.Length; pos += Marshal.SizeOf<DirectoryEntry>())
|
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;
|
if(fileBlock >= clusters.Length) return Errno.InvalidArgument;
|
||||||
|
|
||||||
deviceBlock = (long)(firstClusterSector +
|
deviceBlock = (long)(firstClusterSector + clusters[fileBlock] * sectorsPerCluster);
|
||||||
(ulong)((clusters[fileBlock] - (fat32 ? 2 : 0)) * sectorsPerCluster));
|
|
||||||
|
|
||||||
return Errno.NoError;
|
return Errno.NoError;
|
||||||
}
|
}
|
||||||
@@ -103,8 +102,7 @@ namespace DiscImageChef.Filesystems.FAT
|
|||||||
{
|
{
|
||||||
if(i + firstCluster >= clusters.Length) return Errno.InvalidArgument;
|
if(i + firstCluster >= clusters.Length) return Errno.InvalidArgument;
|
||||||
|
|
||||||
byte[] buffer =
|
byte[] buffer = image.ReadSectors(firstClusterSector + clusters[i + firstCluster] * sectorsPerCluster,
|
||||||
image.ReadSectors(firstClusterSector + (ulong)((clusters[i + firstCluster] - (fat32 ? 2 : 0)) * sectorsPerCluster),
|
|
||||||
sectorsPerCluster);
|
sectorsPerCluster);
|
||||||
|
|
||||||
ms.Write(buffer, 0, buffer.Length);
|
ms.Write(buffer, 0, buffer.Length);
|
||||||
|
|||||||
@@ -192,9 +192,8 @@ namespace DiscImageChef.Filesystems.FAT
|
|||||||
|
|
||||||
// First root directory sector
|
// First root directory sector
|
||||||
firstClusterSector =
|
firstClusterSector =
|
||||||
(ulong)((fat32Bpb.root_cluster - 2) * fat32Bpb.spc + fat32Bpb.big_spfat * fat32Bpb.fats_no +
|
(ulong)(fat32Bpb.big_spfat * fat32Bpb.fats_no + fat32Bpb.rsectors) * sectorsPerRealSector -
|
||||||
fat32Bpb.rsectors) * sectorsPerRealSector;
|
2 * sectorsPerCluster;
|
||||||
sectorsForRootDirectory = 1;
|
|
||||||
|
|
||||||
if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End)
|
if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End)
|
||||||
{
|
{
|
||||||
@@ -396,8 +395,7 @@ namespace DiscImageChef.Filesystems.FAT
|
|||||||
foreach(uint cluster in rootDirectoryClusters)
|
foreach(uint cluster in rootDirectoryClusters)
|
||||||
{
|
{
|
||||||
byte[] buffer =
|
byte[] buffer =
|
||||||
imagePlugin.ReadSectors(firstClusterSector + (cluster - 2) * sectorsPerCluster,
|
imagePlugin.ReadSectors(firstClusterSector + cluster * sectorsPerCluster, sectorsPerCluster);
|
||||||
sectorsPerCluster);
|
|
||||||
|
|
||||||
rootMs.Write(buffer, 0, buffer.Length);
|
rootMs.Write(buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,8 +129,7 @@ namespace DiscImageChef.Filesystems.FAT
|
|||||||
|
|
||||||
foreach(uint cluster in rootDirectoryClusters)
|
foreach(uint cluster in rootDirectoryClusters)
|
||||||
{
|
{
|
||||||
byte[] buffer = image.ReadSectors(firstClusterSector + (cluster - 2) * sectorsPerCluster,
|
byte[] buffer = image.ReadSectors(firstClusterSector + cluster * sectorsPerCluster, sectorsPerCluster);
|
||||||
sectorsPerCluster);
|
|
||||||
|
|
||||||
eaMs.Write(buffer, 0, buffer.Length);
|
eaMs.Write(buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user