Download presentation
Presentation is loading. Please wait.
1
FAT32 Directory Entries and Operations Guide
Operating Systems CS3430 Sarah Diesburg
2
Outline Directory entries Project 3 operations
Short-name and long-name entries Project 3 operations
3
Directory Entries
4
Directory Entries Lists names of files and directories in a directory
Types Short-name directory entry Long-name directory entry
5
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
6
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
7
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
8
Long-name Directory Entry
Long-name part 1 Two long-name entries are needed to hold the file name Long-name part 2 Short-name
9
Long-name Directory Entry
Long-name part 1 Long-name part 2 Short name entry for the file must exist too Short-name
10
Long-name Directory Entry
Long-name part 1 Long-name entries for this file immediately precede short-name entry Long-name part 2 Short-name
11
Directory entries Long-name entry for “fatgen103.pdf"
12
Directory entries Short-name entry for “fatgen103.pdf"
13
Long-name Directory Entries
You can ignore the long directory entries Can just display the short names This makes the project easier
14
“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?
15
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
16
Checking the Image… You can tell your OS to “mount” the image just like a real file system $> sudo mount –o loop fat32.img /mnt $> cd /mnt $> sudo umount /mnt Be sure you cd out of the /mnt directory first
17
Checking the Image Mac computer automatically mount the image
They also *modify* it Add Trash can directory Add other files Your test image may become different than other people’s images
18
Utility Operations
19
FAT32 Utility Oprations Utility recognizes the following built-in commands: info stat volume cd ls read
20
Precautions File or directory must exist before performing operations on it Be sure you are reading from the right location Off by 1 byte can throw whole project off
21
Volume Volume ID string exists in two places Can get it either place
Boot sector Root directory Can get it either place
22
stat Check that provided file name exists in the requested directory
Can be accomplished by seeking through the clusters of the requested directory If it does, extract the size information Pay attention to endianness!
23
ls Make sure that provided directory name is directory and exists in requested directory Seek first data cluster Iterate through and print each directory entry in the cluster If more directory entries left than first cluster can hold, seek next cluster and repeat 3
24
cd Check that provided directory name is a directory and exists
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
25
I/O 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
26
read Make sure file name provided is in open-file table and flagged as read-capable Check that the provided position is valid Check that the requested number of bytes is valid Seek to data cluster corresponding to the requested start position and begin reading If more data to be read, seek the next clusters and repeat 4
27
Other Things Be sure to look at the Project 3 Use Cases document and make sure you code acts the same way. You must read the Microsoft FAT32 Specification to understand what’s going on Be sure your code works on the class virtual machine You may need to boot into the original kernel
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.