14: Filesystem Examples: CD-ROM, MS-DOS,...

Post on 26-Jan-2020

17 views 0 download

Transcript of 14: Filesystem Examples: CD-ROM, MS-DOS,...

1

14: Filesystem Examples:CD-ROM, MS-DOS, Unix

Mark Handley

CD Filesystems

ISO 9660Rock Ridge Extensions

Joliet Extensions

2

ISO 9660: CD-ROM Filesystem

CD is divided into logical blocks of 2352 bytes. 2048 bytes of payload per block, after preambles, error

correction, etc CD-ROM starts with 16 unspecified blocks, Then one block containing primary volume descriptor

system id, volume id, publisher id, etc where to find root directory

Each directory consists of a variable number of entries. A flagindicates the last one.

No more than 8 levels of directory nesting.

An ISO 9660 Directory Entry

Files are contiguous, so only need starting block and file size. Separate bytes for year, month, day, hour, min, sec, timezone. L: filename length. Filename: 8.3 uppercase format for basename.ext followed by

; then version (1 or 2 binary bytes). Last: optional system use field.

Bytes

3

CD-ROM Extensions

Rock Ridge Designed to allow Unix

filesystems to be stored, Uses “system use” field, so

is backward compatible. PX - POSIX attributes

permissions, etc PN - device numbers SL - symbolic link NM - alternative name CL, PL, RE - relocation TF - time stamps

Joliet Designed to allow

Microsoft filesystems to bestored on CD. Long names: 128 chars Unicode Directory nesting

greater than 8 levels Directory names with

extensions.

MS-DOS Filesystem

Extension for larger disksExtension for better metadata

Extension for unicode and longer filenames.

4

MS-DOS

Uses a FAT filesystem.Derived from earlier CP/M filesystem

3 versions, depending on number of bits in blockaddress:FAT-12 has 12-bit block addressesFAT-16 has 16-bit block addressesFAT-32 has 28-bit block addresses

MS-DOS

Original FAT-12 used 12-bit block addresses with 512 byteblocks: 2MB max partition, FAT table requires 4096 entries of 2

bytes each in memory. Good for floppy drives and 640K RAM.

Use of bigger block sizes, and up to four partitions per drivestretched FAT-12 to 64MB disks.

FAT-16 introduced with 16-bit block addresses. Max 64K blocks of 32KBytes each => 2GB per partition. FAT requires 128KBytes of RAM.

Windows 95-SE introduced FAT-32.

5

MS-DOS: Maximum Partition Sizes

MS-DOS Directory Entry

Fixed size: 32 bytes. Attributes: read-only, needs to be archived, hidden, system file. Date and Time file was last modified

± 2 seconds accuracy, rollover in 2108 First disk block of file - remainder found via FAT. Max file size: 2GB

Base name Ext file sizelast moddate/time

8 3 1 4 410 2

Attributes First blocknumber

Reserved

6

The Windows 98 Directory Entry

The extended MS-DOS directory entry used in Windows 98:

Creation date/time, separate from Last Modified date/time,and accurate to 10ms (via sec field)

Last Access date (but not time) NT compatible filesystem case sensitivity. Extra 16 bits block index needed for FAT-32.

Base name ExtNT

file sizelast moddate/time

Creationdate/time

lastacces

8 3 1 4 211 4 42 2

Attributes Sec upper 16 bitsof first file block

lower 16 bitsof first file block

Windows 98 (Extension) Directory Entry

An entry for part of a long file name in Windows 98 Characters are unicode, so take 2 bytes each. A complete directory entry has one 8.3 ASCII MS-DOS

compatible base directory entry and multiple extensionentries containing the long unicode filename.

Checksum is for backwards compatibility: detects file deletion/readdition on old systems.

0 2 characterslast moddate/time

Creationdate/time

lastacces

10 1 1211 42

Attributes(0x0F)

Checksum

06 characters5 characters

1

Sequence

7

Windows 98: Storing Long Filenames

An example of how a long name is stored in Windows 98

Base name Ext A SNT

file sizelast moddate/time

Creationdate/time

lastacces

8 3 1 4 211 4 42 2

high lo

0 2 characterslast moddate/time

Creationdate/time

lastacces

10 1 1211 42

06 characters5 characters

1

A SNT

file sizelast moddate/time

Creationdate/time

lastacces

high lo

0last moddate/time

Creationdate/time

lastacces 01

0last moddate/time

Creationdate/time

lastacces 02

0last moddate/time

Creationdate/time

lastacces 067

THI TXT~1ISS

T i sh

y l o n

m !e

i as

g f i l

v

e

e r

n astoredfirst

storedlast

“This is a very long filename!.TXT” == THISIS~1.TXT

Unix Filesystem

Version 7 FilesystemBSD FFS extensions

Linux filesystem structure

8

UNIX File System

Disk layout in classical UNIX systems

9

The UNIX V7 File System:

A Directory Entry

System 7 released January 1979 Filenames limited to 14 characters. All metadata is stored in the i-node, not in the directory.

The UNIX V7 File System:

i-nodes and indirect blocks

10

The UNIX V7 File System:

Locating a File

The steps in looking up /usr/ast/mbox

The UNIX File System:

A Single Directory Hierarchy

Before mounting.

/

a

c

b

/

d

p q r

x y z

/

a

c d

p q r

x y z

bb

Hard Disk CD-ROM Unified Filesystem

After mounting

11

System Calls for File Management

s is an error code fd is a file descriptor position is a file offset

UNIX File System (2)

Structure of an i-node

12

The stat() System Callint stat(const char *path, struct stat *sb);struct stat { dev_t st_dev; /* device inode resides on */ ino_t st_ino; /* inode's number */ mode_t st_mode; /* inode protection mode */ nlink_t st_nlink; /* number or hard links to the file */ uid_t st_uid; /* user-id of owner */ gid_t st_gid; /* group-id of owner */ dev_t st_rdev; /* device type, for special file inode */ struct timespec st_atimespec; /* time of last access */ struct timespec st_mtimespec; /* time of last data modification */ struct timespec st_ctimespec; /* time of last file status change */ off_t st_size; /* file size, in bytes */ quad_t st_blocks; /* blocks allocated for file */ u_long st_blksize; /* optimal file sys I/O ops blocksize */ u_long st_flags; /* user defined flags for file */ u_long st_gen; /* file generation number */ };

System Calls for Directory Management

s is an error code dir identifies a directory stream dirent is a directory entry

13

UNIX File System:

File Descriptors

The relation between the file descriptor table, the openfile description, the inode, and the file.

BSD Filesystem Directories

A BSD directory with three files The same directory after the file voluminous has been

removed

14

The Linux Ext2 File System

Directory Structure is very similar to BSD FFS. Disk layout differs: block groups rather than cylinder

groups.