Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

File System Simulation

This project is a C program that simulates basic file system functionality. It covers the basic features of a real file system and demonstrates how file operations work.

✨ Features

  • Creating, deleting, reading, and writing files
  • Renaming and moving files
  • Copying and comparing files
  • Disk defragmentation
  • Integrity checking
  • Backup and restore
  • Log system

🛠 Requirements

  • GCC compiler
  • Make
  • POSIX-compliant operating system (Linux, macOS, WSL)

Usage

To run the program: You can go to the project file location in the terminal, compile the program with the make command, and run it directly.

  • Creating a file:

App Demo

  • List of files:

App Demo

  • Append some data to file and print the content:

App Demo

  • Truncate the file, read data between two offsets:

App Demo

Basic Commands

  • fs_init(): Initializes the file system
  • fs_format(): Formats the disk
  • fs_create(filename): Creates a new file
  • fs_delete(filename): Deletes a file
  • fs_write(filename, data, size): Writes data to a file
  • fs_read(filename, offset, size, buffer): Reads data from a file
  • fs_append(filename, data, size): Appends data to a file
  • fs_rename(old_name, new_name): Renames a file
  • fs_copy(src, dest): Copies a file
  • fs_mv(old_name, new_name): Moves a file
  • fs_ls(): Displays the file list
  • fs_cat(filename): File contents Displays
  • fs_diff(file1, file2): Compares files
  • fs_defragment(): Defragments the disk
  • fs_check_integrity(): Checks integrity
  • fs_backup(backup_filename): Makes a backup
  • fs_restore(backup_filename): Restores from a backup

Project Structure

📁 BasicFileSystem/
├── 📂 assets/
│
├── 📂 include/
│ └── 📄 fs.h # Header file
│
├── 📂 src/
│ ├── 📄 main.c # Main program
│ └── 📄 fs.c # File system implementation
│
├── 📂 lib/ # Compiled .o files
├── 📂 bin/ # Executable file
├── 📄 Makefile # Build configuration
└── 📄 README.md # Project documentation

Error Management

The program checks and manages the following error conditions:

  • File not found
  • Insufficient disk space
  • Invalid file operations
  • Disk integrity errors
  • Out of memory

Log System

All transactions are recorded in the log.txt file. This file will be created automatically. Log records include:

  • Transaction time
  • Transaction type
  • Transaction result
  • Error messages

🤝 Contributing

Feel free to fork the repo, make improvements, fix bugs and submit pull requests. 🎉

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages