Git Product home page Git Product logo

vfat-rs's Introduction

VFAT / FAT32

A simple VFAT implementation written in rust, and mostly tested against Linux's vfat driver.

It aims to be simple to understand and easy to use in a custom kernel.

no_std

This component was first developed with no_std in mind. std is mostly supported behind a feature flag. Check example/simple.rs for a usage example.

Run example

To run the example, first create a vfat fs using tests/setup.sh then run the example file using:

cargo run --example simple --feature std

Testing

To run the setup.sh script, I've added an exception for my user in the sudoers file:

fponzi ALL=(ALL) NOPASSWD: /usr/bin/mount,/usr/bin/umount

On github actions (CI) it just works, because the user has passwordless sudo. Then all tests can be run with cargo test. Each test in vfat.rs will create and delete a vfat filesystem.

Utils:

You can check whether the file contains a valid MBR via gdisk:

$ gdisk -l fat32.fs

and you can get info about the filesystem with fdisk:

$ fdisk -l fat32.fs

Some stupid script to flush fs changes:

sudo umount /mnt/test
sudo mount -o loop,offset=$((2048*512)) fat32.fs /mnt/test/
ls -l /mnt/test

Check the changes:

sudo dosfsck -w -r -l -v -r /dev/loop13

TODO

  • Have a better update entry which allows to support renaming.
  • Test: What happens if there are no free clusters (memory is full)?

Long todo:

  • Write to backup FAT as well.
  • Free cluster summary update when allocating clusters.

Future improvements.

  • Currently, the device mutex is shared behind an ARC reference. Maybe, also having the whole FS behind arc would save quite some space when returning files and directories. Because they get a copy of the Vfat struct.
  • Get rid of alloc dependency? It's mostly used for String support rn.

FAQ

  • What happens if I have a "File" handle and meanwhile someone deletes this file and I try to read from a deleted file? This case should be taken care of by the application using this library.

--

Useful docs:


To mount with 777 permission:

sudo mount -o loop,offset=$((2048*512)),uid=1000,gid=1000,dmask=0000,fmask=0001 fat32.fs /mnt/test/

vfat-rs's People

Contributors

federicoponzi avatar osteffenrh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.