1 / 5

size of directory / file structure is 32 bytes

In this assignment you are going to read floppy disk. You can run ‘mdir’ Unix function to see what output your program should give. FAT-12 MS-DOS file system: floppy disk uses this file system, and that means the following: - each sector has 512 bytes - each entry in FAT table has 12 bits

zea
Download Presentation

size of directory / file structure is 32 bytes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. In this assignment you are going to read floppy disk.You can run ‘mdir’ Unix function to see what output your program should give. FAT-12 MS-DOS file system:floppy disk uses this file system, and that means the following: - each sector has 512 bytes - each entry in FAT table has 12 bits floppy disk layout: Boot sector: contains lots of details, you don’t need it in this assignment.FAT tables: usually floppy disk contains two identical copies of FAT table.You need to use this table in order to read directories content (for all directories except the root directory) – would be explained later.Root directory: contains one entry for all directory/file that is straight under the root directory (their quantity is limited to 224).Data area: sectors with directories / files data.Pay attention that in each of the items above have their constant place on disk.

  2. Structure of the root directory:root directory contains entries for each directory / file that it contains.Entry for directory / file has the following structure:struct directory { char name[8]; /* 0 file name */ char ext[3]; /* 8 file extension */ unsigned char attr; /* 11 attribute byte */ unsigned char Case; /* 12 case of short filename */ unsigned char ctime_ms; /* 13 creation time, milliseconds (?) */ unsigned char ctime[2]; /* 14 creation time */ unsigned char cdate[2]; /* 16 creation date */ unsigned char adate[2]; /* 18 last access date */ unsigned char startHi[2]; /* 20 start cluster, Hi */ unsigned char time[2]; /* 22 time stamp */ unsigned char date[2]; /* 24 date stamp */ unsigned char start[2]; /* 26 starting cluster number */ unsigned char size[4]; /* 28 size of the file */ { For example, in order to read a name of the first directory / file in the root directory, you need to read sector #19 from the floppy disk, and then read the first entry of this sector, and then read first 8 bytes of this entry. Compile and run mardir.c file (with some floppy disk, of course in disk drive).This program prints names (only) of all directories / files of the root directory. size of directory / file structure is 32 bytes

  3. Directory / file attributes:third field of the directory structure is named attr; its size is one character;it contains on / off bits of directory / file attributes:1. READ_ONLY = 0x01 (1b) – if this bit is on, the file is read only2. HIDDEN  = 0x02 (10b) – if this bit is on, the file is hidden3. SYSTEM = 0x04 (100b) – if this bit is on, the file is system file4. VOLUME = 0x08 (1000b) – isn’t important for us 5. DIRECTORY = 0x10 (10000b) – if this bit is on, the file is directory6. ARCHIVE = 0x20 (100000b) - if this bit is on, the file is really file (not directory)7. LONG_NAME = 0xF (1111b) – isn’t important for us  We use this attributes when want to show content of any directory on the floppy directory: we don’t show hidden, system, volume files.In order to verify if some directory / file has some attributes, we use binary operations (see the code file that I wrote in order to understand this better). Note: the file I put does only a little part of the work you have to do.Please read maman 15 instructions carefully and implement all of it.

  4. Deleted files:when you delete file (or directory), it name isn’t removed from the directory file that contained it. Operating system just changes its name, putting 0xe5 character as a first character of the name of the deleted file. So if you read some directory, pay attention at the first character of its name: if it is 0xe5, this means that this file was deleted and you have not to show it. Printing directory that is not the root directory:let’s look at the following example: ls /dir1/dir2 FAT table (starting at sector #1): if you scanned sector 59, and didn’t find an entry for dir2 there, you have to scan next sector of dir1; in order to find it, you have to look at entry 59 of FAT and there you will find the number of the next sector of dir1 for example: root directory You have to read sector #59 from floppy disk, and then scan it for entry of directory with name dir2 …name = dir1…start = 59 You have to read sector #73 from floppy disk, and then scan it for entry of directory with name dir2 59: 73 After you found an entry for dir2, use its ‘stat’ field to find its first sector on the floppy disk, and read it; then scan all its entries and print all the file/ directory names with all the details asked in the maman; then read second sector of dir2 using FAT as I explained above, and so on, till you reach the end of dir2 file (-1 in the last FAT entry that you look at).

  5. How you read floppy disk:since we use Unix, all disk drives are mounted into the single tree, and the path of the floppy disk in this tree is “/dev/fd0”.See the code I put in order to learn how to open this file and to read from it. Sorry for the late publish If you have any questions, just send them to me to my email. Good luck at the exam.

More Related