This is a learning project where I implemented a simple filesystem in Rust. The goal of this project was to understand how filesystems work at a low level and how to manage files, inodes, and blocks programmatically.
The project demonstrates fundamental concepts of a filesystem including:
- Disk management
- Superblock, inodes, and inode tables
- Block allocation and bitmaps
- File creation, reading, updating, and deletion
This project is not intended for production. It is purely educational to practice Rust, filesystem concepts, and low-level file management.
The project supports the following operations:
-
Filesystem Initialization
Load an existing disk image or create a new one, along with superblock, inode bitmap, block bitmap, and inode table. -
File Management
- Create a new file with content
- Read file content
- Update file content
- Delete a file
-
Listing Files
List all files stored on the filesystem along with their content.
src/
├─ blocks/ # Contains disk, inode, inode table, block bitmap, and superblock logic
├─ file/ # File struct with methods for create, read, update, delete
├─ fs/ # Main filesystem struct FS
└─ main.rs # Demo of filesystem operations
Disk
– handles low-level reading/writing of blocks to a disk image.Super
– contains superblock information.InodeTable
– stores metadata of files (name, size, block location).InodeBitmap
&BlockBitmap
– manage free/used inodes and blocks.File
– provides an interface to manipulate files.FS
– main filesystem interface coordinating all components.
fn main() -> std::io::Result<()> {
let mut fs = FS::new()?;
// List initial files
let files = fs.list_files();
// Create a new file
let mut file1 = File::create(fs.clone(), "file1.txt", "Hello World").unwrap();
// Read content
println!("File content: {}", file1.get().unwrap());
// Update content
file1.set("Updated content!")?;
// Delete file
file1.delete();
Ok(())
}
During this project, I learned:
- How to work with Rust structs, cloning, and ownership in a complex system.
- How filesystems manage inodes, blocks, and bitmaps.
- Reading and writing binary data to simulate disk storage.
- Implementing CRUD operations at a low level.
- Handling errors and rollback operations to maintain filesystem integrity.
- Support multi-block files for larger content.
- Implement directories and file paths.
- Add persistence and journaling for crash safety.
- Implement more advanced filesystem operations like moving or copying files.
This project was a hands-on learning experience to understand both Rust programming and filesystem internals. It’s a foundation for more advanced projects in storage systems, operating systems, and low-level programming.