Skip to content

Bennyluwho/File-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple File System Emulator

Overview

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.


Files

  • main.c – program entry point
  • fs.c / fs.h – file system implementation
  • disk.c / disk.h – emulated disk and block I/O
  • util.c / util.h – helper functions
  • Makefile – build instructions

How to Compile

From the project root directory, run:

make

This produces an executable named fs.


How to Run

Run the program by redirecting input from a command file or by typing commands manually:

./fs < input.txt

Example:

./fs < FS-input-sample-1.txt

The program reads commands from standard input and writes all output to standard output.


Notes

  • The in command 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

Supported Commands

The shell supports the following commands:

  • in – initialize the system
  • cr <name> – create file
  • de <name> – destroy file
  • op <name> – open file
  • cl <index> – close file
  • rd <index> <mem> <count> – read from file
  • wr <index> <mem> <count> – write to file
  • sk <index> <pos> – seek
  • dr – list directory
  • wm <mem> <str> – write to memory
  • rm <mem> <count> – read from memory

If a command fails, the program outputs:

error

About

Holder for my 143b project 1 assignmnet.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors