Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecturer: Hao-Hua Chu TA: Wen-Chang HSU.  Read and understand the nachos file system  Enhance file system in Nachos  Relax maximum size of a file.

Similar presentations


Presentation on theme: "Lecturer: Hao-Hua Chu TA: Wen-Chang HSU.  Read and understand the nachos file system  Enhance file system in Nachos  Relax maximum size of a file."— Presentation transcript:

1 Lecturer: Hao-Hua Chu TA: Wen-Chang HSU

2  Read and understand the nachos file system  Enhance file system in Nachos  Relax maximum size of a file. ▪ Nachos file system can not hold a single file more than 4KB ▪ You need to increase the limit up to 32 Kbyte.  Let Nachos has hierarchal directory structure ▪ Nachos has only one root directory ▪ Have Nachos handle subdirectory. 2

3  How to use Nachos File system.  C++ files that represent file system  The clue of how to extend file size limit.  Modify the FileHeader class ( i-node ).  How to add subdirectory  Modify the File System  Test case. 3

4  There are two mode of nachos file system  1. STUB system ( we use it before).  Nachos file system operations are forward to host file system.  2. Native file system  Nachos simulate a disk with a huge file.  Nachos implement the detail of every file operation. 4

5  Modify Makefile, remove the -DFILESYS_STUB  Make clean and rebuild nachos.  You can use Nachos with native file system now! 5

6  Nachos -f  format and make a disk.  Nachos –cp source destination  Copy unix file into nachos disk.  Read trheads/main.cc, you know all the file system operations in nachos. 6

7  filesys.cc/h  It contains top-level file system functions.  Directory.cc/h  Contains the structure of one directory.  openfile.cc / h  Like a file descriptor (fd).  filehdr.cc/h ( i node )  It contains pointes to data sectors on disk.  Synchdisk.cc / h  Operation on disks 7

8 8 01289 15 50 Syndisk: Disk is look like a huge array. Access each element by sectorNumber. each sector size is 128 byte.

9 9 01289 15 50 FileHeader. Store on one sector. And has pointers point to data sector.

10 10 01289 15 50 FileHeader. OpenFile : it is a wrapper of Fileheader. Perform r/w access of a single file by OpenFile. Act like a fd.

11 11 012 inode 89 15 50 FileSystem: Provide functionality to manage files. Free map:Store a bitmap. To record which sector is free Directory:Stores name and position of every file.

12  Why maximum size of a file is limited?  The size of file header (i-node) is corresponding to the size of one sector.  The maximum size of a file is limited by the number of pointers that will fit in one disk sector. 12 FileHeader.

13 #define NumDirect ((SectorSize - 2 * sizeof(int)) / sizeof(int)) #define MaxFileSize (NumDirect * SectorSize) class FileHeader { you need read the comment of every public methods carefully. private: int numBytes; // sizeof( int) int numSectors; // sizeof(int) int dataSectors[NumDirect]; } 13

14  A FileHeader can be initialized by  (1) Allocate : allocate free sector and create a new file fileheader  (2)FetchFrom : the fileheader is already exists on disk, so the method just read the file header structure.  ByteToSector.  Return the sector where a given byte is on. 14

15  Add some indirect blocks in FileHeader.  You can’t change the size of a sector.  In Allocate and Deallocate, you'll need to determine if you need to use indirect blocks or not base on file size.  In FetchFrom and WriteBack, you'll also need to determine whether indirect blocks are needed.  Plan carefully! 15

16  Nachos has only a root directory.  modify file fileSystem and Directory to support subdirectory.  Separator is the usual UNIX directory separator / 16

17  TA will put file up to 32k into your file system.  Bonus:  If you can handle file up to 4MB.  Disk created by nachos is just 128 KB,You need to check how to correctly enlarge the simulated disk. 17

18  TA will test your implementation by copying,listing, dumping and executing file in your file system.  Nachos -r path_to_dir // 刪除檔案  nachos -l path_to_dir // 列出某個資料夾的內容。  nachos -p path_to_file // 看檔案內容  nachos -cp UnixFIle path_to_dir // 拷貝資料  nachos -mkdir path_to_dir // 創建新的資料夾。  nachos -E path_to_file UnixFile // 匯出檔案到 unix  除了 mkdir, -E 其他的參數 nachos 本來就有提供相似的的功能, 。 18

19  Each directory name in less than 9 character  TA won’t test strange file name.  You need to correctly support multiple level subdirectory. 19

20  Submit source code and report.  Make clean first. Don’t send the simulated disk!  The file you need to send: 1. A report in.pdf or.doc 2. code directory in nachos,  指令範例 ( 在 NachOS-4.0 目錄下執行 ): "tar zcvf os_hw5_b91902090.tar.gz code report.pdf"  壓縮檔範例 : http://www.csie.ntu.edu.tw/~artoo/os_hw5_b91902090.tar.gz 20

21  Due at 1/5 24:00 !! 21

22 22  Deadline: 10/6 24:00  Delayed submission would have penalty!  DO NOT COPY!! Protect your code well!!


Download ppt "Lecturer: Hao-Hua Chu TA: Wen-Chang HSU.  Read and understand the nachos file system  Enhance file system in Nachos  Relax maximum size of a file."

Similar presentations


Ads by Google