BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

操作系统代写 | COMPSCI 340 Operating Systems Assignment 2 – User space file system

操作系统代写 | COMPSCI 340 Operating Systems Assignment 2 – User space file system

本次新西兰代写是操作系统的一个assignment

Introduction

In this assignment you will create an undoable memory based user space file system for a Linux
environment.

Set up

Do the assignment on Ubuntu from flexit.auckland.ac.nz . You can use your own machine (virtual
machines work too, including the Windows subsystem for Linux version 2) but the markers will
run your code on the flexit system and it must work there to get the marks.
You need to have libfuse-dev installed, but it probably already is. The flexit version is already
fine.

The Python interface is called fuse.py and it also may already be installed. It was originally
written for Python 2, but I have successfully used it with Python 3. The code distributed with the
assignment uses Python 3.

You can either use the Python package system called pip3 to install it or fuse.py can be
downloaded from https://github.com/fusepy/fusepy.

To install using pip3:

sudo apt install python3-pip (you don’t need to do this on flexit, in fact you can’t)
pip3 install fusepy

Create a new directory e.g. mkdir A2 . Ensure this is in the Linux area if you are using WSL (i.e.
not in the C drive).

Download the memundo.py file from the assignment page into this directory. This is a very
slightly modified version of the memory.py example in GitHub.

In the same directory create another directory called memdir.

Try this to ensure your environment is set up correctly. The undoshell prompt is expected.
python3 memundo.py
undoshell: ls -al

You should see something like:

total 4
drwxr-xr-x 2 root root 0 Aug 3 11:45 .
drwxrwxr-x 4 robert robert 4096 Aug 3 10:59 ..

As mentioned in class and tutorials this directory is now showing files from the memdir user space
file system.

The working directory for all commands you give at the undoshell prompt is always memdir.

This means that cd does not work (you can examine the code to see why this is the case).
Try the following commands (after running each command you should run ls -al):

touch file1
echo “hello” > hi
cat hi
cat > file1
now just type anything and finish with ctrl-D
cat hi file1 > file2
cat hi >> file2
chmod u-w file2
ln -s hi hisym
cat hisym
rm file1
rm file2
mv hi hi2
cat hisym
cp hi2 hi
cat hisym
mkdir tempdir
rmdir tempdir
quit

Read and understand the memundo.py program. This is really important, you cannot make
changes until you understand what is happening here.

Step 1 [2 marks]

Currently the . directory (i.e. the base directory of the user space file system) has root for the
owner and group. Modify the program to use the current user’s id and the current group.
Also change the size to something more meaningful using sys.getsizeof. This size should
change as the number of files increases and should decrease as the number of files decreases. (See
question 1.)

Ensure that all files, including symbolic links, created in the directory have the correct times and
user and group information.
Hint: os.getuid(), os.getgid()

Step 2 [6 marks]

Add a single step undo command to your file system. If the user types the command undo then
the most recent changes made by another command line command (like those above) in your file
system are undone. That is, the result is as if the last command which changed something didn’t
happen. (Remove the current place holder print statement as well.)

What counts as a change? A modification to the data structures associated with the file system. It
includes actions from the following functions:

create (can be called via touch, echo, cat etc…)
chmod
mkdir (you don’t have to make the directory hold files but this command should work)
rmdir
unlink (rm calls this)
rename (mv calls this)
write
truncate

changed. You must therefore only save the relevant information in your undo state. The markers
will examine your source code for this.

It is possible that a single command could cause more than one state change. The undo should
reverse all of the state changes caused by the command.

Not all commands make changes to the file system. e.g. ls -al, cat file. So if the user creates
a file, lists the directory and then executes undo, the newly created file should disappear.

Step 3 [2 marks]

Add the redo command to your file system. If the user types the command redo the most recent
undo is undone. That is, the result is as if the undo did not happen. (Remove the current place
holder print statement as well.)

N.B. If a change has occurred in the file system since the last undo command was performed the
redo command does nothing and you should report “redo not possible”. Do this even if the
change had nothing to do with the files affected by the last undo command.

bestdaixie

评论已关闭。