FAT32 Directory Entries and Operations Guide

29
1 FAT32 Directory Entries and Operations Guide Operating Systems CS3430 Sarah Diesburg

description

FAT32 Directory Entries and Operations Guide. Operating Systems CS3430 Sarah Diesburg. Outline. Directory entries Short-name and long-name entries Project 3 operations. Directory Entries. Directory Entries. Lists names of files and directories in a directory Types - PowerPoint PPT Presentation

Transcript of FAT32 Directory Entries and Operations Guide

Page 1: FAT32 Directory Entries and Operations Guide

1

FAT32 Directory Entries and Operations Guide

Operating Systems

CS3430

Sarah Diesburg

Page 2: FAT32 Directory Entries and Operations Guide

Outline

Directory entries Short-name and long-name entries

Project 3 operations

2

Page 3: FAT32 Directory Entries and Operations Guide

Directory Entries

3

Page 4: FAT32 Directory Entries and Operations Guide

Directory Entries

Lists names of files and directories in a directory

Types Short-name directory entry Long-name directory entry

4

Page 5: FAT32 Directory Entries and Operations Guide

Short-name Directory Entry Limits name size to 8 bytes with additional 3

bytes after “.” Compatible with previous FAT versions 32 bytes total size Holds important information about file or dir:

Attributes, timestamp, last access date, first cluster number, size

5

Page 6: FAT32 Directory Entries and Operations Guide

Short-name Directory Entry If DIR_Name[0] == 0xE5, then the directory

entry is free (no file or directory name in this entry)

If DIR_Name[0] == 0x00, then the directory entry is free (same as for 0xE5), and there are no allocated directory entries after this one

6

Page 7: FAT32 Directory Entries and Operations Guide

Long-name Directory Entry Backwards-compatible way to allow longer

names to be displayed Each long-name directory entry is 32 bytes

A long file name can cover a set of long-name directory entries

Each set of long-name directory entries must correspond to a short-name directory entry Long-name entries must immediately precede

corresponding short-name entry

7

Page 8: FAT32 Directory Entries and Operations Guide

Long-name Directory Entry

8

Long-name part 1

Long-name part 2

Short-name

Two long-name entries are needed to hold the file name

Page 9: FAT32 Directory Entries and Operations Guide

Long-name Directory Entry

9

Long-name part 1

Long-name part 2

Short-nameShort name entry for the file must exist too

Page 10: FAT32 Directory Entries and Operations Guide

Long-name Directory Entry

10

Long-name part 1

Long-name part 2

Short-name

Long-name entries for this file immediately precede short-name entry

Page 11: FAT32 Directory Entries and Operations Guide

Directory entries

Long-name entry for “fatgen103.pdf"

11

Page 12: FAT32 Directory Entries and Operations Guide

Directory entries

Short-name entry for “fatgen103.pdf"

12

Page 13: FAT32 Directory Entries and Operations Guide

Long-name Directory Entries You can ignore the long directory entries

Can just display the short names This makes the project easier

13

Page 14: FAT32 Directory Entries and Operations Guide

“Dot” Entries

All directories (except root directory of entire system) have “.” and “..” directory entries

“.” means “this directory” “..” means “the parent directory” Why do you think the root directory does not

have these entries?

14

Page 15: FAT32 Directory Entries and Operations Guide

Directory Entry Attributes

Offset 11 in directory entry, 1 byte long ATTR_READ_ONLY 0x01 ATTR_HIDDEN 0x02 ATTR_SYSTEM 0x04 ATTR_VOLUME_ID 0x08 ATTR_DIRECTORY 0x10 ATTR_ARCHIVE 0x20 ATTR_LONG_NAME

ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID

15

Page 16: FAT32 Directory Entries and Operations Guide

Utility Operations

16

Page 17: FAT32 Directory Entries and Operations Guide

FAT32 Utility Oprations

info open close size cd

ls read

17

Utility recognizes the following built-in commands:

Page 18: FAT32 Directory Entries and Operations Guide

Precautions

File or directory must exist before performing operations on it

File must be open and flagged for reading before you attempt to read from it

Be sure you are reading from the right location Off by 1 byte can throw whole project off

18

Page 19: FAT32 Directory Entries and Operations Guide

Handling Open Files

An open file is a file we allow I/O operations to be performed on read

To handle open files, we must maintain a table of files that are open

Page 20: FAT32 Directory Entries and Operations Guide

Opening Files

/] open FATINFO.TXT rw

If “FATINFO.TXT” is found in the current directory, open “FATINFO.TXT”

In order to find fatinfo.txt, you must be able to interpret the current directory and determine whether fatinfo.txt is part of that directory

Once you open fatinfo.txt, store its name in the open file table

Page 21: FAT32 Directory Entries and Operations Guide

open

1. Check if the file is already open

2. Check that the provided file name exists in the requested directory

3. If it exists, add the file to your open file table

Page 22: FAT32 Directory Entries and Operations Guide

close

1. Check that the file name provided exists in your open file table

2. If it does, remove that entry from your open file table

Page 23: FAT32 Directory Entries and Operations Guide

Closing Files

/] close FATINFO.TXT

Remove this file’s entry from the open file table

23

Page 24: FAT32 Directory Entries and Operations Guide

ls

1. Make sure that provided directory name is directory and exists in requested directory

2. Seek first data cluster

3. Iterate through and print each directory entry in the cluster

4. If more directory entries left than first cluster can hold, seek next cluster and repeat 3

Page 25: FAT32 Directory Entries and Operations Guide

size

1. Check that provided file name exists in the requested directory

Can be accomplished by seeking through the clusters of the requested directory

2. If it does, extract the size information Pay attention to endianness!

Page 26: FAT32 Directory Entries and Operations Guide

cd

1. Check that provided directory name is a directory and exists

2. Alter your current working directory to reflect the change

For ease of debugging and use, you may want to alter your prompt to show current working directory

Page 27: FAT32 Directory Entries and Operations Guide

I/O on Open Files

/] read “fatinfo.txt” 0 100

Only allow the read if fatinfo.txt is open In order to read fatinfo.txt, you must look

into the open file table, look up the address of fatinfo.txt (or store it with its name), and read enough of the data clusters to satisfy the read request

Page 28: FAT32 Directory Entries and Operations Guide

read

1. Make sure file name provided is in open-file table and flagged as read-capable

2. Check that the provided position is valid

3. Check that the requested number of bytes is valid

4. Seek to data cluster corresponding to the requested start position and begin reading

5. If more data to be read, seek the next clusters and repeat 4

Page 29: FAT32 Directory Entries and Operations Guide

Use Cases

Be sure to look at the Project 3 Use Cases document and make sure you code acts the same way.

29