Skip to content

Latest commit

 

History

49 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Filesystem

For this project I teamed up with three classmates to write a user space portable index-allocated file system. Our program provides users with 226 bytes of drive space in a disk image. Users will have the ability to create the filesystem image, list the files currently in the file system, add files, remove files, and save the filesystem. Files will persist in the file system image when the program exits.

What I Learned

C memory management concepts
Filesystems structure and functionality
Disk Images
XOR Cypher Encryption

Usage

The code will be compiled with:

gcc -Wall -Werror --std=c99 <filename>

The program prints out a prompt of mfs> when it is ready to accept input.

Command Usage Description
insert insert <filename> Copy the file into the filesystem image
retrieve retrieve <filename> Retrieve the file from the filesystem image and place it in the current working directory
retrieve retrieve <filename> <newfilename> Retrieve the file from the filesystem image and place it in the current working directory using the new filename
read read <filename> <starting byte> <number of bytes> Print <number of bytes> bytes from the file, in hexadecimal, starting at <starting byte>
delete delete <filename> Delete the file from the filesystem image
undel undelete <filename> Undelete the file from the filesystem image
list list [-h] [-a] List the files in the filesystem image. If the -h parameter is given it will also list hidden files. If the -a parameter is provided the attributes will also be listed with the file and displayed as an 8-bit binary value.
df df Display the amount of disk space left in the filesystem image
open open <filename> Open a filesystem image
close close Close the opened filesystem image
createfs createfs <filename> Creates a new filesystem image
savefs savefs Write the currently opened filesystem to its file
attrib attrib [+attribute] [-attribute] <filename> Set or remove the attribute for the file
encrypt encrypt <filename> <cipher> XOR encrypt the file using the given cipher. The cipher is limited to a 1-byte value
decrypt encrypt <filename> <cipher> XOR decrypt the file using the given cipher. The cipher is limited to a 1-byte value
quit quit Quit the application

Command Details

insert

insert allows the user to put a new file into the file system.

The command takes the form:

insert <filename>

If the filename is too long an error will be returned stating:

insert error: File name too long.

If there is not enough disk space for the file an error will be returned stating:

insert error: Not enough disk space.

retrieve

The retrieve command allows the user to retrieve a file from the file system and place it in the current working directory.

The command shall take the form:

retrieve <filename>

and

retrieve <filename> <newfilename>

If no new filename is specified the retrieve command copies the file to the current working directory using the old filename.

If the file does not exist in the file system an error will be printed that states:

Error: File not found.

delete command

The delete command allows the user to delete a file from the file system

If the file does exist in the file system it shall be deleted and all the space available for additional files.

undelete command

The undelete command allows the user to undelete a file that has been deleted from the file system

If the file does exist in the file system directory and marked deleted it will be undeleted.

If the file is not found in the directory then the following shall be printed:

undelete: Can not find the file.

list command

The list command displays all the files in the file system, their size in bytes and the time they were added to the file system

If no files are in the file system a message shall be printed: list: No files found.

Files that are marked as hidden are not listed

df command

The df command displays the amount of free space in the file system in bytes.

open command

The open command opens a file system image file with the name and path given by the user.

If the file is not found a message will be printed:

open: File not found

close command

The close command closes a file system image file with the name and path given by the user.

If the file is not open a message will be printed:

close: File not open

savefs command

The savefs command writes the file system to disk.

attrib command

The attrib command sets or removes an attribute from the file.

Valid attributes are:

Attribute Description
h Hidden. The file does not display in the directory listing
r Read-Only. The file is marked read-only and can not be deleted.

To set the attribute on the file the attribute tag is given with a +, ex:

mfs> attrib +h foo.txt

To remove the attribute on the file the attribute tag is given with a -, ex:

mfs> attrib -h foo.txt

If the file is not found a message will be printed:

attrib: File not found

createfs command

createfs command

createfs creates a file system image file with the named provided by the user.

If the file name is not provided a message will be printed:

createfs: Filename not provided

encrypt command

The encrypt command allows the user to encrypt a file in the file system using the provided cipher. This is a simple byte-by-byte XOR cipher.

The command shall take the form:

encrypt <filename> <cipher>

The cipher is required to be 256 bits.

decrypt command

The decrypt command allows the user to decrypt a file in the file system using the provided cipher. This is a simple byte-by-byte XOR cipher.

The command shall take the form:

decrypt <filename> <cipher>

The cipher is required to be 256 bits.

About

User space portable index-allocated file system.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages