How waseque199/minivsfs-image-generator-using-c works
Project Type and Purpose
• This is a pair of command-line tools (mkfs_builder and mkfs_adder) written in C that implement a minimal filesystem (MiniVSFS) inside a raw disk image.
• mkfs_builder initializes an empty MiniVSFS image. mkfs_adder injects user files into an existing image.
File Structure
• Top-level files:
• mkfs_builder.c: CLI tool to build a new image
• mkfs_adder.c: CLI tool to add files to an image
• Base Files/: sample text files used for testing
• README.md: project description, data-layout, usage, algorithms
• No separate frontend/backend; it’s a self-contained, procedural C application.
Main Components
• User / Shell (invokes the CLI with flags and parameters)
• mkfs_builder (binary)
• Command-line Parser
• Superblock Initializer
• Bitmap Initializer (inode/data bitmaps)
• Inode Table Creator
• Root Directory Creator
• CRC32 Checksum Module
• Block Writer (writes raw blocks to the image file)
• mkfs_adder (binary)
• Command-line Parser
• Image Reader (reads Superblock + Bitmaps + Inodes)
• Allocation Manager (first-fit on bitmaps)
• Inode Updater
• Directory Entry Manager
• Data Writer (writes file data, block padding)
• Checksum Updater (CRC32 & XOR for dir entries)
• Disk Image File (filesystem.img, test.img, updated.img)
• Superblock (1 block)
• Inode Bitmap (1 block)
• Data Bitmap (1 block)
• Inode Table (N blocks)
• Data Region (M blocks)
• Host Filesystem (where the raw image and source files reside)
Relationships and Data Flow
• mkfs_builder
→ initializes each on-disk structure in order (SB → inode bitmap → data bitmap → inode table → data region)
→ writes to Disk Image File
• mkfs_adder
→ reads Disk Image File structures (SB, bitmaps, inode table)
→ finds free inode & blocks via Allocation Manager
→ writes file data into Data Region
→ updates Bitmaps & Inode Table & Directory Entries
→ recalculates and writes checksums
→ writes out updated Disk Image File
• The Disk Image File is the persistent component shared by both tools.
Architectural Patterns and Design Principles
• Procedural, module-based C code (each major responsibility lives in its own function set)
• Data laid out in fixed-offset, packed binary structures for portability
• First-fit allocation algorithm for bitmaps
• Single root directory (flat namespace)
• Checksum validation for safety (CRC32 for metadata, XOR for directory entries)
Relevant Technologies & Libraries
• C standard library (fopen/fread/fwrite, argc/argv parsing)
• CRC32 implementation (e.g. zlib or custom algorithm)
• POSIX-style file I/O
• #pragma pack for strict on-disk layouts
• hexdump/xxd for debugging