A Unix-like file system implementation in C++ featuring inode-based storage, Unix permissions, symbolic/hard links, and hierarchical directories.
- Inode-based storage with direct and indirect block pointers
- Hierarchical directories with nested path support
- Disk emulator for block-level I/O simulation
- Format and mount operations
- Password protection with SHA-256 hashing
- Multi-user ready architecture
- Permission checking framework
- Symbolic links support
- Hard links with reference counting
- File metadata (timestamps, types)
- Comprehensive error handling
make./bin/sfssh data/disk.img 200sfs> format # Format disk
sfs> mount # Mount filesystem
sfs> mkdir docs # Create directory
sfs> touch file.txt # Create file
sfs> ls # List contents
sfs> stat # Show statistics
sfs> exit # Unmount and exitBlock 0: Superblock (metadata)
Block 1-N: Inodes (file metadata)
Block N+1 onwards: Data blocks
- File size
- Direct pointers [5]
- Indirect pointer (→ 1024 blocks)
- Permissions flags
- Timestamps
- Link count
- Entries with inode numbers
- "." and ".." entries
- Hierarchical navigation
include/sfs/disk.h- Disk emulator interfaceinclude/sfs/fs.h- File system interfacesrc/library/disk.cpp- Block I/O implementationsrc/library/fs_layer_1.cpp- Inode managementsrc/library/fs_layer_2.cpp- File/directory operationssrc/shell/sfssh.cpp- Interactive shell
- Inode: File metadata and block pointers
- SuperBlock: FS configuration
- Directory Entry: Name → inode mapping
- Block: 4KB units of storage
- Block size: 4096 bytes
- Inodes per block: 128
- Max filename: 16 characters
- Direct pointers: 5
- Indirect capacity: 1024 blocks
- Max file size: ~4 MB
- Inode allocation: 10% of disk
This project demonstrates:
- OS Concepts: File systems, I/O, block management
- Data Structures: Trees (directories), bitmaps (free blocks)
- Algorithms: Block allocation, path resolution
- C++ Skills: Memory management, OOP, system calls
- Unix Fundamentals: Permissions, links, hierarchies
cd tests
./test_format.sh
./test_create.sh
./test_copyin.sh
./test_copyout.sh$ ./bin/sfssh data/test.img 100
sfs> format
Formatting disk with 100 blocks...
Format complete.
sfs> mount
File system mounted successfully.
sfs> mkdir projects
sfs> cd projects
sfs> touch README.md
sfs> ls
[DIR] .
[DIR] ..
[FILE] README.md
sfs> stat README.md
File: README.md
Type: Regular file
Size: 0 bytes
Inode: 1
sfs> exit
File system unmounted.sfs> mount
sfs> password set
Enter new password: ****
Password set successfully.
sfs> exit
# Restart
sfs> mount
Enter password: ****
File system mounted successfully.# Copy local file into FS
sfs> copyin ~/documents/essay.txt essay.txt
Copied 2048 bytes.
# Copy FS file out
sfs> copyout essay.txt ~/backup/essay_backup.txt
Copied 2048 bytes.- Direct pointers for small files (<20KB)
- Indirect pointer for large files (up to 4MB)
- Free block bitmap for O(1) allocation search
- SHA-256 password hashing
- Password protection on mount
- Permission checking framework ready
- Magic number validation
- Integrity checking on mount
- Graceful error handling
For any feedback: contact: GitHub: nobitanobi22
#MIS SECTION
After building this project, I was able to learn about these:
- How file systems organize data on disk
- The role of inodes in Unix filesystems
- Block allocation strategies
- Directory implementation
- File system mount/unmount process
- Basic security mechanisms
This project was created to demonstrate a deep understanding of operating system fundamentals and low-level systems programming.