This project is a C implementation of an in-memory filesystem that emulates the core concepts of a traditional Linux filesystem. It demonstrates the use of fundamental data structures like inodes and directory entries to manage a hierarchical structure of files and directories, all handled dynamically in memory.
The emulator is built around two primary data structures:
-
inode: A structure that serves as the metadata container for every file and directory. It stores essential information such as file type (regular file or directory), permissions, size, and pointers to the data blocks that hold the actual content. -
Directory Entry: A structure that links human-readable filenames to their correspondinginodenumbers, forming the directory hierarchy.
All filesystem components are allocated dynamically on the heap, and their relationships are managed through pointers.
The project implements a suite of standard filesystem operations, providing a functional command-line interface to interact with the in-memory structure:
-
File & Directory Creation (
touch,mkdir): Dynamically allocates a newinodeand links it into the parent directory's data blocks. For directories, it correctly initializes the.and..entries to maintain the hierarchical structure. -
Directory Listing (
ls): Traverses a directory's linked list of data blocks, reading each directory entry to display the names of its contents. -
File & Directory Removal (
rm,rmdir): Deallocates all data blocks associated with aninode, frees theinodeitself, and removes its entry from the parent directory, ensuring no memory leaks. -
File Content Operations (
write,read): Simulates writing to and reading from files by managing and accessing the content stored in the associated data blocks.
This project showcases a deep understanding of C-based memory management, data structure design, and the foundational principles of filesystem architecture.