Update history:

Mini Fat Fuse Project

You are to write a file system using FUSE. The file system will be a simplified version of FAT.

The class/projX folder has the FUSE "hello world filesystem" example, that should work with make; make test.

Implementation highlights

  1. Read the documentation on FUSE and get the hello-world file system working on FUSE.
  2. Read the FAT documentation quickly for the main ideas.
  3. The FAT table will have 32-bit entries.
  4. Cluster free mark is 0, EOC (end of cluster chain) mark is -1 (0xffffffff).
  5. A zero-length file "begins" at cluster 0 (which is unclaimable).
  6. Implement an empty directory by a NULL as the first character in the filename.
  7. Filenames are padded with 0x20.
  8. You do not have to implement the behavior associated with 0xe5/0x05 as the first character in the filename.
  9. Directories have no length, they always end in even blocks.
  10. Don't worry about getting create and access times correct (believe me, MS doesn't either).

The longest journey/first step spiel

  1. Make these simplifications (except see extra credit below):
  2. Implement incrementally in this order (just a hint. YMMV):
  3. You should know by now that the successful developer:

Where is my disk partition?

One thing that confuses people is where the "disk partition" will be that holds the file system.

Here it is:

   dd if=/dev/zero of=mydisk.dmg bs=1024 count=1024
Open this file and lseek to byte positions, and read and write from this file as you would the disk. Almost. On a disk you can only read and write entire clusters. No need to stand on formalities, for this project you can read or write whatever lengths are convenient.

Example: To update a FAT entry, just write the 32 bit entry. No need to read into a buffer the entire contents of the 1024 byte cluster containing the entry, updating the entry in the buffer, and then writing back all 1024 bytes. In the "real world", this does happen. Disk drives read or write in blocks.

A friend in need:

     hexdump -C mydisk.dmg
See man hexdump.

Extra credit

  1. Variable length directories.
  2. Subdirectories.
  3. LFN: long file names, and default short file names

Hints

/*
 * mini_fat_fuse
 *    a really simple fat file system using fuse
 * assume: 
 *    1- 1024 byte clusters
 *    2- cluster 0 is superblock and can be all zeros
 *    3- clusters 1-4 is the fat table of 1024 entries
 *    4- cluster 5 is the first cluster of the root directory
 *    5- root directory has no . or .. entries
 *    6- we do not support subdirectories
 *    7- fat table entry is simple: cluster 5 is the 5-th 
 *       entry of the fat table
 *    8- there are a total of 1024 clusters, of which the
 *       first 5 are metadata. The total disk size if 1019Ki
 *    9- the file system can be initialized to zero using:
 *       dd if=/dev/zero of=mini_fat.dmg bs=1024 count=1024
 *
 *  Implementation:
 *    1- Implement the directory functions: readdir, getattr, open, create
 *    2- Implement unlink
 *    3- Implement write (use hexdump -C against fat.dmg file to debug)
 *    4- Implement read
 *    5- Further functions: truncate and utimens
 *
 * How to start:
 *
 *    A- files are one block long; don't use FAT table, just
 *       a next free cluster index in superblock; don't reclaim
 *       blocks on unlink
 *
 * How to continue:
 *
 *    I would next implement multiple cluster files, modifying
 *    fat_read and fat_write, and introducing use of the FAT table.
 *    Truncate reimplementation can do all handing of adding and removing
 *    clusters to the cluster chain, so write can assume the file has
 *    enough clusters.
 *
 */