Hints

I would do this differently now. Please see updated hints.

In 22 steps. At an hour per step you should be still under 1 day's work.

  1. Can you make an empty 4M file, using dd?
  2. Can you write a c program to fill each byte in the empty file with 0's?
  3. How about with 0xff? (Yes, use hex!)
  4. Can you use hexdump to see that what you did work?
  5. Can you set bytes at location i to value v? Where i and v can be more or less whatever?
  6. Can you set words i in the file to integer value v? That means translating from a word to a byte, and from an integer to 4 bytes. Tricky.
  7. Can you now consider a piece of the file to be an array of integers. Starting a byte B, entries 0, 1, 2, etc. Given an index i can you read and write the integer a array location B[i]?
  8. Can you make a struct SuperBlock and read and write that to and from the file, beginning at a given location p?
  9. Can you put the superblock at location 0, and the B of the array of integer at just beyond the superblock, say at location 4096? Where does the "fat table", our array of integers. end? I.e. byte number in the file.
  10. Are you writing subroutines so that you don't have to redo your work of translating indices, and referring to low level functions such as lseek and write? Rather you have functions with names that refer to what you are doing, as in, read_fat_entry, or so forth?
  11. Can you now make a array-represention of a linked list in the fat table? Go to the web to make sure you know what an array-representation of a linked list means.
  12. How are you testing all of this? If you aren't sure, then it isn't working and you are better off fixing it now before things get more complicated.
  13. Are you making a Makefile for this? If you aren't, then you had better do it now before you go away for dinner, come back, and can't remember the steps you take to build your project.
  14. Can you translate between the numbers in your fat table, which are fat table indices, to a block number? Where a block number is the starting byte number of a 4096 byte sequence of bytes, arranged to begin on an even 4096 byte boundary?
  15. Can you make a 5 block file, which we will consider to be the root directory, starting at fat entry 2, and cluster number 2?
  16. Can you make a struct for the directory entries and place them as a sequence into the root directory?
  17. Can you now make (empty) files in the root directory? I.e. create a file by name, open a file by name, and delete a file by name?
  18. Now hook this up to fuse. You have a weird but workable file system that stores a fixed number of files using 8.3 naming in a root directory with no subdirectories. (return any sort of error or a phoney result from fuse). The files in this directory are all empty. Even if you append to them, they just throw stuff away. Why? Why would I make such a thing? Why would I climb half-way up a mountain?
  19. Can you make files that have content? Can you find free blocks by scanning the fat table (make a subroutine), given a fat-entry, can you chain a new free block onto the end of the chain that is started at the fat-entry? Can you allocate an empty file with an empty block of content? Can you play all sorts of tricks with the block chaining .. and if you can ..
  20. Can you put content into your files by chaining enough blocks so the content fits, copying the content in the blocks appropriately, and setting the file length in the directory entry appropriately? And can you read out from your file system, using the information fuse gives you to read?
  21. At this point you have a workable file system that uses 8+3 naming, does not support sub-folders, has a fixed maximum number of folders in the root directory (which is the only directory), but can have read and write files owned by everyone (no permissions implemented). Why? Why would I make such a thing? Why should I climb 3/4 up a mountain?
  22. Ok. At this point the sherpa stays behind. You guys go to the top yourselves, and tell me how it is up there. Good luck.