fat32rs 0.0.1

Minimal FAT32 client written in #[no_std] Rust.
Documentation
  • Coverage
  • 0%
    0 out of 64 items documented0 out of 22 items with examples
  • Size
  • Source code size: 67.16 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.97 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • careyi3/fat32rs
    31 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • careyi3

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!