fat32rs

Crates.iofat32rs
lib.rsfat32rs
version0.0.1
created_at2025-08-15 18:02:49.789568+00
updated_at2025-08-15 18:02:49.789568+00
descriptionMinimal FAT32 client written in #[no_std] Rust.
homepagehttps://github.com/careyi3/fat32rs
repositoryhttps://github.com/careyi3/fat32rs
max_upload_size
id1797255
size67,168,080
Ian Carey (careyi3)

documentation

README

fat32rs

Minimal FAT32 client written in #[no_std] Rust.

This is library was designed to operate within some specific constraints imposed by running in an embedded systems environment.

Based on this original Python prototype: fat32py

*The following instructions assumes a Linux or Mac environment

Test

Features

The only features implemented are:

  • List the files in the root directory of the drive
  • Append to a file on the drive
  • Create a new file in the root directory of the drive
  • Get a root directory file by name

Setup

All you should need is a working dev environment for Rust with Cargo installed. You can find instructions here.

Running

To run the examples simply run the below:

$ cargo run --example print_files
 

Note: If you want to read from your own physical drive, you can pass an argument like /dev/diskn which will run against your physical drive.

$ cargo run --example print_files /dev/disk4
 

I recommend using an SDCard. If you plug one into you system, you can see the name for it by listing all the files in your /dev directory:

$ cd /dev
$ ls
 

Tests

You can run tests by running:

$ cargo test
 

This will use a 64MB .img drive preloaded with test files which you can find at ./tests/data/drive.img.

Generating a disk image fixture

$ cd ./tests/data
 

This will create an empty .dmg image formatted for FAT32 with the volume name DRIVE.

$ sudo hdiutil create -size 64m -fs FAT32 -layout MBRSPUD -volname DRIVE ./drive.dmg
 

This will create an empty .dmg image formatted for FAT32 with the volume name DRIVE.

$ hdiutil convert drive.dmg -format UDRW -o drive.img
 
$ hdiutil attach drive.img
/dev/disk6              FDisk_partition_scheme         
/dev/disk6s1            DOS_FAT_32                      /Volumes/DRIVE
# this output you will need for the next step, will be different for your system
$ open /Volumes/DRIVE
 

You can now use the disk as normal. If you are using the drive committed in this repo, you will notice it has two files LOG-1 and LOG-2. These are used by the tests. However, you can add or modify the drive as you like, just make sure to update the tests!

Commit count: 0

cargo fmt