mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[FAT] Fix that first 2 FAT entries are not considered part of the allocation ones, allocating two more.
This commit is contained in:
@@ -710,7 +710,8 @@ namespace Aaru.Filesystems
|
|||||||
{
|
{
|
||||||
if(clusters < 4089)
|
if(clusters < 4089)
|
||||||
{
|
{
|
||||||
ushort[] fat12 = new ushort[clusters];
|
// The first 2 FAT entries do not count as allocation clusters in FAT12 and FAT16
|
||||||
|
ushort[] fat12 = new ushort[clusters + 2];
|
||||||
|
|
||||||
_reservedSectors = fakeBpb.rsectors;
|
_reservedSectors = fakeBpb.rsectors;
|
||||||
sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize;
|
sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize;
|
||||||
@@ -735,7 +736,7 @@ namespace Aaru.Filesystems
|
|||||||
foreach(ushort entry in fat12)
|
foreach(ushort entry in fat12)
|
||||||
{
|
{
|
||||||
if(entry >= FAT12_RESERVED ||
|
if(entry >= FAT12_RESERVED ||
|
||||||
entry <= clusters)
|
entry <= clusters + 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fat12Valid = false;
|
fat12Valid = false;
|
||||||
@@ -750,7 +751,7 @@ namespace Aaru.Filesystems
|
|||||||
foreach(ushort entry in fat16)
|
foreach(ushort entry in fat16)
|
||||||
{
|
{
|
||||||
if(entry >= FAT16_RESERVED ||
|
if(entry >= FAT16_RESERVED ||
|
||||||
entry <= clusters)
|
entry <= clusters + 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fat16Valid = false;
|
fat16Valid = false;
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ namespace Aaru.Filesystems
|
|||||||
{
|
{
|
||||||
if(clusters < 4089)
|
if(clusters < 4089)
|
||||||
{
|
{
|
||||||
ushort[] fat12 = new ushort[clusters];
|
ushort[] fat12 = new ushort[clusters + 1];
|
||||||
|
|
||||||
_reservedSectors = fakeBpb.rsectors;
|
_reservedSectors = fakeBpb.rsectors;
|
||||||
sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize;
|
sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize;
|
||||||
@@ -839,8 +839,8 @@ namespace Aaru.Filesystems
|
|||||||
|
|
||||||
_bytesPerCluster = _sectorsPerCluster * imagePlugin.Info.SectorSize;
|
_bytesPerCluster = _sectorsPerCluster * imagePlugin.Info.SectorSize;
|
||||||
|
|
||||||
ushort[] firstFatEntries = new ushort[_statfs.Blocks];
|
ushort[] firstFatEntries = new ushort[_statfs.Blocks + 2];
|
||||||
ushort[] secondFatEntries = new ushort[_statfs.Blocks];
|
ushort[] secondFatEntries = new ushort[_statfs.Blocks + 2];
|
||||||
bool firstFatValid = true;
|
bool firstFatValid = true;
|
||||||
bool secondFatValid = true;
|
bool secondFatValid = true;
|
||||||
|
|
||||||
@@ -864,7 +864,7 @@ namespace Aaru.Filesystems
|
|||||||
|
|
||||||
fatBytes = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat);
|
fatBytes = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat);
|
||||||
|
|
||||||
_fatEntries = new ushort[_statfs.Blocks];
|
_fatEntries = new ushort[_statfs.Blocks + 2];
|
||||||
|
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
|
||||||
@@ -881,7 +881,7 @@ namespace Aaru.Filesystems
|
|||||||
foreach(ushort entry in firstFatEntries)
|
foreach(ushort entry in firstFatEntries)
|
||||||
{
|
{
|
||||||
if(entry >= FAT12_RESERVED ||
|
if(entry >= FAT12_RESERVED ||
|
||||||
entry <= _statfs.Blocks)
|
entry <= _statfs.Blocks + 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
firstFatValid = false;
|
firstFatValid = false;
|
||||||
@@ -892,7 +892,7 @@ namespace Aaru.Filesystems
|
|||||||
foreach(ushort entry in secondFatEntries)
|
foreach(ushort entry in secondFatEntries)
|
||||||
{
|
{
|
||||||
if(entry >= FAT12_RESERVED ||
|
if(entry >= FAT12_RESERVED ||
|
||||||
entry <= _statfs.Blocks)
|
entry <= _statfs.Blocks + 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
secondFatValid = false;
|
secondFatValid = false;
|
||||||
@@ -924,7 +924,7 @@ namespace Aaru.Filesystems
|
|||||||
foreach(ushort entry in firstFatEntries)
|
foreach(ushort entry in firstFatEntries)
|
||||||
{
|
{
|
||||||
if(entry >= FAT16_RESERVED ||
|
if(entry >= FAT16_RESERVED ||
|
||||||
entry <= _statfs.Blocks)
|
entry <= _statfs.Blocks + 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
firstFatValid = false;
|
firstFatValid = false;
|
||||||
@@ -935,7 +935,7 @@ namespace Aaru.Filesystems
|
|||||||
foreach(ushort entry in secondFatEntries)
|
foreach(ushort entry in secondFatEntries)
|
||||||
{
|
{
|
||||||
if(entry >= FAT16_RESERVED ||
|
if(entry >= FAT16_RESERVED ||
|
||||||
entry <= _statfs.Blocks)
|
entry <= _statfs.Blocks + 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
secondFatValid = false;
|
secondFatValid = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user