This project is a custom-built file system implemented in C, designed to simulate core operating system–level file management functionality. The system operates on a virtual volume file and implements low-level block-based storage using Logical Block Addressing (LBA).
The file system supports directory structures, file operations, free space management, buffering, and persistent storage — all built from scratch in a Linux environment.
- Block-based storage abstraction
- Custom free space allocation and release management
- Directory hierarchy management
- Persistent file metadata tracking
- Buffered read/write operations
- Emulation of Unix-like file and directory interfaces
- Volume size: configurable (500,000 – 10,000,000 bytes)
- Block size: 512 bytes per sector
- LBA-based read/write operations
- Persistent storage maintained within a virtual volume file
Low-level I/O operations are handled through:
uint64_t LBAwrite (void * buffer, uint64_t lbaCount, uint64_t lbaPosition);
uint64_t LBAread (void * buffer, uint64_t lbaCount, uint64_t lbaPosition);These functions operate directly on block-level storage, requiring explicit buffer management and block calculations.
- Tracks available and allocated blocks
- Handles allocation during file creation and write operations
- Releases space during file deletion
- Ensures consistency between directory entries and storage layout
- Hierarchical directory structure
- Root directory initialization during volume formatting
- Custom directory entry tracking
- Support for directory iteration and traversal
Supported directory interfaces:
int fs_mkdir(const char *pathname, mode_t mode);
int fs_rmdir(const char *pathname);
fdDir * fs_opendir(const char *pathname);
struct fs_diriteminfo *fs_readdir(fdDir *dirp);
int fs_closedir(fdDir *dirp);
char * fs_getcwd(char *pathbuffer, size_t size);
int fs_setcwd(char * pathname);
int fs_isFile(char * filename);
int fs_isDir(char * pathname);
int fs_delete(char* filename);The system implements custom file descriptors and file positioning logic.
b_io_fd b_open (char * filename, int flags);
int b_read (b_io_fd fd, char * buffer, int count);
int b_write (b_io_fd fd, char * buffer, int count);
int b_seek (b_io_fd fd, off_t offset, int whence);
int b_close (b_io_fd fd);Supported flags:
O_CREATO_TRUNCO_APPENDO_RDONLYO_WRONLYO_RDWR
File metadata includes size tracking, block allocation mapping, and timestamp management.
int fs_stat(const char *filename, struct fs_stat *buf);Tracked attributes include:
- File size (bytes)
- Block size
- Allocated blocks
- Access time
- Modification time
- Creation time
A custom interactive shell (fsshell.c) is included to demonstrate file system functionality.
Supported commands:
ls— List directory contentscp— Copy files within the file systemmv— Move filesmd— Create directoryrm— Remove file or directorytouch— Create filecat— Display file contentscp2l— Copy from custom file system to Linux file systemcp2fs— Copy from Linux file system into custom file systemcd— Change directorypwd— Print working directoryhistory— Show command history
This project is built using make.
makeTo run the interactive shell:
make runThe system must be executed in a Linux environment.
- Designing block allocation without fragmentation corruption
- Mapping file logical offsets to physical LBA blocks
- Maintaining directory consistency during file deletion
- Managing file seek operations with custom descriptors
- Implementing buffered read/write logic over raw block storage
- Handling persistent metadata updates safely
- Low-level systems programming in C
- File system architecture design
- Block-level storage abstraction
- Manual memory management
- OS-style file and directory interfaces
- Persistent data structure design
- Multi-phase systems implementation
- Journaling for crash recovery
- Defragmentation logic
- Permission management system
- Indirect block expansion
- Improved caching strategy
- Performance benchmarking
- Language: C
- Platform: Ubuntu Linux
- Block size: 512 bytes
- Volume size: configurable up to 10MB