Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fat32 doesn't appear to support FSInfo #275

Open
Yazwh0 opened this issue Feb 12, 2023 · 2 comments
Open

Fat32 doesn't appear to support FSInfo #275

Yazwh0 opened this issue Feb 12, 2023 · 2 comments

Comments

@Yazwh0
Copy link

Yazwh0 commented Feb 12, 2023

The FAT32 implementation doesn't appear to implement the FSInfo structure.

http://elm-chan.org/docs/fat_e.html#fsinfo

@LTRData
Copy link

LTRData commented Feb 12, 2023

The link seems broken.

@Yazwh0
Copy link
Author

Yazwh0 commented Feb 12, 2023

Strange, its working for me!

image

Have a workaround by calling this after each update.

    public void UpdateFsInfoFreeSpace()
    {
        var p = _data.Position;
        _data.Position = _bpbFSInfo * SectorSize;
        var fsInfo = StreamUtilities.ReadExact(_data, SectorSize);

        var usedSectors = UsedSpace / SectorSize;
        var freeSectors = TotalSectors - ReservedSectorCount - usedSectors;
        fsInfo[488 + 0] = (byte)(freeSectors & 0xff);
        fsInfo[488 + 1] = (byte)((freeSectors >> 8) & 0xff);
        fsInfo[488 + 2] = (byte)((freeSectors >> 16) & 0xff);
        fsInfo[488 + 3] = (byte)((freeSectors >> 24) & 0xff);

        _data.Position = _bpbFSInfo * SectorSize;
        _data.Write(fsInfo, 0, SectorSize);

        _data.Position = p;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants