MemFS is an in-memory file system implemented in C++. It provides a lightweight, thread-safe solution for file storage and manipulation, entirely residing in memory. MemFS supports basic file operations such as:
- Create: Add new files to the memory file system.
- Write: Append content to existing files.
- Read: Retrieve the content of a file.
- Delete: Remove files from the file system.
- List (ls): Display metadata about files, including their size and timestamps.
Please refer to Design Doc & Report
- Thread-Safe Operations: Supports concurrent execution using a thread pool.
- Asynchronous Task Queue: Manages tasks with synchronization and batch processing.
- File Metadata: Tracks creation and modification timestamps for files.
- File Size Limitation: Enforces a maximum file size of 2048 bytes to ensure controlled memory usage.
The project is divided into two parts:
- Core Functionality: Demonstration of MemFS features.
- Benchmarking: Performance evaluation of MemFS.
src
├── CommandInterpreter.hpp #Header file for interpreting and executing commands in the MemFS system
├── MemFS.hpp # Header file defining the MemFS class and core file system logic
├── benchmark.cpp # Benchmarking program to evaluate MemFS performance under various workloads
└── main.cpp # Main Program to run CLI
The following make commands are available:
-
make run: Compiles and runs the CLI program- Compiles
src/main.cppwith C++11 standard - Executes the resulting binary
- Compiles
-
make benchmark: Compiles and runs the benchmark program (generates benchmark.txt)- Compiles
src/benchmark.cppwith C++11 standard - Executes the resulting benchmark binary
- Compiles
-
make prune: Cleans up compiled binaries- Removes the main executable and benchmark executable
The Command Line Interface (CLI) for MemFS provides a set of commands to interact with the in-memory file system. Below is a description of the available commands:
-
Create a single file
create <filename>Creates a new file with the specified filename. -
Create multiple files
create -n <count> <filenames...>Creates multiple files. Replace<count>with the number of files and provide<filenames>separated by spaces.
-
Write to a single file ```write ""`` Writes the specified content to a file. Enclose the content in quotes (
"). -
Write to multiple files
write -n <count> <filename> "<content>" ...Writes content to multiple files. Replace<count>with the number of filename/content pairs, and provide them as space-separated values.
- Read a file
read <filename>Displays the content of the specified file.
-
Delete a single file
delete <filename>Deletes the specified file. -
Delete multiple files
delete -n <count> <filenames...>Deletes multiple files. Replace<count>with the number of files and provide<filenames>separated by spaces.
-
List all files
lsLists all files in the directory. -
List files with details
ls -lLists all files with additional details such as file size, creation time, and last modified time.
-
Show Help Menu
helpDisplays the help menu with available commands. -
Clear the Screen
clearClears the terminal screen. -
Exit the Program
exitTerminates the CLI application.
- Create a single file:
create myfile.txt - Create multiple files:
create -n 3 file1.txt file2.txt file3.txt - Write to a file:
write myfile.txt "Hello" - Read a file:
read myfile.txt - List files with details:
ls -l - Delete multiple files:
delete -n 2 file1.txt file2.txt
