Skip to content

nobitanobi22/basic-file-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleFS - Enhanced Unix-like File System

A Unix-like file system implementation in C++ featuring inode-based storage, Unix permissions, symbolic/hard links, and hierarchical directories.

1. Features

Core File System

  • 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

Security & Permissions

  • Password protection with SHA-256 hashing
  • Multi-user ready architecture
  • Permission checking framework

Advanced Features

  • Symbolic links support
  • Hard links with reference counting
  • File metadata (timestamps, types)
  • Comprehensive error handling

2. Quick Start

Build

make

Run

./bin/sfssh data/disk.img 200

Basic Commands

sfs> 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 exit

3. Architecture

Block 0: Superblock (metadata)
Block 1-N: Inodes (file metadata)  
Block N+1 onwards: Data blocks

Inode Structure

  • File size
  • Direct pointers [5]
  • Indirect pointer (→ 1024 blocks)
  • Permissions flags
  • Timestamps
  • Link count

Directory Structure

  • Entries with inode numbers
  • "." and ".." entries
  • Hierarchical navigation

4. Implementation

Key Files

  • include/sfs/disk.h - Disk emulator interface
  • include/sfs/fs.h - File system interface
  • src/library/disk.cpp - Block I/O implementation
  • src/library/fs_layer_1.cpp - Inode management
  • src/library/fs_layer_2.cpp - File/directory operations
  • src/shell/sfssh.cpp - Interactive shell

Data Structures

  • Inode: File metadata and block pointers
  • SuperBlock: FS configuration
  • Directory Entry: Name → inode mapping
  • Block: 4KB units of storage

5. Specifications

  • 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

6. Concepts Used

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

7. Testing

cd tests
./test_format.sh
./test_create.sh
./test_copyin.sh
./test_copyout.sh

8. Example Session

$ ./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.

9. Advanced Usage: Password Protection

Password Protection

sfs> mount
sfs> password set
Enter new password: ****
Password set successfully.

sfs> exit
# Restart

sfs> mount  
Enter password: ****
File system mounted successfully.

File Operations

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

10. main Technical Highlights

Efficient Storage

  • Direct pointers for small files (<20KB)
  • Indirect pointer for large files (up to 4MB)
  • Free block bitmap for O(1) allocation search

Security

  • SHA-256 password hashing
  • Password protection on mount
  • Permission checking framework ready

Reliability

  • Magic number validation
  • Integrity checking on mount
  • Graceful error handling

For any feedback: contact: GitHub: nobitanobi22

#MIS SECTION

A. Learning Outcomes

After building this project, I was able to learn about these:

  1. How file systems organize data on disk
  2. The role of inodes in Unix filesystems
  3. Block allocation strategies
  4. Directory implementation
  5. File system mount/unmount process
  6. Basic security mechanisms

B. Author Note

This project was created to demonstrate a deep understanding of operating system fundamentals and low-level systems programming.

About

This repository is based on implementation of core concepts learnt in operating system fundamentals and low-level systems programming!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors