mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
* Added trailing fs info sector signature
* Calculate correct cluster size svn path=/trunk/; revision=5677
This commit is contained in:
parent
57a76c0f45
commit
cb15da56e1
2 changed files with 39 additions and 12 deletions
|
@ -134,6 +134,7 @@ VfatWriteFsInfo(IN HANDLE FileHandle,
|
|||
FsInfo->StrucSig = 0x61417272;
|
||||
FsInfo->FreeCount = 0xffffffff;
|
||||
FsInfo->NextFree = 0xffffffff;
|
||||
FsInfo->TrailSig = 0xaa550000;
|
||||
|
||||
/* Write sector */
|
||||
FileOffset.QuadPart = BootSector->FSInfoSector * BootSector->BytesPerSector;
|
||||
|
@ -425,10 +426,35 @@ VfatFormat(
|
|||
return Status;
|
||||
}
|
||||
|
||||
/* Calculate cluster size */
|
||||
if (ClusterSize == 0)
|
||||
{
|
||||
if (PartitionInfo.PartitionLength.QuadPart < 8ULL * 1024ULL * 1024ULL)
|
||||
{
|
||||
/* Partition < 8GB ==> 4KB Cluster */
|
||||
ClusterSize = 4096;
|
||||
}
|
||||
else if (PartitionInfo.PartitionLength.QuadPart < 16ULL * 1024ULL * 1024ULL)
|
||||
{
|
||||
/* Partition 8GB - 16GB ==> 8KB Cluster */
|
||||
ClusterSize = 8192;
|
||||
}
|
||||
else if (PartitionInfo.PartitionLength.QuadPart < 32ULL * 1024ULL * 1024ULL)
|
||||
{
|
||||
/* Partition 16GB - 32GB ==> 16KB Cluster */
|
||||
ClusterSize = 16384;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Partition >= 32GB ==> 32KB Cluster */
|
||||
ClusterSize = 32768;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&BootSector, 0, sizeof(FAT32_BOOT_SECTOR));
|
||||
memcpy(&BootSector.OEMName[0], "MSWIN4.1", 8);
|
||||
BootSector.BytesPerSector = DiskGeometry.BytesPerSector;
|
||||
BootSector.SectorsPerCluster = 4096 / BootSector.BytesPerSector; // 4KB clusters /* FIXME: */
|
||||
BootSector.SectorsPerCluster = ClusterSize / BootSector.BytesPerSector;
|
||||
BootSector.ReservedSectors = 32;
|
||||
BootSector.FATCount = 2;
|
||||
BootSector.RootEntries = 0;
|
||||
|
@ -437,7 +463,7 @@ VfatFormat(
|
|||
BootSector.FATSectors = 0;
|
||||
BootSector.SectorsPerTrack = DiskGeometry.SectorsPerTrack;
|
||||
BootSector.Heads = DiskGeometry.TracksPerCylinder;
|
||||
BootSector.HiddenSectors = PartitionInfo.HiddenSectors;
|
||||
BootSector.HiddenSectors = DiskGeometry.SectorsPerTrack; //PartitionInfo.HiddenSectors;
|
||||
BootSector.SectorsHuge = PartitionInfo.PartitionLength.QuadPart >>
|
||||
GetShiftCount(BootSector.BytesPerSector); /* Use shifting to avoid 64-bit division */
|
||||
BootSector.FATSectors32 = 0; /* Set later */
|
||||
|
|
|
@ -26,9 +26,9 @@ typedef struct _FAT32_BOOT_SECTOR
|
|||
unsigned char Media; // 21
|
||||
unsigned short FATSectors; // 22
|
||||
unsigned short SectorsPerTrack; // 24
|
||||
unsigned short Heads; // 22
|
||||
unsigned long HiddenSectors; // 24
|
||||
unsigned long SectorsHuge; // 28
|
||||
unsigned short Heads; // 26
|
||||
unsigned long HiddenSectors; // 28
|
||||
unsigned long SectorsHuge; // 32
|
||||
unsigned long FATSectors32; // 36
|
||||
unsigned short ExtFlag; // 40
|
||||
unsigned short FSVersion; // 42
|
||||
|
@ -48,10 +48,11 @@ typedef struct _FAT32_BOOT_SECTOR
|
|||
|
||||
typedef struct _FAT32_FSINFO
|
||||
{
|
||||
unsigned int LeadSig; // 0
|
||||
unsigned char Res1[480]; // 4
|
||||
unsigned int StrucSig; // 484
|
||||
unsigned int FreeCount; // 488
|
||||
unsigned int NextFree; // 492
|
||||
unsigned int Res2; // 496
|
||||
unsigned long LeadSig; // 0
|
||||
unsigned char Res1[480]; // 4
|
||||
unsigned long StrucSig; // 484
|
||||
unsigned long FreeCount; // 488
|
||||
unsigned long NextFree; // 492
|
||||
unsigned long Res2[3]; // 496
|
||||
unsigned long TrailSig; // 508
|
||||
} __attribute__((packed)) FAT32_FSINFO, *PFAT32_FSINFO;
|
||||
|
|
Loading…
Reference in a new issue