Coder Social home page Coder Social logo

mapulse / fat16gen Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geoffreymbrown/fat16gen

0.0 0.0 0.0 14 KB

fat16 file system generator for embedded devices. Creates compact, table driven file system with support for both static and virtual files

License: MIT License

Makefile 0.96% C 35.71% Python 63.33%

fat16gen's Introduction

Generates a fat16 file system

While this is intended for use in embedded devices, the test code provided will generate a static image. In the dynamic case, the file system consists of a constant table driven file system with a few built-in functions to generate content on demand. This content includes the fat16 boot record and fat tables as well as directories and static files. The code also provides a hook for dynamic file content.

How this works

The main module, gensys, takes as input a root directory (containing static files and directories) and a list of "virtual file" definitions (where they go in the file hierarchy, their size, a generator function name, and a (void *) operand). The code below (in gensys.py) generates an example file system definition on stdout.

    volume_name = 'Test Volume'   # fat16 volume name
    table_name  = 'filesys'       # C name of file system table
    fdout = sys.stdout            # output file
    rootdir = 'testdir'           # path to root file system

    vfiles = [{'path' : os.path.join(rootdir,'a virtual file.txt'), 
               'size' : 1024, 
               'func' : 'vfile_1', 
               'operand' : '(void *) 0'
               }
              ]

    fs = vFileSystem(rootdir,vfiles)
    fs.gensys(fdout,table_name,volume_name)

It doesn't appear (easily) feasible to generate a file system that the host can modify; thankfully that wasn't necessary for our application -- an embedded data logger with a large flash (2Gbit) chip. We wanted an easy way to access that data and perhaps a bit of status information (through a virtual file).

To test this, you don't need an embedded device. The Makefile will generate an image -- execute make to generate test image test.img that can be mounted. This image contains the files and directories in testdir along with one virtual file a virtual file.txt. The contents of this file are generated by the procedure vfile_1 in testmain.c

Implementation Notes

The other major module is fatname.py. This is where all the conversion from host file system names to Microsoft long and short file names occurs. It's somewhat hard to be sure that all possible cases are accounted for (the available fat file system documentation leaves a bit too much as an exercise to the reader). If there's a case that doesn't work, perhaps the best thing is to rename your static files; alternatively, suggest a patch.

The code also doesn't check for "long name" collisions -- cases where two long names are rewritten (to meet windows requirements) to the same string.

This was implemented using the gcc compiler; fat.h uses attributes to define packed data structures for key components of the fat16 file system. This is an area of risk if you move to a different compiler.

I did look at emfat (see below) but decided that I wanted to pursue a different direction. In particular, fat16gen uses a python script to generate information that is similar to what emfat requires as input. Another essential difference is that the fat16gen generates static directory "files". This greatly simplified the necessary runtime and made it easier to support the rather complex issues related to long file names.

Links

fat16gen's People

Contributors

geoffreymbrown 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.