This project implements a simple file system emulator in C. The system simulates a disk using fixed-size memory blocks and supports basic file system operations such as creating, deleting, opening, closing, reading, writing, seeking, and listing files.
An interactive shell reads commands from standard input and prints results to standard output according to the provided command language specification.
main.c– program entry pointfs.c / fs.h– file system implementationdisk.c / disk.h– emulated disk and block I/Outil.c / util.h– helper functionsMakefile– build instructions
From the project root directory, run:
makeThis produces an executable named fs.
Run the program by redirecting input from a command file or by typing commands manually:
./fs < input.txtExample:
./fs < FS-input-sample-1.txtThe program reads commands from standard input and writes all output to standard output.
- The
incommand reinitializes the entire file system to its original state. - The program does not print prompts.
- Output formatting exactly follows the project specification.
- Input files should use Unix line endings (
\n). If needed, convert Windows files using:dos2unix input.txt
The shell supports the following commands:
in– initialize the systemcr <name>– create filede <name>– destroy fileop <name>– open filecl <index>– close filerd <index> <mem> <count>– read from filewr <index> <mem> <count>– write to filesk <index> <pos>– seekdr– list directorywm <mem> <str>– write to memoryrm <mem> <count>– read from memory
If a command fails, the program outputs:
error