首页 > 其他分享 >COMPSCI 340  Operating System

COMPSCI 340  Operating System

时间:2024-09-22 20:37:35浏览次数:8  
标签:version mount will fileA COMPSCI 340 file directory Operating

COMPSCI 340 S2 2024

Assignment 2

15% of your gradeDue date: 11:59 pm Friday 20th  SeptemberTotal – 15 marks

Introduction

This assignment is divided into three parts:

1.   The first part of this assignment serves as an introduction to user space file systems. You basically follow this as a tutorial.

2.   Implement a user space file system that automatically maintains multiple versions of files.

3.   Implement a set of tools that allow users to interact with the versioning file system.

Part 1 - Getting Started

This assignment is to be done on a Unix based operating system. We recommend the

flexit.auckland.ac.nz Ubuntu image (called Ubuntu 20.04). Markers will use the Ubuntu image provided on flexit.auckland.ac.nz. So please ensure that your submitted programs run in that   environment. FlexIt Ubuntu 20.04 is using python 3.

Download the files fuse.py and versionfs.py from the Assignment 2 page of Canvas into a directory.

fuse.py originally came fromhttps://github.com/fusepy/fusepy

versionfs.py is based on passthrough.py fromhttps://github.com/skorokithakis/python- fuse-sample

You need to install the fusepy library first - pip install fusepy

Next, 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, create a directory called mount (mkdir mount). Then run the program:

python versionfs.py mount

This should cause the creation of another directory called .versiondir. Because this directory name starts with a " ." it is invisible in the default working of the ls command; to view the directory you need to use "ls -a".

Any files you create in the mount directory will really be created in the .versiondir directory. Also, the versionfs.py program will show what is happening to files as you create them and use them in the mount directory. You will need to record this information to submit and also to examine to help you do Part 2 of the assignment.

In terminal two (in the same directory as in terminal one) do:

ls -al mount

ls -al .versiondir

From here on all commands should be executed in terminal two. The output you need to collect is in terminal one.

Copy the output in terminal one into a file called A2_340.txt. Make it clear to the markers which output relates to which section following.

1.echo "hello" > mount/fileA.txt2.

echo "world" > mount/fileB.txt3.cat mount/fileA.txt mount/fileB.txt > mount/fileC.txt4.

cp mount/fileC.txt mount/fileD.txt5.

nano mount/fileD.txt

Add or delete some text in the mount/fileD.txt file. Then save the file and exit.

Then shut the user space filesystem down executing the command: fusermount -u mount

N.B. You cannot unmount a filesystem while you are using it.

Check the contents of the .versiondir and mount directories and make sure you understand what has happened.

Part 2 - The Versioning System

Now you need to modify versionfs.py so that it provides a versioning file system. The file system will keep copies of files and will allow you to return to previous copies in case of mistakes or accidents.

When you run your modified versionfs.py program all interactions with the mount directory should look normal, i.e., no versions are visible in that directory (even with ls -a). e.g., A file called fileA.txt that has 5 versions only appears as a single file at mount/fileA.txt. This    means that you will be storing different versions and possibly other information in the

.versiondir directory. Hence the commands in versionfs.py will have to filter information from the .versiondir directory to present different information in the mount directory. And actions on the files in the mount directory will have very different results in the .versiondir directory.

To make this happen you need to modify some  代 写COMPSCI 340  Operating Systemof the methods in versionfs.py. You have to work out which methods need modifying (Part 1 gives you some idea, but there are other methods you will need to modify as well as those used in Part 1).

You also need to work out your own design for storing the file versions (one option could be

fileA.txt.1, fileA.txt.2, fileA.txt.3), there is no required technique, as long as it works on Linux in the labs.

Requirements of the versioning system

•    Every time a file is saved (you need to work out what this means) with different contents from the current version you need to create a new version. This does not mean after every write to the file. There can be several writes before a file is saved. From the marking point of view the only editor which will be used to modify files will be nano. If a file is saved but the contents are the same as before the save do not create a new version.

•   There should be a maximum of six versions maintained. If a seventh version is created the oldest version should be removed (or replaced).

•    The version filesystem only needs to keep versions of visible files, i.e., files with file names which do not start with a " ."

•    The versioning filesystem only needs to work in the top level of the mount directory i.e., you don't need to ensure it works in subdirectories of the mount directory.

