Nachos File System

 

Laboratory 4: Nachos File System

:Objectives(实验目标)

The purpose of this laboratory session is to study the functionality of the file system in Nachos.

The file system in Nachos is designed to be small and simple so that you can read all its source

code in a short period of time. Before starting to read the code, it is very useful to get an idea

of what functionality the Nachos file system offers. In this laboratory session, you will run the

commands of the Nachos file system and watch the effects on the simulated hard disk in Nachos.

On the completion of this laboratory session, you should know

_ what is the functionality of the Nachos file system, and

_ how to examine the contents of the simulated hard disk in Nachos.

:实验环境

It is very simple to compile Nachos with its file system. You simply move to the directory ../filesys

and execute command make. A new version of Nachos with its file system included will be

made in the directory. The Makefile in ../filesys/ includes both Makefile.local files from

../threads/ and ../filesys/. The Makefile.local in ../filesys/ is as follows:

ifndef MAKEFILE_FILESYS_LOCAL

define MAKEFILE_FILESYS_LOCAL

yes

endef

# Add new sourcefiles here.

CCFILES +=bitmap.cc\

directory.cc\

filehdr.cc\

filesys.cc\

fstest.cc\

openfile.cc\

29

synchdisk.cc\

disk.cc

ifdef MAKEFILE_USERPROG_LOCAL

DEFINES := $(DEFINES:FILESYS_STUB=FILESYS)

else

INCPATH += -I../userprog -I../filesys

DEFINES += -DFILESYS_NEEDED -DFILESYS

endif

endif # MAKEFILE_FILESYS_LOCAL

This means that this version of Nachos uses C++ files listed above in addition to the files used to

compile the Nachos in ../threads/. Most of these additional files exist in the current directory.

Some of them are in other directories such as ../userprog/. The make utility program will find

them automatically due to the VPATH defined in ../Makefile.common.

:关键代码注释:

9.5.1 Compiling Nachos File System

Follow the description in Section 9.2 to compile the Nachos with its file system in ../filesys/). 输入make

9.5.2 Testing Nachos File System

Execute the following commands and check the results as described:

(a) Execute nachos -f. Nachos should have created the simulated hard disk called DISK in your

current directory.

(b) Execute nachos -D to dump the whole file system on the simulated hard disk DISK and you

should have the following dump:

....

FileHeader contents. File size: 128. File blocks:

2

File contents:

\1f\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0

\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0

\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0

31

\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0

Directory file header:

FileHeader contents. File size: 200. File blocks:

3 4

File contents:

\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0

\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0

\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0

\0\0\0\0\0\0\0\0\0\0\0\0\0\0

\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0

\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0

(c) Execute od -c DISK and you should have the following dump on the screen:

0000000 211 g E 200 \0 \0 \0 001 \0 \0 \0 002 \0 \0 \0

0000020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

*

0000200 \0 \0 \0 \0 \0 \0 \0 002 \0 \0 \0 003 \0 \0 \0

0000220 004 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

0000240 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

*

0000400 \0 \0 \0 \0 037 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

0000420 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

(d) Execute nachos -cp test/small small to copy file small into the Nachos file system.

Use nachos -l, nachos -p and nachos -D to make sure you do create a new file named

small in the Nachos file system. Watch the dump of od -c DISK again to see what has been

changed.

(e) Continue the experiment with other nachos commands such as nachos -r on more files.

:调试记录:

记录如上.

:运行结果分析:

本实验主要通过对文件系统的一系列操作来观察相应的nachos文件的变化,同时熟悉nachos文件的相应代表意义,就像上面的结果,可以观察到头文件和相应文件存放的扇区。

你可能感兴趣的:(linux,NachOs)