Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are asked to develop a Floppy Disk program that allows users to access a floppy disk locally mounted on a computer. You are expected

You are asked to develop a Floppy Disk program that allows users to access a floppy disk locally mounted on a computer. You are expected to use C programming language. In your program, all file I/O related operations should use the system calls discussed in our lectures, including open(), read(), write(), lseek(), close(), and you should not use those library functions like fopen() andfread(). Your implementation must work on Linux machine in FH133 lab.

Required Modules:

1. [90%] Client Environment (a floppy console): the console (interface) allows users to access the floppy by using the following commands:

[5%] help: show the commands supported in the floppy shell. [5%] fmount argument: mount a local floppy disk, where "argument" is a floppy image file, e.g., imagefile.img. [5%] fumount: umount the mounted floppy disk. [10%] structure: to list the structure of the floppy disck. For example:

flop: structure 
number of FAT: 2 number of sectors used by FAT: 9 number of sectors per cluster: 1 number of ROOT Entries: 224 number of bytes per sector: 512 
---Sector #--- 0 
 01 -- 09 10 -- 18 19 -- 32 
---Sector Types--- BOOT 
 FAT1 FAT2 ROOT DIRECTORY 

Note that the above numbers should be extracted from the floppy disk rather than being hard coded (you won't received any credit for the hard coding). [20%] traverse [-l]: list the content in the root directory. For example:

flop: traverse /A.CLA /ALOOP1.CLA /ALOOP1.JAV /ALOOP2.CLA /ALOOP2.JAV /ALOOP3.CLA /ALOOP3.JAV /B.CLA /CONDIT.CLA /CONDIT.JAV /D.CLA /DEMO.CLA /DEMO.JAV /DIR1 
/DIR1/. /DIR1/.. /DIR1/DIR2 /DIR1/DIR2/. /DIR1/DIR2/.. /DIR1/DIR2/FILE3 /DIR1/C.CLA /POLYTEST.CLA /POLYTEST.JAV /SOME.CLA 
      

When switch -l is turned on (long list), all detailed information is shown, including the file attribute, last modified time, file size (in bytes), the path name and the starting logical cluster ID. For example:

flop: traverse -l ***************************** 
 ** FILE ATTRIBUTE NOTATION ** ** ** ** R ------ READ ONLY FILE ** 
 ** S ------ SYSTEM FILE ** ** H ------ HIDDEN FILE ** ** A ------ ARCHIVE FILE ** ***************************** 
-A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 
----- 10/27/2014 13:13:05 
----- 10/27/2014 13:13:05 
----- 10/27/2014 13:13:05 
----- 10/27/2014 13:13:05 
----- 10/27/2014 13:13:05 
----- 10/27/2014 13:13:05 
-A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 -A--- 10/27/2014 13:13:05 
      
 670 /A.CLA 3 763 /ALOOP1.CLA 5 333 /ALOOP1.JAV 7 786 /ALOOP2.CLA 8 404 /ALOOP2.JAV 10 786 /ALOOP3.CLA 11 408 /ALOOP3.JAV 13 358 /B.CLA 14 
1067 /CONDIT.CLA 15 444 /CONDIT.JAV 18 508 /D.CLA 19 967 /DEMO.CLA 20 648 /DEMO.JAV 22 
 /DIR1 24 /DIR1/. 24 /DIR1/.. 0 /DIR1/DIR2 25 /DIR1/DIR2/. 25 /DIR1/DIR2/.. 24 
 11 /DIR1/DIR2/FILE3 26 427 /DIR1/C.CLA 27 630 /POLYTEST.CLA 28 
1063 /POLYTEST.JAV 30 226 /SOME.CLA 33 

[10%] showsector [sector number]: show the content (in the form of hex dump) of the specified sector number (512 bytes for each sector). For example:

flop: showsector 10 0123456789ABCDEF

0F0FFFF 040 0FF6F 0FFFFFF 9F0FFFF 10CF 0FFFFFFFF F 111F0FFFFFFFF15F0 20FF17F0FFFFFFFFFFFFFF1DF0FF1F 0 2 30 FF FF FF 0 0 0 0 0 0 0 0 0 0 0 0 0 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 70 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 A0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 B0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 D0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 E0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 F0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1A0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1B0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1C0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1D0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1E0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1F0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

[15%] showfat: show the contents of the first 256 entries in the FAT table (in the hex dump).flop: showfat

0123456789abcdef FREE 4fff 6ffffff 9ffffff cfffffffff 10 10 11fffffffff 15fff 17fffffffffffffff 1dfff 1f 20 20 fff fff FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE 30 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE 40 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE 50 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE 60 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE 70 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE 80 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE 90 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE a0 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE b0 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE c0 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE d0 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE e0 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE f0 FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE FREE

Note: you are expected to interpret the raw FAT data to a readable format as show above, i.e., extract the 12-bit entry value and reconstruct a FAT table with the cluster indices (the first column and the first row). If the cluster entry is free, please print "FREE" as the content. [15%]showfile [filename]: show the content of the target file (in the hex dump).

 flop: showfile /ALOOP1.JAV 

70 75 62 6c 69 63 20 63 6c 61 73 73 20 41 6c 6f 6f7031207b a202020207075626c6963 20 73 74 61 74 69 63 20 76 6f 69 64 20 6d 61 69 6e 28 53 74 72 69 6e 67 5b 5d 20 61 72 67 73 29 207b a 9 a 9537472696e675b5d2072 61 6e 6b 20 3d 20 7b 22 44 45 55 43 45 22 2c 20 22 54 48 52 45 45 22 2c 20 22 46 4f 55 52 22 2c 20 22 46 49 56 45 22 2c 20 22 53 49 58 22 2c 20 22534556454e222c a 9 9 920224549 47 48 54 22 2c 20 22 4e 49 4e 45 22 2c 20 22 54 45 4e 22 2c 20 22 4a 41 43 4b 22 2c 20 22 51 55 45 45 4e 22 2c 20 22 4b 49 4e 47 22 2c 20 22 41 4345227d3b a 9 a 9696e742069203d 20303b a 9696e7420636f756e746572 203d20303b a 97768696c6520282172 61 6e 6b 5b 69 5d 2e 65 71 75 61 6c 73 28 22 53 4958222929207b a 920202020692b2b 3b a 920202020636f756e7465722b2b 3b a 97d a 953797374656d2e6f7574 2e 70 72 69 6e 74 6c 6e 28 63 6f 75 6e 74 65 72 29 3b a a 20 20 20 20 7d a 7d a a 0 0 0

0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000

[5%] quit: quit the floppy shell. 2. [5%] Provide a Makefile so make command would produce the executable. 3. [5%] Write-up:

Please take a group picture inside FH128 and copy the JPEG file into the submission folder. you are required to write a README document (in TXT format only) that describes your project design detail and the execution sequence (with the commands). In particular, please explicitly state which part, if there is any, does not work and the possible reasons why that module does not work. For those working modules, please give a brief (in short) sample output. In particular, you have to follow the format below:

 1. Your Group Members; 2. The contribution (percentage) of the members; 3. Project description; 4. The compile instruction and execution command; 5. Sample execution results (for each command); 
6. Existing bugs (if there is). 

It is not easy to find a computer equipped with a floppy disk drive, but we can use mount utility to easily create a virtual floppy disk device.

For your convenience, we provide an example floppy image: imagefile.img. You may also create your own floppy image by following instructions (on your own computers only):

Create an empty floppy image: (here 1.44MB) $ dd bs=512 count=2880 if=/dev/zero of=./imagefile.img 
Format it: $ mkfs.msdos ./imagefile.img 

Once an image is ready, you can simply open the image file in your program to access the floppy disk:

 $ sudo mkdir /media/floppy/ $ sudo mount ./imagefile.img /media/floppy/ 

Now you can do any normal disk operations on this virtual floppy disk. Note that your current floppy image file is empty (no file and directory). Next, you may copy files and create directories in /media/floppy. As the result, the mounted image file: imagefile.img, will be automatically updated. Once you are done, please umount the /media/floppy, and your imagefile.img with your own data is ready to be used. To access this virtual floppy disk, you can simply open the image file in your program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Second East European Symposium Adbis 98 Poznan Poland September 1998 Proceedings Lncs 1475

Authors: Witold Litwin ,Tadeusz Morzy ,Gottfried Vossen

1st Edition

3540649247, 978-3540649243

More Books

Students also viewed these Databases questions