Start working on FAT formatter

This commit is contained in:
Pdawg11239
2025-03-16 13:51:50 -04:00
parent 642fd5e1ed
commit 87cf731f0b
6 changed files with 127 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
namespace BadBuilder.Formatter
{
static class FAT32Utilities
{
internal static uint GetVolumeID()
{
DateTime now = DateTime.Now;
ushort low = (ushort)(now.Day + (now.Month << 8));
low += (ushort)((now.Millisecond / 10) + (now.Second << 8));
ushort hi = (ushort)(now.Minute + (now.Hour << 8));
hi += (ushort)now.Year;
return (uint)(low | (hi << 16));
}
internal static uint CalculateFATSize(uint diskSize, uint reservedSectorCount, uint sectorsPerCluster, uint numberOfFATs, uint bytesPerSector)
{
const ulong fatElementSize = 4;
ulong numerator = fatElementSize * (diskSize - reservedSectorCount);
ulong denominator = (sectorsPerCluster * bytesPerSector) + (fatElementSize * numberOfFATs);
return (uint)((numerator / denominator) + 1);
}
}
}