7 File Management

Download Report

Transcript 7 File Management

File Management
in
Representative Operating Systems
1
UNIX File Management
• File
– Stream of bytes
– Internal logical structure is application specific
• Types of files
– Ordinary
• Contains information entered by user, application program, or system
utility program
– Directory
• Ordinary file with special protection privileges (file system can write,
user programs can read)
• Contains a list of file names and pointers to the associated index or
information nodes (inodes)
– Special
• Used for I/O devices, each device is associated with a special file
– Named
• Named pipe
CS-550 (M.Soneru): File Management in Representative Operating Systems: [Sta’01]
2
UNIX File Management (cont.)
• Inodes
– Control structure that contains information needed by the OS for a
particular file
– Contents
• File mode: File type, execution flags, access permissions (RWE for
OGO)
• Link count: Number of directory references to this node
• Owner ID: Owner of file
• Group ID: Group owner
• File size: Number of bytes in file
• File address: 39 bytes of address information
• Last accessed: Time of last file access
• Last modified: Time of last file modification
• Inode Modified: Time of last inode modification
CS-550 (M.Soneru): File Management in Representative Operating Systems: [Sta’01]
3
UNIX File Management (cont.)
• File allocation on secondary storage
– Dynamic allocation, on a block basis, non-contiguous
– Indexed method of addressing, with part of the index stored in file’s inode
– Inode has 39 bytes of address information, structured as thirteen 3-byte
pointers (addresses)
• First ten addresses point to the first 10 data blocks
• Eleventh address points to a block on disk that contains the next stage of the
index (single indirect block)
• Twelfth address points to a double indirect block
• Thirteenth address points to a triple indirect block
– Total number of blocks depends on the capacity of the fixed-size blocks in
the system (e.g., in UNIX System V each block has 1Kbyte and can hold
256 block addresses. Total size of a file is 16Gbytes.)
– Advantages
• The inode has a fixed size, is small, and can be kept be in main memory
• Small files can be accessed with no indirection
• The maximum size can accommodate any application
CS-550 (M.Soneru): File Management in Representative Operating Systems: [Sta’01]
4
UNIX File Management (cont.)
CS-550 (M.Soneru): File Management in Representative Operating Systems: [Sta’01]
5
Windows 2000 File Management
• File systems supported
– File Allocation Table (FAT) from Windows 95, MS-DOS, and OS/2
– W2K File System (NTFS)
• NTFS key features
– Recoverability
• Uses transaction processing model to reconstruct disk volumes after failures
• Uses redundant storage for critical system data
– Security
• Security descriptor for each file object defines security attributes
– Large disks and large files
• Supports very large disks and files
– Multiple data streams
• Multiple data streams can be defined for a file
– General indexing facility
• A file can be indexed by any of the attributes associated with the file
CS-550 (M.Soneru): File Management in Representative Operating Systems: [Sta’01]
6
Windows 2000 File Management (cont.)
• NTFS volume and file structure
– Disk storage units
• Sector: Smallest physical storage unit on disk; power of 2 in bytes, usually
512 bytes
• Cluster: One or more contiguous sectors; size in sectors is power of 2
• Volume:
– Logical partition on disk used by file system to allocate storage, one or more
clusters
– Consists of file system information, a collection of files, and any remaining
unallocated space on the volume
– Can be a portion or an entire single disk, or can extend across multiple disks
– Maximum size: 2e64
– Cluster is the fundamental unit of allocation
• System is configured initially with a certain number of sectors per cluster
• Use of clusters allows the use of non-standard disks, with sectors different
from 512 bytes
• Maximum file size is 2e32, which represents 2e48 bytes
CS-550 (M.Soneru): File Management in Representative Operating Systems: [Sta’01]
7
Windows 2000 File Management (cont.)
• NTFS volume layout
– Every element on a volume is a file and every file consists of a collection of
attributes
– Regions on the NTFS volume
• Partition boot sector
– Information about the volume layout and the file system structures
– Boot startup information and code
• Master File Table (MFT)
–
–
–
–
Information about all the files and folders (directories) on this volume
Information about available unallocated space
Organized as a table of variable-length rows, called records
Each row describes a file or folder on this MFT and contains
» Attributes for the file or folder (e.g., file name, access rights, time stamps)
» Pointers to clusters containing file
• System files region
–
–
–
–
MFT2: duplicate of the first three rows of MFT
Log file: list of transaction steps for file recoverability
Cluster bit map: volume representation, showing which clusters are in use
Attribute definition table: defines the attribute types supported on this volume
CS-550 (M.Soneru): File Management in Representative Operating Systems: [Sta’01]
8
Windows 2000 File Management (cont.)
• Recoverability
– The file system can be recovered to a consistent state following a system crash or disk
failure
– Elements that support recoverability
• I/O manager
– NTFS driver: provides the basic open, close, read, write functions
– Fault-tolerant driver (FTDISK) provides the software RAID functionality
• Log file service
– Maintains a log of disk writes
– Used to recover volume after a system failure
• Cache manager
– Caches file reads and writes for improved performance (lazy write and lazy commit)
• Virtual memory manager
– Cached file are accessed by mapping file references to virtual memory references and reading and
writing virtual memory
– Logging is the main technique used to implement recoverability
• Each operation that changes the file system is treated as a transaction
• Transactions are recorded in a log file
• Partially completed transactions can be redone or undone after recovery
CS-550 (M.Soneru): File Management in Representative Operating Systems: [Sta’01]
9
Windows 2000 File Management (cont.)
CS-550 (M.Soneru): File Management in Representative Operating Systems: [Sta’01]
10