<<

Chapter 10-11 File Systems file offset pointer per- current-file-position pointer

Mac OS/X files resource o data type o creator type data fork

Unix files magic number o executable file o batch file – shell script file extensions – provides hint but is not controlling as to use sequence of 8-bit bytes

Text files – ascii Executable files – relocatable object code – tables or relocatable addresses

Internal File Structure – Disk Systems sector size  block size disk I/O is done in units of blocks blocks are all the same size disks have no external fragmentation blocks may have internal fragmentation packing data into blocks -- may eliminate internal (block) fragmentation but may make data more difficult to locate packing data into bytes – unrelated to current topic, e.g., see binary coded decimals

Disk System Partitions -- segregate portions of the disk system for File Systems o Structures o Files -- Swap Space Raw Disk Space

Remark: A may span multiple disks as long as they, the disks, are included in one partition

File System Structure I/O transfers of data between memory and disk – blocks block contains some number of sectors sector size consists of some multiple of 32 bytes, normally 512 bytes frame, page and frames are normally sized such blocks and frames contain some multiple of one another and thus there is no inter-media fragmentation

Levels 0. I/O Control -- device drivers

Device Controller physical block (translates) specific bit patterns information -- written to specified drive, cylinder, memory locations or track, sector registers disk

1. Basic File System

Manages

Memory Buffers Transfer Data Block Transfer Data Block & Data Caches (in-use) (in-reserve)

file-system data, directory data

Transmits

2. File-Organization Module possibly used by multiple file systems Logical Block Information

Physical Block Information File Allocation Information Free-Space Manager – tracks unallocated blocks (UFS) derived from the Berkeley Fast File System (FFS)

3. Logical File System Windows XP File Name with FAT, FAT32, Manages NTFS (Windows NT File System)

Meta-Data , File Structure supports 40+ other file systems

File-Control Block (FCB), i.e., UNIX ownership, permissions, location of file contents, last modification date protection security partition == volume == file system storage space On-Disk Structures

Boot Control Block UFS – boot block; NTFS – partition boot sector o one per partition o information necessary to boot from the partition o may be empty, i.e., there is no operating system on the volume o normally it is the first block of a volume

Volume Control Block UFS – superblock; NTFS – stored as part of the Master File Table o one per partition o number of blocks in par tition o block size o free-block count o free-block pointers o free-FCB (inode) count o FCB (inode) pointers

Directory Structure o one per file system o UFS – file names & associated inode numbers o NTFS – stored as part of the Master File Table

File Control Block (FCB), i.e., Unix inode structure o one per file o details about the file o unique identifier (Unix inode) number  directory entry (Unix inode number) o NTFS – stored as part of the Master File Table (relational database, one row per file)

In-Memory Structures

Mount Table o contains information about each mounted volume Directory-Structure Cache o holds directory information about recently accessed directories System-Wide -File Table o contains a copy of the FCB, i.e., inode, of each open file Per-Process Open-File Table o contains a pointer to the appropriate entry in the System-Wide Open-File Table I/O Memory Buffers o hold file-system blocks while they are being from or written to disk

File Creation application process requests the creation of a new file logical file system allocates a new FCB, i.e., inode structure, the FCB is either o allocated from free memory or o selected from a pre-allocated set of free-FCB, i.e., free- appropriate directory is updated with the new file name and FCB, i.e., inode Directories Unix – directories are treated as files containing special data Windows – directories differently from files; they require a separate set of systems calls to create, manipulate, etc

Operations open( ) o search System-Wide Open-File Table to see if file is currently in use . if it is, create a Per-Process Open-File table entry pointing to the existing System-Wide Open-File Table . if it is not, search the directory for the file name; once found, place the FCB in the System-Wide Open-File Table o make an entry, i.e., Unix , Windows file handle in the Per-Process Open-File Table, with pointers to the entry in the System-Wide Open-File Table and other fields which include a pointer to the current location in the file and the access mode in which the file is open o increment the open cont in the System-Wide Open-File Table o returns a pointer to the appropriate entry in the Per-Process Open-File Table o all subsequent operations are performed with this pointer

P0 Per-Process Open-File Table fp0 P5 offset pointer status information File Control Block, i.e., Unix inode

System-Wide Open-File Table (Unix UFS Directory System) P0 and P1 data location access mode information File Control creation/modification date Block, i.e., Unix inode open count (files currently accessing)

P17

File Control P1 Per-Process Open-File Table fp1 Block, i.e., offset pointer Unix inode status information

process closes file  Per-Process Open-File Table entry is removed; open count decremented all processes file  copy in-memory directory information to disk and System-Wide Open-File Table is removed from memory Unix i-node System

inode 34 data Unix Directory

inode “number”

proj1 34

midterm 65 data notes6July 108

data

data

data

Unix (UFS) System-Wide Open-File Table holds inodes for files, directories, devices, and network connections

inode numbering system is only unique within a given file system across file systems, the use of a pointer is required

Mounting File Systems Boot Block – series of sequential blocks containing a memory image of a program, call the boot loader, that locates and mounts the root partition; the partition contains the kernel; the boot loader locates, loads, and starts the kernel executing In-memory mount table – external file systems must be mounted on devices, the mount table records the mount points, types of file systems mounted, and an access path to the desired file system

Unix – the in-memory mount table contains a pointer to the superblock of the file system on that device

Virtual File System inode object -- vnodes file object superblock object dentry object