+
Skip to content
/ FS Public

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.

Notifications You must be signed in to change notification settings

aminehabchi/FS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Learning Filesystem Project

Overview

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.


Features

The project supports the following operations:

  1. Filesystem Initialization
    Load an existing disk image or create a new one, along with superblock, inode bitmap, block bitmap, and inode table.

  2. File Management

    • Create a new file with content
    • Read file content
    • Update file content
    • Delete a file
  3. Listing Files
    List all files stored on the filesystem along with their content.


Project Structure

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.

Example Usage

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(())
}

What I Learned

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.

Future Improvements

  • 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.

Conclusion

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.

About

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.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载