A simple filesystem to understand things.

This is a Work In Progress. Do not use this yet.

The source files are licensed under Creative Commons Zero License.
More information at:	http://creativecommons.org/publicdomain/zero/1.0/
Full license text at:	http://creativecommons.org/publicdomain/zero/1.0/legalcode

Architecture + Notes
--------------------

Block Zero = Super block
Block One = Inode store
Block Two = Occupied by the initial file that is created as part of the mkfs.

Only a limited number of filesystem objects are supported.
A file cannot grow beyond one block. ENOSPC will be returned as an error on attempting to do.
Directories store the children inode number and name in their data blocks.
Read support is implemented.
Files and Directories can be created. Support for .create and .mkdir is implemented.
Basic write support is implemented. Writes may not succeed if done in an offset. Works when you overwrite the entire block.
Locks are not well thought-out. The current locking scheme works but needs more analysis + code reviews.
Memory leaks may (will ?) exist.


Credits
--------
All the source code is written by me (Sankar P) until this point. 

An O_LARGETHANKS to the guidance of VijaiBabu M and Santosh Venugopal. Their excellent talks on filesystems motivated me to implement a file system from the scratch. Without their inspirational speeches, I would not have focussed on filesystems.

A big thanks should go to the kernelnewbies mailing list for helping me with clarifying the nitty-gritties of the linux kernel, especially people like Mulyadi Santosa, Valdis Kletnieks, Manish Katiyar, Rajat Sharma etc.

Special thanks to Ankit Jain who provides interesting conversations to help my intellectual curiosities.


TODO
-----
- Check the locks. Remove/Add locks as necessary
- Fix the bug related to creation of files in subdirs
- Fix various README / TODO comments in the code
- Send for review
- Make a 1.0 release
- After the 1.0 release, start with support for extents, which on completion will be 2.0
- After the 2.0 release, start with journalling support, which on completion will be 3.0


How To ?
--------
If you are planning to learn filesystems, start from the scratch. You can look from the first commit in this repository and move the way up.


To compile:
------------
install linux kernel sources and run make from the checkedout directory.


To test:
---------

psankar@linux-9dni:~/src/simplefs> make

psankar@linux-9dni:~/src/simplefs> dd bs=4096 count=100 if=/dev/zero of=image
100+0 records in
100+0 records out
409600 bytes (410 kB) copied, 0.00106827 s, 383 MB/s
psankar@linux-9dni:~/src/simplefs> ./mkfs-simplefs image 
Super block written succesfully
root directory inode written succesfully
welcomefile inode written succesfully
inode store padding bytes (after the two inodes) written sucessfully
root directory datablocks (name+inode_no pair for welcomefile) written succesfully
padding after the rootdirectory children written succesfully
welcomefilebody has been written succesfully

psankar@linux-9dni:~/src/simplefs>

Now as root:
linux-9dni:/home/psankar/src/simplefs # insmod simplefs.ko ; mount -o loop -t simplefs image /home/psankar/src/simplefs/mount/
linux-9dni:/home/psankar/src/simplefs # cd mount/
linux-9dni:/home/psankar/src/simplefs/mount # ls
vanakkam
linux-9dni:/home/psankar/src/simplefs/mount # cat vanakkam
Love is God. God is Love. Anbe Murugan.
linux-9dni:/home/psankar/src/simplefs/mount # cp vanakkam Hello
linux-9dni:/home/psankar/src/simplefs/mount # cat Hello
Love is God. God is Love. Anbe Murugan.
linux-9dni:/home/psankar/src/simplefs/mount # echo "Hello World" > Hello
linux-9dni:/home/psankar/src/simplefs/mount # cat Hello
Hello World
linux-9dni:/home/psankar/src/simplefs/mount # mkdir dir
linux-9dni:/home/psankar/src/simplefs/mount # cd dir
linux-9dni:/home/psankar/src/simplefs/mount/dir # cp ../Hello .
linux-9dni:/home/psankar/src/simplefs/mount/dir # cat Hello
Hello World
linux-9dni:/home/psankar/src/simplefs/mount/dir # echo "Vanakkam Ulagam" > Hello 
linux-9dni:/home/psankar/src/simplefs/mount/dir # cat Hello
Vanakkam Ulagam
linux-9dni:/home/psankar/src/simplefs/mount/dir # ...
linux-9dni:/home/psankar/src/simplefs # umount mount ; rmmod simplefs.ko
linux-9dni:/home/psankar/src/simplefs # #Now let us remount and see if all the changes were written to the disk
linux-9dni:/home/psankar/src/simplefs # insmod simplefs.ko ; mount -o loop -t simplefs image /home/psankar/src/simplefs/mount/
linux-9dni:/home/psankar/src/simplefs # cd mount/
linux-9dni:/home/psankar/src/simplefs/mount # cat Hello
Hello World
linux-9dni:/home/psankar/src/simplefs/mount #
Description
A simple, kernel-space, on-disk filesystem from the scratch
Readme 158 KiB
Languages
C 92.7%
Shell 6.5%
Makefile 0.8%