26
Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Embed Size (px)

Citation preview

Page 1: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Lecture 9: The FAT and VFAT Filesystems

6/16/2003

CSCE 590

Summer 2003

Page 2: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Disk Drive Review

• Disks or platters of magnetic material– Can be one or two sided

– Rated to hold a certain amount of magnetic charge

• Motor to spin the disks• Set of read/write/erase heads

– Read/write heads sandwiched between two erase heads

• Actuator (stepper motor) to position heads• Interface (circuitry) to transfer data to and from

disk

Page 3: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Disk Drivehttp://www.ntfs.com/hard-disk-basics.htm

Page 4: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Low Level Formatting

• Setting down a series of concentric circles (tracks) on each disk

• Division of tracks into wedge shaped sectors– A sector holds 512 bytes– Smallest physical storage unit on disk– Sectors are numbered starting with 1

• Numbers of tracks and sectors is standardized

Page 5: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Tracks• 1024 tracks on a side of a platter in a hard disk• 80 tracks per side on a 3.5” HD floppy• Outside track is numbered 0

– Old days innermost track is numbered 1023 (BIOS limitation)

– Large Block Addressing (LBA) tricks the BIOS into handling bigger, more complicated modern disks

• In a stack of platters, the nth track on each side of each platter makes up the nth cylinder– When all heads are in the same position on the disk– Older disk drives would identify a sector by

cylinder/head/sector notation

Page 6: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Sectors

• Outside of disk spins faster than inside.• Old days, fixed number of sectors on a track (63)

– Data density increased towards the center of the disk

• Now, use zoned-bit recording where there are more sectors towards the outside of the disk– The raw data transfer rate is greater on the outside

tracks or zones, and we write to the outside (0th) track first, so drive appears to get slower as it ages!

– Why modern hard drives are low level formatted at the factory

Page 7: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Sectorshttp://www.pctechguide.com/04disks.htm

Any sector can be referenced by its platter number, side number (0 or 1), track and sector numbers

Page 8: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Starting and Ending Head, Sector and Cylinder

• Maximum Formatted Capacity = (sector size) x (sectors per track) x (cylinders) x (heads)

• Ranges of values– Head fields (1 byte) ~ range 0 to 28 – 1 = 256 values– Sector fields (6 bits) ~ range 0 to 26 – 1 = 64 values– Cylinder fileds (10 bits) ~ range 0 to 210 – 1 = 1024 values

• Maximum Formatted Capacity• = (sector size) x (sectors per track) x (cylinders) x (heads)• = 512 x 64 x 1024 x 256• = 29 x 26 x 210 x 28

• = 233

• = 23 x 230

• = 8,455,716,864 = 7.8 GB

Page 9: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

High Level Formatting

• Placing a series of tables, data structures, and code into the first few sectors of the disk

• Master Boot Record (MBR)– In very first sector (cylinder 0, head 0, sector 1)– Contains master partition table– And boot code

Page 10: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Master Boot Record

• Processor always starts executing at the same place on boot

• BIOS loads initial boot program from MBR that starts the process of loading the operating system

• Boot program checks the Partition Table and identifies system partition

• Loads the system’s Partition Boot Sector into memory and transfer control to the executable code in the Partition Boot Sector

Page 11: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Partition Table

• Each entry 16 bytes long• Maximum four entries• Boot Indicator field for x-86 based computers

– RISC computers use the NVRAM contains info on where to boot

• System ID Field – describes the type of file system used to format the volume

Page 12: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Byte offset Field Length Sample Value Meaning

00 1 byte 0x80 Boot Indicator 00 = Do not use for booting

08 = System partition

01 1 byte 0x01 Starting Head

02 6 bits 0x01 Starting Sector

03 10 bits 0x00 Starting Cylinder

04 1 byte 0x06 System ID (volume type)

05 1 byte 0x0F Ending Head

06 6 bits 0x3F Ending Sector

07 10 bits 0x196 Ending Cylinder

08 4 bytes 3F 00 00 00 Relative Sector

12 4 bytes 51 42 06 00 Total Sectors

Partition Table Format

Page 13: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Extended Partitions

• Used when there are more than four partitions• Not used for bootable/system partitions• Can create any number of logical volumes in an

