rafalh / rust-fatfs

A FAT filesystem library implemented in Rust.
MIT License
302 stars 53 forks source link

Optional lfn/vfat at runtime #95

Open dbalsom opened 4 months ago

dbalsom commented 4 months ago

Hi! Thanks for the great crate - I've used it to implement mounting directories as disk images in my PC emulator, MartyPC: https://github.com/dbalsom/martypc

I think it would be useful to be able to control whether LFN/Vfat is enabled when writing. It looks like you can disable lfn via a feature flag, but that means you don't have it at all. Any chance this could be controlled at runtime so that I can, say, create IO.SYS and MSDOS.SYS as the first two directory entries to make a bootable diskette? If there is a vfat entry created before them, then the disk is not bootable using a DOS boot sector.

rafalh commented 3 months ago

Oh, that's interesting. To be more specific you are talking about MS-DOS boot sector? It only looks at first 2 entries in root directory and ignores the rest? I guess there could be a runtime option, but I'm not sure how the API should look like. Having it as a filesystem option (FsOptions) feels wrong, because you may want to create other files with LFN. It would have to be a flag for Dir::create_file, but I wouldn't want everyone to pass true/false there... I wish Rust had defaults for parameters. Perhaps I should reproduce something like OpenOptions from std lib to allow extensibility.

dbalsom commented 3 months ago

Yes, an MS-DOS boot sector is hardcoded to require those two files as the first entries. For now I have disabled lfn and can create bootable floppies.