A complete implementation of a simple, Unix-like file system on a simulated disk.
mkdir <directory>- Create empty subdirectoryls- List directory contents (directories show with/)cd <directory>- Change to specified subdirectoryhome- Switch to root directoryrmdir <directory>- Remove empty subdirectorycreate <filename>- Create empty fileappend <filename> <data>- Append data to filestat <name>- Display file/directory statisticscat <filename>- Print file contentstail <filename> <n>- Print last n bytes of filerm <filename>- Remove file
- Multi-block file support - Files can span multiple 128-byte blocks
- Smart block allocation - Fills last block before allocating new ones
- Data persistence - File system state persists across sessions
- Comprehensive error handling - All required error messages implemented
- Efficient resource management - Proper cleanup and block reclamation
The project follows a layered architecture:
Shell (CLI) β FileSys (Commands) β BasicFileSys (Low-level) β Disk (Storage)
- Block Size: 128 bytes
- Total Blocks: 1,024 (0-1023)
- Block Types:
- Block 0: Superblock (bitmap)
- Block 1: Root directory
- Other blocks: Dynamic allocation
- Directory Block: Magic number + entry count + name/block pairs
- Inode Block: Magic number + file size + data block pointers
- Data Block: Raw file data (128 bytes)
- Compiler: C++ compatible compiler (g++, clang++)
- Make: GNU Make
- Platform: Linux/Unix
git clone https://github.com/Shan533/C-File-System.git
cd C-File-Systemcd "file system skeleton code"make# Interactive mode
./filesys
# Script mode
./filesys -s test_script.txt# Create and navigate directories
mkdir testdir
cd testdir
ls
home
# Create and manipulate files
create myfile
append myfile "Hello, World!"
cat myfile
stat myfile
tail myfile 5
# Clean up
rm myfile
cd ..
rmdir testdir# Create a large file that spans multiple blocks
create bigfile
append bigfile "This is a long string that will exceed 128 bytes and require multiple blocks to store properly in our file system implementation."
stat bigfile
cat bigfileThe project includes comprehensive test scripts:
test_script.txt- Basic functionality testtest_large_files.txt- Multi-block file testingtest_edge_cases.txt- Edge case testingtest_persistence1.txt- Persistence testingtest_newline.txt- Special character handling
# Run basic test
./filesys -s test_script.txt
# Run large file test
./filesys -s test_large_files.txt
# Run edge case test
./filesys -s test_edge_cases.txt