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