Description
1 Introduction
2 In this assignment, you will implement utilities that perform operations on a simple file system, FAT12, used by
3 MS-DOS.
4 1.1 Sample File Systems
5 You will be given a file system image: disk.IMA for self-testing, but your submission may be tested against other
6 disk images following the same specification.
7 You should get comfortable examining the raw, binary data in the file system images using the program xxd.
8 2 Requirements
9 2.1 Part I
10 In part I, you will write a program that displays information about the file system. In order to complete part I,
11 you will need to understand the file system structure of MS-DOS, including FAT Partition Boot Sector, FAT File
12 Allocation Table, FAT Root Folder, FAT Folder Structure, and so on.
13 Your program for part I will be invoked as follows:
./diskinfo disk.IMA
14 Your output should include the following information:
OS Name:
Label of the disk:
Total size of the disk:
Free size of the disk:
==============
The number of files in the root directory (not including subdirectories):
=============
Number of FAT copies:
Sectors per FAT:
15 2.2 Part II
16 In part II, you will write a program, with the routines already implemented for part I, that displays the contents of
17 the root directory in the file system.
18 Your program for part II will be invoked as follows:
./disklist disk.IMA
19 The directory listing should be formatted as follows:
1
20 1. The first column will contain:
21 (a) F for regular files, or
22 (b) D for directories;
23 followed by a single space
24 2. then 10 characters to show the file size in bytes, followed by a single space
25 3. then 20 characters for the file name, followed by a single space
26 4. then the file creation date and creation time.
27 2.3 Part III
28 In part III, you will write a program that copies a file from the file system to the current directory in Linux. If the
29 specified file is not found in the root directory of the file system, you should output the message File not found.
30 and exit.
31 Your program for part III will be invoked as follows:
./diskget disk.IMA ANS1.PDF
32 If your code runs correctly, ANS1.PDF should be copied to your current Linux directory, and you should be able
33 to read the content of ANS1.PDF.
34 2.4 Part IV
35 You will write a program that copies a file from the current Linux directory into the root directory of the file system.
36 If the specified file is not found, you should output the message File not found. on a single line and exit. If the
37 file system does not have enough free space to store the file, you should output the message No enough free space
38 in the disk image. and exit.
39 Your program will be invoked as follows:
./diskput disk.IMA foo.txt
40 Note that a correct execution should update FAT and related allocation information in disk.IMA accordingly.
41 To validate, you can use diskget implemented in Part III to check if you can correctly read foo.txt from the file
42 system.
43 3 File System Specification
44 The specification of FAT12 and related information could be found in Connex.
45 4 Byte Ordering
46 Different hardware architectures store multi-byte data (like integers) in different orders. Consider the large integer:
47 0xDEADBEEF
48 On the Intel architecture (Little Endian), it would be stored in memory as:
49 EF BE AD DE
50 On the PowerPC (Big Endian), it would be stored in memory as:
51 DE AD BE EF
52 Since the FAT was developed for IBM PC machines, the data storage is in Little Endian format, i.e. the least
53 significant byte is placed in the lowest address. This will mean that you have to convert all your integer values to
54 Little Endian format before writing them to disk.
2
55 5 Submission Requirements
56 What to hand in: You need to hand in a .tar.gz file containing all your source code and a Makefile that produces
57 the executables (i.e., diskinfo, disklist, diskget, and diskput).
58 The file is submitted through connex.csc.uvic.ca site.
59 6 Marking Scheme
60 7 Marking
61 We will mark your code submission based on correct functionality and code quality.
62 7.0.1 Functionality
63 1. Your programs must correctly output the required information in Part I, II, and III. One sample disk image is
64 provided to you for self-learning and self-testing. Nevertheless, your code may be tested with other disk images
65 of the same file system. We will not test your code with a damaged disk image. We will not disclose all test
66 files before the final submission. This is very common in software engineering.
67 2. You are required to catch return errors of important function calls, especially when a return error may result
68 in the logic error or malfunctioning of your program.
69 7.0.2 Code Quality
70 We cannot specify completely the coding style that we would like to see but it includes the following:
71 1. Proper decomposition of a program into subroutines (and multiple source code files when necessary)—A 1000
72 line C program as a single routine would fail this criterion.
73 2. Comment—judiciously, but not profusely. Comments also serve to help a marker, in addition to yourself. To
74 further elaborate:
75 (a) Your favorite quote from Star Wars or Douglas Adams’ Hitch-hiker’s Guide to the Galaxy does not count
76 as comments. In fact, they simply count as anti-comments, and will result in a loss of marks.
77 (b) Comment your code in English. It is the official language of this university.
78 3. Proper variable names—leia is not a good variable name, it never was and never will be.
79 4. Small number of global variables, if any. Most programs need a very small number of global variables, if any.
80 (If you have a global variable named temp, think again.)
81 5. The return values from all system calls and function calls listed in the assignment specification
82 should be checked and all values should be dealt with appropriately.
83 7.1 Detailed Test Plan
84 The detailed test plan for the code submission is as follows.
Components Weight
Make file 2
diskinfo 8
disklist 9
diskget 10
diskput 10
Readme 1
Total Weight 40
85
86 Note that the score of 40/40 means that you obtain 100% of this assignment.
3
87 8 Warning
88 1. You are required to use C. Any other language is not acceptable.
89 2. Your code should output the required information specified in Parts I, II, III, and IV. Failing to do so will
90 result in the deduction of scores.
91 3. You should use the Linux machines in ECS242 to test your work.
92 4. The due date of this assignment is set to be very late.
93 THERE WILL BE NO FURTHER EXTENSION!
94 9 Plagiarism
95 This assignment is to be done individually. You are encouraged to discuss the design of the solution and the FAT 12
96 specification with your classmates, but each student must implement their own assignment.
4