{"id":13437317,"url":"https://github.com/psankar/simplefs","last_synced_at":"2025-03-19T06:31:00.008Z","repository":{"id":9756244,"uuid":"11722259","full_name":"psankar/simplefs","owner":"psankar","description":"A simple, kernel-space, on-disk filesystem from the scratch","archived":false,"fork":false,"pushed_at":"2024-11-05T01:24:47.000Z","size":101,"stargazers_count":936,"open_issues_count":2,"forks_count":220,"subscribers_count":59,"default_branch":"master","last_synced_at":"2024-11-05T02:26:16.603Z","etag":null,"topics":["c","filesystem","kernel"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/psankar.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-28T16:22:08.000Z","updated_at":"2024-11-05T01:24:51.000Z","dependencies_parsed_at":"2022-08-11T04:21:13.980Z","dependency_job_id":null,"html_url":"https://github.com/psankar/simplefs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psankar%2Fsimplefs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psankar%2Fsimplefs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psankar%2Fsimplefs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psankar%2Fsimplefs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psankar","download_url":"https://codeload.github.com/psankar/simplefs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244370951,"owners_count":20442319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","filesystem","kernel"],"created_at":"2024-07-31T03:00:55.952Z","updated_at":"2025-03-19T06:31:00.003Z","avatar_url":"https://github.com/psankar.png","language":"C","readme":"A simple filesystem to understand things.\n\nThis is a Work In Progress. Do not use this yet.\n\nIf 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.\n\nThe source files are licensed under Creative Commons Zero License.\nMore information at:\thttp://creativecommons.org/publicdomain/zero/1.0/\nFull license text at:\thttp://creativecommons.org/publicdomain/zero/1.0/legalcode\n\nsimplefs 1.0 Architecture + Notes\n---------------------------------\n\nBlock Zero = Super block\nBlock One = Inode store\nBlock Two = Occupied by the initial file that is created as part of the mkfs.\n\nOnly a limited number of filesystem objects are supported.\nFiles and Directories can be created. Support for .create and .mkdir is implemented. Nested directories can be created.\nA file cannot grow beyond one block. ENOSPC will be returned as an error on attempting to do.\nDirectories store the children inode number and name in their data blocks.\nRead support is implemented.\nBasic write support is implemented. Writes may not succeed if done in an offset. Works when you overwrite the entire block.\nLocks are not well thought-out. The current locking scheme works but needs more analysis + code reviews.\nMemory leaks may (will ?) exist.\n\n\nCredits\n--------\nThe initial source code is written by psankar and patches are contributed by other github members. azat being the first contributor.\n\nAn 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.\n\nA 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.\n\nSpecial thanks to Ankit Jain who provides interesting conversations to help my intellectual curiosities.\n\n\nPatch Submission\n-----------------\nPlease send a merge request only if you are ready to publish your changes in the same creative commons zero license.\n\nWe would like to keep the filesystem simple and minimal so that it can be used as a good teaching material.\n\nWe are not planning to use this filesystem in a production machine. So some design choices are driven by learning/teaching simplicity over performance/scalability. This is intentional. So do not try to fix those things :)\n\nTODO\n-----\n- After the 1.0 release, start with support for extents, which on completion will be 2.0\n- After the 2.0 release, start with journalling support, which on completion will be 3.0\n\n\nTo compile:\n------------\ninstall linux kernel sources and run make from the checkedout directory.\n\n\nTo test:\n---------\nAnd here is the build environment for simplefs: https://github.com/azat/simplefs-bld\n\npsankar@linux-9dni:~/src/simplefs\u003e make\n\npsankar@linux-9dni:~/src/simplefs\u003e dd bs=4096 count=100 if=/dev/zero of=image\n100+0 records in\n100+0 records out\n409600 bytes (410 kB) copied, 0.00106827 s, 383 MB/s\npsankar@linux-9dni:~/src/simplefs\u003e ./mkfs-simplefs image\nSuper block written succesfully\nroot directory inode written succesfully\nwelcomefile inode written succesfully\ninode store padding bytes (after the two inodes) written sucessfully\nroot directory datablocks (name+inode_no pair for welcomefile) written succesfully\npadding after the rootdirectory children written succesfully\nwelcomefilebody has been written succesfully\n\npsankar@linux-9dni:~/src/simplefs\u003e\n\nNow as root:\nlinux-9dni:/home/psankar/src/simplefs # insmod simplefs.ko ; mount -o loop -t simplefs image /home/psankar/src/simplefs/mount/ ; dmesg\n[41932.281196] Sucessfully registered simplefs\n[41932.284811] The magic number obtained in disk is: [268640275]\n[41932.284813] simplefs filesystem of version [1] formatted with a block size of [4096] detected in the device.\n[41932.284823] simplefs is succesfully mounted on [/dev/loop16]\nlinux-9dni:/home/psankar/src/simplefs # cd mount/\nlinux-9dni:/home/psankar/src/simplefs/mount # ls\nvanakkam\nlinux-9dni:/home/psankar/src/simplefs/mount # cat vanakkam\nLove is God. God is Love. Anbe Murugan.\nlinux-9dni:/home/psankar/src/simplefs/mount # cp vanakkam hello\nlinux-9dni:/home/psankar/src/simplefs/mount # cat hello\nLove is God. God is Love. Anbe Murugan.\nlinux-9dni:/home/psankar/src/simplefs/mount # echo \"Hello World\" \u003e hello\nlinux-9dni:/home/psankar/src/simplefs/mount # cat hello\nHello World\nlinux-9dni:/home/psankar/src/simplefs/mount # mkdir dir1\nlinux-9dni:/home/psankar/src/simplefs/mount # cd dir1\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1 # cp ../hello .\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1 # cat hello\nHello World\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1 # echo \"First level directory\" \u003e hello\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1 # cat hello\nFirst level directory\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1 # mkdir dir2\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1 # cd dir2\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1/dir2 # touch hello\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1/dir2 # cat hello\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1/dir2 # echo \"Second level directory\" \u003e hello\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1/dir2 # cat hello\nSecond level directory\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1/dir2 # ...\nlinux-9dni:/home/psankar/src/simplefs/mount # ..\nlinux-9dni:/home/psankar/src/simplefs # umount mount ; rmmod simplefs.ko ;\nlinux-9dni:/home/psankar/src/simplefs # insmod simplefs.ko ; mount -o loop -t simplefs image /home/psankar/src/simplefs/mount/\nlinux-9dni:/home/psankar/src/simplefs # cd mount\nlinux-9dni:/home/psankar/src/simplefs/mount # ls -lR\n.:\ntotal 0\ndrwxr-xr-x 1 root root 0 Aug  5 22:43 dir1\n---------- 1 root root 0 Aug  5 22:43 hello\n---------- 1 root root 0 Aug  5 22:43 vanakkam\n\n./dir1:\ntotal 0\ndrwxr-xr-x 1 root root 0 Aug  5 22:43 dir2\n---------- 1 root root 0 Aug  5 22:43 hello\n\n./dir1/dir2:\ntotal 0\n-rw-r--r-- 1 root root 0 Aug  5 22:43 hello\nlinux-9dni:/home/psankar/src/simplefs/mount # cat hello\nHello World\nlinux-9dni:/home/psankar/src/simplefs/mount # cd dir1\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1 # cat hello\nFirst level directory\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1 # cd dir2/\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1/dir2 # cat hello\nSecond level directory\nlinux-9dni:/home/psankar/src/simplefs/mount/dir1/dir2 # ...\nlinux-9dni:/home/psankar/src/simplefs/mount # ..\nlinux-9dni:/home/psankar/src/simplefs # umount mount ; rmmod simplefs.ko ;\nlinux-9dni:/home/psankar/src/simplefs # dmesg\n[41932.281196] Sucessfully registered simplefs\n[41932.284811] The magic number obtained in disk is: [268640275]\n[41932.284813] simplefs filesystem of version [1] formatted with a block size of [4096] detected in the device.\n[41932.284823] simplefs is succesfully mounted on [/dev/loop16]\n[41951.102689] No inode found for the filename [hello]\n[41951.102706] No inode found for the filename [hello]\n[41951.102724] No inode found for the filename [hello]\n[41951.102731] New file creation request\n[41951.102986] The new filesize that is written is: [41] and len was: [41]\n[41961.195423] The new filesize that is written is: [12] and len was: [12]\n[41968.055946] No inode found for the filename [dir1]\n[41968.055959] New directory creation request\n[41980.265026] No inode found for the filename [hello]\n[41980.265073] No inode found for the filename [hello]\n[41980.265082] New file creation request\n[41980.265168] The new filesize that is written is: [12] and len was: [12]\n[41991.857978] The new filesize that is written is: [22] and len was: [22]\n[41999.993579] No inode found for the filename [dir2]\n[41999.993592] New directory creation request\n[42005.461745] No inode found for the filename [hello]\n[42005.461756] New file creation request\n[42016.694882] The new filesize that is written is: [23] and len was: [23]\n[42024.480843] simplefs superblock is destroyed. Unmount succesful.\n[42024.485339] Sucessfully unregistered simplefs\n[42031.157983] Sucessfully registered simplefs\n[42031.162331] The magic number obtained in disk is: [268640275]\n[42031.162334] simplefs filesystem of version [1] formatted with a block size of [4096] detected in the device.\n[42031.162360] simplefs is succesfully mounted on [/dev/loop17]\n[42104.389807] simplefs superblock is destroyed. Unmount succesful.\n[42104.395575] Sucessfully unregistered simplefs\nlinux-9dni:/home/psankar/src/simplefs #\n","funding_links":[],"categories":["C","c"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsankar%2Fsimplefs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsankar%2Fsimplefs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsankar%2Fsimplefs/lists"}