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

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

C语言代写 | COMPSCI 340 / SOFTENG 370 Operating Systems

C语言代写 | COMPSCI 340 / SOFTENG 370 Operating Systems

这个作业是用C语言完成操作系统相关的用户文件空间系统
COMPSCI 340 / SOFTENG 370
Operating Systems
Assignment 2 – User space file system

Part 1
Make two directories, one called source and one called mount in the directory. Put some files in
the source directory (download the files one, two, and three from Canvas).
You will need two terminal windows open: one to run the user space file system and display the
work it is doing, and one to work with files from the command line. I will refer to these as terminal
one and terminal two.
In terminal one run the program: python a2fuse1.py source mount
In terminal two do:
ls -l source
ls -l mount
For all the questions put the answers (and requested output) into a file called A2.txt.
Question 1
Explain the output you have just seen in terminal two. What did you see and why was it like that?
[2 marks]
Question 2
For each of the following commands you perform in terminal two, copy the output generated by the
user space file system in terminal one into your answer file and explain each method called. You can
get some information from the Python documentation and more using man.
COMPSCI 340 / SOFTENG 370
Operating Systems
Assignment 2 – User space file system
Worth 10%
Due date: 09:30pm 8th of October 2020
Here is the set of commands to be performed (make sure to be in the
mount directory – perform “cd mount” first):
cat > newfile
hello world
^D (this is control-D)
Example:
DEBUG:fuse.log-mixin:-> getattr /newfile (None,)
DEBUG:fuse.log-mixin:<- getattr {‘st_atime’: 1599037397.463398, ‘st_ctime’:
1599037379.543504, ‘st_gid’: 20, ‘st_mode’: 33188, ‘st_mtime’:
1599037379.543504, ‘st_nlink’: 1, ‘st_size’: 12, ‘st_uid’: 501}
Gets attributes for “newfile”. You can explain what the attributes mean.
[6 marks]
Then shut the user space file system down by moving up a directory (out of the user file system
directory) and executing the command: fusermount -u mount(Ubuntu) or umount mount
(macOS)
Check the contents of the source and mount directories.
Part 2
The Operations class in fuse.py is the one which does the work we are interested in. This is
subclassed in both passthrough.py and memory.py.
As we have seen passthrough.py provides a copy of one directory mounted in a different location
and passes all requests back to the original directory. Whereas memory.py implements an entirely
separate file system in memory. This means when the file system is shut down those files arelost.
Question 3
Answer these questions about memory.py.
For the following list of methods in the Memory class explain exactly what each method does.
Include a statement by statement explanation.
_init__, getattr, readdir
open, create, unlink
write, read
[6 marks]
Example:
Creates an empty dictionary self.files for the files. This will use the path names as the keys.
Each value in the dictionary will be another dictionary.
self.data is a dictionary for the files’ data. The path names are the keys. The values are the data of
that file.
Sets the starting value for the file descriptors, these are going to be used as unique file identifiers.
Grabs the current time and sets the file attributes for the root of this file system. It is a directory,
with creation, modified and accessed times set to now. It has two links.
Part 3
You now have to create your own user space file system. It works a little bit like a combination of
passthrough.py and memory.py. Call your program a2fuse2.py. You can subclass
Passthrough or Memory if you want. You will probably have to implement at least the same
methods you described in Question 3 to enable the following command.
Run your program with python a2fuse2.py source1 source2 mount
Settings: Create two source directories, source1 and source2. Put file one in source1, and put
file two in source2 respectively. Make sure that mount is initially empty. The file system works
very much like memory.py but it starts with some real files from the source1 and source2
directories. So, the file system has two classes of files which are in the mount directory. One consists
of real files from the source1 and source2 directories and the other of files which only exist in
memory. Specifically, create your FUSE to meet the following two requirements.
Requirement 1: Enable your FUSE to mount two source directories into a mount point.
Requirement 2: Any changes which happen to files in the mount directory which have been created
only in memory (including creating or deleting files or writing to files) only happen in the mount
directory. However, if the file was initially in the source1 and source2 directories then changes
get passed back to that directory just as with passthrough.py.
Example:
Start your FUSE in terminal one: python a2fuse2.py source1 source2 mount
Start in the same directory in terminal two.
(base) ubuntu@q2b:~/part3$ ls -l source1
total 4
-rw-r–r– 1 ubuntu ubuntu 5 Sep 2 05:12 one
(base) ubuntu@q2b:~/part3$ ls -l source2
total 4
-rw-r–r– 1 ubuntu ubuntu 10 Sep 2 05:12 two
(base) ubuntu@q2b:~/part3$ cd mount/
(base) ubuntu@q2b:~/part3/mount$ ls -l
total 0
-rw-r–r– 1 ubuntu ubuntu 5 Sep 2 05:12 one
-rw-r–r– 1 ubuntu ubuntu 10 Sep 2 05:12 two
(base) ubuntu@q2b:~/part3/mount$ cat one two > three
(base) ubuntu@q2b:~/part3/mount$ ls -l
total 0
-rw-rw-r– 1 ubuntu ubuntu 15 Sep 2 05:16 three
-rw-r–r– 1 ubuntu ubuntu 5 Sep 2 05:12 one
-rw-r–r– 1 ubuntu ubuntu 10 Sep 2 05:12 two
(base) ubuntu@q2b:~/part3/mount$ ls -l ../source1
total 4
-rw-r–r– 1 ubuntu ubuntu 5 Sep 2 05:12 one
(base) ubuntu@q2b:~/part3/mount$ ls -l ../source2
total 4
-rw-r–r– 1 ubuntu ubuntu 10 Sep 2 05:12 two
(base) ubuntu@q2b:~/part3/mount$ rm three
(base) ubuntu@q2b:~/part3/mount$ ls -l
total 0
-rw-r–r– 1 ubuntu ubuntu 5 Sep 2 05:12 one
-rw-r–r– 1 ubuntu ubuntu 10 Sep 2 05:12 two

bestdaixie