accelazh / hellofs

An example kernel filesystem implementation
Other
87 stars 25 forks source link

Hellofs - An example kernel filesystem implementation

A very simple linux kernel filesystem for learning purpose. It demonstrates how to implement a VFS filesystem, from superblock, inode, dir to file operations. The license is GPL because some kernel functions require it to be available.

Hellofs is written and tested on Centos 7.1.1503 kernel 3.10.0-229.1.2.el7.x86_64. Note that from kernel version 3.11 some code related to dir operations are changed, for example readdir. It is rewritten based on Sankar's Simplefs (commit 5d00eebd)). Thanks to the greate Simplefs! Actually I found most resources about writting kernel FS are outdated (they are always talking about 2.6). But kernel is being developed in such rapid pace (it is 4.x now!). An working example is precious!

Major modifications that I made on Simplefs are

The on-disk layout of Hellofs is

One disk block contains multiple inodes. One data block corresponds to one disk block (and of the same size). Each inode contains only one data block for simplicity.

To run test cases

cd hellofs
sudo ./hellofs-test.sh | grep "Test finished successfully"