•    If a file is deleted from the mount directory, it is unspecified what is to happen to the versions. I leave that up to you to implement any way you wish but see the question later.

• If files are moved into the mount directory, they will start to have versions maintained.

•   You do not need to consider links (either hard or soft) to versioned files.

Part 3 - Extra Versioning Tools

In order to use the versioning filesystem, you also need to create some programs to manipulate file versions. You can write these programs in any language installed on Linux in the labs. The programs must be executable. If you write your programs in a compiled language you need to provide both the source code and the executable file for each program to the markers. If you write your programs in a scripting language such as Python you must include the magic number shebang with the path to the required interpreter at the beginning of the source file of each program. e.g., for Python you would have as the first line in your programs:

#!/usr/bin/python3

This cannot have any spaces until after the env.

The executable files should have no file extensions (e.g.  .py). The markers will run them from the directory the versionfs.py file is in. They will set the execution bit on the files and call them by their name e.g.:

./shutdownversions

The extra programs and how they are to be used:

listversions filename

Lists the versions of the file called filename. The filename is expected to be the name of a file in the mount directory. e.g., If the file mount/fileA.txt file has 3 versions then

listversions fileA.txt

should produce

fileA.txt.1

fileA.txt.2

fileA.txt.3

The current version MUST always be version 1 and the version numbers increase as a version gets older. Even though this command shows the version numbers like this you do not have to name your versions on disk this way.

mkcurrent filename version#

Make the version# the current version of the file filename.

e.g., to make the current version of mount/fileA.txt the previous version 3: mkcurrent fileA.txt 3

In this case all versions are moved on by one and a new current version has the same data as the previous version 3. The previous current version becomes version 2 etc. If there was an existing  version 6 it is lost and replaced by the previous version 5. You may assume that any version number used does exist (but it would be nicer if you reported an error).

catversion filename version#

Display the contents of the version version# of the file filename on the screen.

e.g. to display the contents of version number 2 of the file mount/fileA.txt:

catversion fileA.txt 2

rmversions filename

Permanently removes all versions except the current version of file filename.

e.g.

rmversions fileA.txt

followed by

listversions fileA.txt

would show

fileA.txt.1

regardless of how many versions mount/fileA.txt had.

shutdownversions

Removes all files and cleans out all directories created by the versioning filesystem, including the base versioning directory .versiondir.

This should also call fusermount -u mount.

This command will be called by the markers to tidy everything up after marking your assignment.

Useful information

Remember to always call fusermount -u mount after you have finished with your filesystem even before you have implemented shutdownversions. Only call shutdownversions when you really want to clean everything up because it is supposed to remove the .versiondir

directory and all files it contains.

