#fat #read-write #file-io #fatfs #driver #targeted #mainly

no-std simple-fatfs

A simple-to-use FAT filesystem library for Rust (mainly targeted at embedded systems)

1 unstable release

0.1.0-alpha.1 Aug 4, 2024

#406 in Embedded development

MIT license

82KB
2K SLoC

simple-fatfs

CI Status GitHub License Crates.io Version docs.rs Crates.io MSRV

A simple-to-use filesystem driver for the File Allocation Table (FAT)

Motive

Apart from rafalh's rust-fatfs library, there aren't actually any other FAT filesystem drivers in crates.io. All the other libraries either support only FAT16/32, aren't being actively developed or are just bindings to some C library.

Another thing I found somewhat frustrating about rafalh's rust-fatfs (which ultimately led to my decision of creating this project) is the fact that his library isn't suitable for embedded Rust, since it requires implementing some weird kind of buffered Read/Write, while it is also worth mentioning that the crates.io version of his library is somewhat outdated (there have been 144 additional commits as of the time I'm writing this).

Intent

A fully-working FAT driver that covers the following criteria:

  • An easy-to-use public API for developers
  • Avoids unnecessary/overbloated dependencies (I am talking about leftpad-like dependencies)
  • #[no_std] support
  • Auto-impls for already-existing std APIs (like the Read, Write & Seek traits)
  • FAT12/16/32/ExFAT support
  • VFAT/LFN (long filename) support

TODO

  • FAT12 support (just handle entries between 2 sectors)
  • Distinguish between dirs and files in paths (this must also be verified by the filesystem, just like in the std)
  • Check whether system endianness matters (FAT is little-endian)
  • Handle non-printable characters in names of files and directories
  • ExFAT support
  • when feature(error_in_core) gets released to stable, bump MSRV & use the core::error::Error trait instead of our custom error::Error

Acknowledgements

This project adheres to Keep a Changelog and Conventional Commits (since commit 21c7d6b, that is excluding the first two commits which don't actually contain any code). It also uses git-cliff to parse commit messages into a CHANGELOG

License

MIT

Dependencies

~1.1–1.8MB
~38K SLoC