extended partition• The entry in the Partition Table for an extended

partition points to the first sector of the extended partition, which is another Partition Table

Page 14: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Extended Partition Table

• Entries contain:– Current logical drive– Info about the next logical drive– Entries three and four are all zeroes

• Each logical drive has its own Partition Table that points to the next logical drive

Page 15: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

File Allocation Table (FAT)

• The FAT file System is a simple file system.• The File Allocation Table resides at the start of the volume• Duplicate copy maintained for recovery

• In the FAT file system space is allocated in clusters.• The size of the default cluster is determined by the size of

the volume• The cluster number must fit in 16 bits and be a power of 2.

Partition Boot Sector

Fat-1 Fat-2 Duplicate

Root Folder Other folders and files

Page 16: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

Differences Between FAT Systems

System Bytes per Cluster

Cluster Limit

FAT12 1.5 Number of Clusters <= 4087

FAT16 2 4087 <= # Clusters <= 65526

FAT32 4 65526 <= # Clusters <= 268,435,456

Page 17: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

FAT Partition Boot Sector

• The Partition Boot Sector contains information to access the volume

• Fields in Partition Boot Sector

Byte offset Field Length Sample Value Meaning

00 3 bytes EB 3C 90 Jump Instruction

03 8 bytes MSDOS5.0 OEM Name in Text

0B 25 bytes BIOS Parameter Block

24 26 bytes Ext. BIOS Par. Block

3E 448 bytes Bootstrap Code

1FE 2 bytes 0x55AA Sector End Marker

Page 18: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

BIOS Parameter Block and Extended Parameter Block Fields• Contains specific information about the

volume, such as:– Bytes per sector. – Sectors per cluster – Number of reserved sectors before the first

FAT

– Number of FATs. – Number of root directory entries (max limit)

Page 19: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

File Allocation System

• Uses a File Allocation Table to to organize the file system and keep track of cluster usage

• Two copies of the FAT are kept (in older versions of FAT, adjacent to each other, in the same cluster)

• Files are given first available cluster in the partition

• Also uses folders to indicate where in the FAT the info for a file may be

Page 20: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

File Allocation Table Information

• Information on clusters– Unused 0x0000 (free)– Cluster in use by a file– Bad cluster (0xFFF7)– Last cluster in a file (0xFFF8-0xFFFF)

• If a file consists of multiple clusters then the end of the first cluster contains a link to the next cluster in the file.

• Example http://www.ntfs.com/fat-allocation.htm

Page 21: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

FAT Root Folder

• Root folder contains each entry for each file and folder on the root

• At a fixed location

• Fixed size 512 entries for a hard disk

• Other folders contain similar entries but can be anywhere on the disk and have unlimited (relatively) entries

Page 22: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

FAT Folder Structure

• Folder entries include– Name (8+3 characters)– Attribute byte– Creation time– Creation date– Last access date– Last modified time– Last modified date– Starting cluster number in the file allocation table (16

bits)

Page 23: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

FAT Filenames

• Old 8+3 names, eight bits for the name, three bits for the extension

Page 24: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

VFAT

• Longer names are supported but backward FAT compatibility is maintained in VFAT

• Example of conversion and storage– “The quick brown.fox” – 15 + extension– “THEQUI~1.FOX” made up name

• Unicode 2 bytes for each character in the long name

• Windows sets volume, read-only, system, and hidden attributes on log filename entries to get backwards compatible to ignore these fields

Page 25: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

VFAT Long Filename Storage

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

2nd long entry

0x42 w w n n . . f f o o 0x0F 0x00 Cheksum

x x

0x00 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00 0x00 0xFF 0xFF 0xFF 0xFF

1rst long entry

0x01 T T h h e e <sp> <sp> q q 0x0F 0x00 Cheksum

u u

i i c c k k <sp> <sp> b b 0x00 0x00 r r o o

Short Entry

T H E Q U I ~ 1 F O X 0x20 NT Crea te Ti me

Crea Date Last Aces 0x00 0x00 Last Mod. Time

Last Mod. Date

First Cluster

FileS Ize… ……. ……

Page 26: Lecture 9: The FAT and VFAT Filesystems 6/16/2003 CSCE 590 Summer 2003

• http://www.ntfs.com/