Skip to content

IxaKylin/spfs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPFS - A simple filesystem for Linux

The goal of SPFS is to help people understand how to develop a kernel-based filesystem for Linux. It will be used as a teaching aid in a future open-source book on Linux filesystems and as the basis for an Udemy course on Linux filesystem development.

About SPFS

Here are the main characteristics of SPFS:

  • Multi-level directories (directories within directories)
  • Fixed block size (2048 bytes).
  • Maximum filename length up to 28 characters.
  • 760 blocks within the whole filesystem.
  • A maximum file size of approximately 505 KB.
  • A mkfs command to create the filesystem and a fillfs command to create more files than the basic mkfs does. This allows development of "read" operations before having to deal with operations that require creating strucutres on disk.
  • File undelete using the SPFS fsdb command.
  • File creation, deletion, rename, symlinks, ...

Most of these limitations are in place to keep the on-disk structures very simple which result in the code to access them being much easier to understand. The goal here is for teaching only.

The filesystem will be updated once a year for new versions of Ubuntu (April releases) and bug fixes will only be applied to the current release.

SPFS Disk Layout

Here is the disk layout. It's very restrictive. The superblock uses all of block 0 (2048 bytes) so the arrays for free inodes (s_inode) and data blocks (s_block) are fixed. This is what gives SPFS its fixed limitations.

disk-layout

To make SPFS more flexible, it would make the on-disk structures more complicated and since it's just for teaching purposes, simple wins.

Building SPFS

A top-level Makefile has been added to simplify building of the user-space tools and the per-Ubuntu-version kernel modules.

  • make or make common — build the command-line tools and tests into common/bin.
  • make modules-22.10 / make modules-23.04 / make modules-24.04 — build kernel module using ubuntu/<version>/kern/Makefile.
  • make modules KVER=22.10 — build the kernel module for the specified KVER.
  • make modules-all — build all supported Ubuntu kernel module versions.
  • make install-modules-22.10 — run modules_install for that version (may require root).
  • make clean — remove common/bin and run clean in each ubuntu/*/kern directory.

Notes:

  • Kernel module builds use the per-version kernel Makefile under ubuntu/<version>/kern and require appropriate kernel headers for the host kernel.
  • Building kernel modules usually requires root privileges for installation; building (make modules-<ver>) does not require root.
  • A new template ubuntu/24.04-external is available as an example that prefers an external kernel source. See ubuntu/24.04-external/README.md for usage and a helper script to create a linux-src symlink.

Examples:

make
make modules-22.10
make modules KVER=24.04

About

A simple kernel-based filesystem for Linux which is used as a base for an Udemy course on Linux filesystems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C 97.5%
  • Makefile 2.5%