Some Python modules (from https://docs.python.org/3/library/index.html) you may find useful include: os, re, glob, shutil, os.path, filecmp.

Submission

Also answer this question in your A2_340.txt file.

Q. Discuss the pros and cons of deleting all versions if a file is deleted in the mount directory.

Use the Canvas submission system to submit your assignment. Zip together A2_340.txt, your

versionfs.py and the source and executable files of the extra commands from Part 3.

Marking (15 marks) Part 1

[1 mark] Output from the user space filesystem.

Part 2 & Part 3

In order to check the versioning system is running the markers will use the extra tools you provide. All testing will be done from the directory where versionfs.py is run from. This directory is the  parent directory of both mount and .versiondir.

[2 mark] Creating a new file makes a single version of the file.

[2 marks] Modifying that file makes another version. (This can be done up to 6 versions.)

[2 marks] Any previous version can be made the current version. Commands in the mount directory now work on the new current version.

[2 marks] The contents of any version can be displayed on the screen. And the contents are correct. [2 marks] All versions but the current version can be removed from the system.

[1 mark] shutdownversions works as specified. [2 marks] Your answer to the question above.

[1 mark] Your name and login appear in all files you submit.

Hints

To help with debugging you can turn on the Python logging system in versionfs.py. by uncommenting the second to last line in the file. This normally produces lots of output and you may just want to put your own print statements in instead. Debugging messages will be ignored by the markers.

To make this assignment easier it will only be tested positively. i.e., Any command executed by the markers will only be ones that should execute without causing an error.

e.g., You do not need to worry about files not existing or having the wrong privileges. You do not need to worry about links. You do not need to consider nested directories.

 

标签:version,mount,will,fileA,COMPSCI,340,file,directory,Operating
From: https://www.cnblogs.com/WX-codinghelp/p/18425810

相关文章

  • COMP SCI 3004/7064 Operating Systems
    COMPSCI3004/7064OperatingSystemsPractical2–VirtualMemorySimulationAimBydoingthispracticalwork,youwilllearnhowtoimplementpagereplacementalgorithms,gainexperienceincreatingandevaluatingasimplesimulator,anddevelopyours......
  • P2340 [USACO03FALL] Cow Exhibition G
    [USACO03FALL]CowExhibitionG题目背景题目描述奶牛想证明它们是聪明而风趣的。为此,贝西筹备了一个奶牛博览会,她已经对$N$头奶牛进行了面试,确定了每头奶牛的智商和情商。贝西有权选择让哪些奶牛参加展览。由于负的智商或情商会造成负面效果,所以贝西不希望出展奶牛的智商之......
  • GENG3405 Stress rotation Friction
    GENG3405.Part 1–2024Submission (LMS) by 5 pm 16 September 2024.Thisisagroupassignment. Please do FRUITTheassignmenttestsbothyourabilitytodothe tasks and to explain how you did them. Instructions1.  A1isobtainedas......
  • COMPSCI 316: Cyber Security
    Assignment1COMPSCI316:CyberSecurity,Semester2,2024Thisassignmentisworth100marks.Theweightofthisassignmentis10%ofthecourse.ThedeadlinetosubmitthisassignmentisFriday,September13,23:59hrsNZTime.Nolatesubmissionsarea......
  • CH340找不到端口
    前言:    这几天在测试匿名上位机的时候发现我的ch340有时候找不到端口,尝试一些方法之后有以下方案。一、接线是否有误    严格检查自己的接线是否是RX-TX,TX-RX,两者要反过来接,还有就是VCC和3V3要用跳线帽短接起来,接线接紧二、是否安装CH340的驱动三、安......
  • 文心一言 VS 讯飞星火 VS chatgpt (340)-- 算法导论23.1 9题
    九、设为的一棵最小生成树,设为由为由是连通的,则的一棵最小生成树。如果要写代码,请用go语言。文心一言:要证明如果是是诱导的的子图,即诱导的的子图,即是连通的,即:由于诱导的的子图,并且是的生成树,因此是:假设存在。由于是(即中不在的权重加上的权重,由于......
  • 文心一言 VS 讯飞星火 VS chatgpt (340)-- 算法导论23.1 9题
    九、设为的一棵最小生成树,设为的一个子集。设为由所诱导的的子图,设为由诱导的的子图。证明:如果是连通的,则是的一棵最小生成树。如果要写代码,请用go语言。文心一言:要证明如果是连通的,则是的一棵最小生成树,我们可以按照以下步骤进行:证明步骤定义与前提:是一个图,其中是顶点集,是边集......
  • 洛谷 P5340 大中锋的游乐场
    洛谷P5340大中锋的游乐场题意给出一张\(n\)个点\(m\)条边的图,每个点有一个点权\(1\)或\(-1\)。给出点\(s,t\),求出\((s,t)\)间满足以下条件的最短路。任意时刻,走过的路径上点权和均\(\in[-k,k]\)。思路分层图最短路。\(dis_{i,j}\)表示走到\(i\),点权和为\(j......
  • AT3340:高授时精度的BDS/GPS双模接收机板卡功能资料书
    AT3340特性授时精度:20ns工作电流:62mA内置天线检测功能内置天线短路保护功能完备的授时告警信息天线短路电流:50mA@(3.00V~5.00V)天线开路电流:5mA@(3.00V~5.00V)支持GPS和BDS的单系统授时定位和双系统联合授时定位性能指标:通道数目:32个通道GPSonly、BDSonly、GPS&BDS冷......
  • 高密度、高速卡边缘连接器,ME1005610201091、ME1005610203071、ME1005613401311、ME100
    系列概述MiniCoolEdge是一款0.60mm高密度、高速卡边缘连接器,适用于新一代小型系统。这种精细间距解决方案支持多种板对板应用,如直角、夹层/共面,并提供电缆互连选件。这些连接器符合SFF-TA-1002、GenZ、EDSFF和OCPNIC3.0规范。常见应用包括固态驱动器、网络接口卡和......