Professional Documents
Culture Documents
Contents
Part I ....................................................................................................................................................... 4 1. 2. 3. 4. 5. 6. 7. 8. 9. 9.1. 9.2. 9.3. 9.4. 9.5. Abstract ....................................................................................................................................... 4 Introduction and history .............................................................................................................. 4 File System Concepts ................................................................................................................... 4 Apple Partitioning Scheme .......................................................................................................... 4 Disk Arbitration............................................................................................................................ 5 File Descriptors ........................................................................................................................... 5 Disk Images ................................................................................................................................. 5 Virtual File System Layer............................................................................................................. 5 File System Types........................................................................................................................ 6 MS-DOS ....................................................................................................................................... 6 New Technology File System ...................................................................................................... 6 Universal Disk Format ................................................................................................................ 6 Apple filing Protocol .................................................................................................................. 6 Hierarchical File System Plus ..................................................................................................... 6
Part II ...................................................................................................................................................... 7 10. 10.1. 10.2. 10.3. 10.4. 10.5. 10.6. 10.6.1. 10.6.2. 10.6.3. 10.6.4. 10.6.5. 10.7. 10.7.1. 10.7.2. Hierarchical File System Plus Filing System ............................................................................... 7 Features .................................................................................................................................... 7 Structure of HFS+ file system .................................................................................................... 7 Reserved Areas.......................................................................................................................... 8 Volume Header ......................................................................................................................... 8 HFS Wrapper ............................................................................................................................. 8 Special files ................................................................................................................................ 8 Allocation File ............................................................................................................................ 8 Catalog File ................................................................................................................................ 8 Extent Overflow File .................................................................................................................. 9 Attribute File ............................................................................................................................. 9 Startup File ................................................................................................................................ 9 Examining HFS+ features ......................................................................................................... 9 Case Sensitivity.......................................................................................................................... 9 File Encoding .......................................................................................................................... 10
10.7.3. 10.7.4. 10.7.5. 10.7.6. 10.7.7. 10.8. 10.8.1. 10.8.2. 11. 12.
Repairing Permission .............................................................................................................. 10 Quotas ..................................................................................................................................... 10 Hardlinks ................................................................................................................................. 10 Aliases and Symbolic Links ..................................................................................................... 10 Resource Forks: ...................................................................................................................... 10 Optimization ........................................................................................................................... 11 On-the Fly Defragmentation .................................................................................................. 11 Hot File Clustering .................................................................................................................. 11 Comparison of HFS+, NTFS and AFP ................................................................................... 11 Conclusion .............................................................................................................................. 11
References .............................................................................................................................................. 12
Part I 1. Abstract
File System of an operating system provides a conceptual view of data on storage devices used by computer systems. Like any other computer system, Apple computers store data in a hard disk drive which are divided into sectors and addressed using Logical Block Addressing (LBA). Disks are further divided into partitions. Partitions contain volume, which is an instance of file system. pdisk command is used in Apple partitioning system to view the partition tables of a disk. Mac OS X is an extensively used modern Operating System. This paper deals with the file system of the apple computers with the spotlight mainly on the HFS Plus File System, a favorite file system type of the Mac OS X. A comparison is made at the end of the paper between the various file systems implemented by the Mac OS X based on the task achieved by them.
their first two bytes alongside with partitions storing offset, size and type. Any amount of partitions can be formed that would fit in the partition map.
5. Disk Arbitration
Mac OS X Disk Arbitration maintains disks. It is done by diskarbitrationd() and DiskArbitration.FrameWork. System call diskarbitrationd() is the central authority for disk management. Disk Arbitration framework identifies a disk, participates in some mounting decisions and interacts with IO Kit regarding notifications. This framework presents API which accomplish following functions of controlling disk objects. DADiskMount()- mount the volume at the given disk DADiskUnmount()- unmount the volume at the given disk DADiskEject()- ejects the given disk DADiskRename()- volume is renamed at the given disk DADiskGetOptions()- to get disk options DADiskSetOptions()- to set disk options DADiskClaim()- disk is claimed to use exclusively DADiskUnclaim()- disk is unclaimed
6. File Descriptors
File descriptors correspond to the open files. They take action as an index into process file descriptor table in the kernel. These descriptors are used in the system calls. Following are their Mac OS Xs file descriptors along with their type. DTYPE_VNODE - struct node DTYPE_SOCKET - struct socket DTYPE_PSXSHM - struct pshmnode DTYPE_PSXDEM - struct psemnode DTYPE_KQUEUE - struct kqueue DTYPE_PIPE - struct pipe DTYPE_FSEVENTS - struct fsevent_handle
7. Disk Images
There is risk in every activity. Similarly, file system has their jeopardy of losing entire data. For this, virtual disks or disk images are used. These disk images act very similar to their physical counterparts. Mac OS X comprises a framework DiskImages.framework. This provides wide-ranging support for disk images.
Vfs_mount()- implement the mount() system call. Vfs_start()- any operation that the file system wishes is started after the mount() is successfully performed. Vfs_unmount()- implements the unmount() system call. Vfs_root()- retrieves the root node of the file system. Vfs_getattr()- vfs_attributes are populated with file system attributes Vfs_statfs()- file system statistics are obtained.
9.1.
MS-DOS
Mac OS X support FAT alternative of MS-DOS file system. This file system is not loaded into kernel but is present as a loadable kernel extension.
9.2.
Mac OS X includes read-only support for New Technology File system (NTFS). NTFS file system driver is hearted on free BSD NTFS driver. This is also not compiled into the kernel but loaded by mount_ntfs() when required.
9.3.
Universal Disk Format (UDF) is the file system used by DVD-ROM disks and CDs. It is implemented as a kernel extension and loaded by mount_udf () when required.
9.4.
Apple Filing Protocl (AFP) is a session based protocol used by networked computers to share files. User Authentication Method (UAM) is used by systems to validate other systems on the network.
9.5.
Hierarchical File System Plus (HFS+) is the much preferred file system of the Mac OS X. It is also called as Extended File System. Its predecessor is HFS. It is very rich in features and uses a B-Tree based Catalog file to store and maintain the file systems hierarchical structure.
Part II 10. Hierarchical File System plus Filing System 10.1. Features
Provide storage for file of size up to the range of 2^63 bytes in size. Name encoding is made based on Unicode character set (range 255 16 bit characters which are stored in decomposed form). Indexing is based on the B+ tree structure which is hierarchical. The extents that outnumber the specified values are stored in the B+ tree. The size of the extended attribute is limited to 4 KB. B+ tree stores the arbitrary metadata. A File object can employ means like aliases, hard link and symbolic link to refer to another file. Hot File Clustering method is adopted to adaptively look up frequently accused files. To maintain continuity, dynamic relocation of small fragmented files is performed from time to time. File permission are applied in UNIX. File flags are BSD based which designate file as append-only, immutable and undeletable. Supports volume-level user and group quotas. Metadata stores finder information of a file to make certain per-file properties like fileextension hiding and color-coded labels. Method call searchfs() performs search for file object based on given search criteria. Numerous time-stamps are stored for a single file system object. Case sensitivity is achieved. Dedicated startup files which can be used by non-Mac OS X to boot from HFS+ volume.
**These special files need not be in contiguous locations and are not user-visible and hence they do not contribute to the total count of files on volume header.
10.4. Volume Header After the first reserved area present is the volume header. It is 512 bytes in size. This contains information about other data structures. While other structure changes location; volume header has a fixed one. It is at a fixed offset from the start. Alternate volume header stores disk and file system repair utilities. Volume header contains extent of HFS+ B Trees and other files. Kernel block called Volume Control Block (VCB) holds volume header info once as HFS+ volume is mounted. It also stores dynamic information about the volume.
It is basically to track if an allocation block is being used. It is a bit map structure i.e., when a block is holding user data or assigned to file system data structure, the respective bit is set in allocation blocks. Since allocation file is also a file, it itself occupies some blocks. This file has the property of being grown or shrunk and so space can be flexibly manipulated based on the use. hfsdebug is used to view contents of the file.
10.6.2.
Catalog File
This file contains the vital information about all files and folders and also acts as their catalog. The file and folder names are stored as HFSUnistr 255 structure which consists of a length and
255-element double byte Unicode character array. The files and folders are identified by a unique Catalog Node ID (CNID). Catalog files are organized as B-Tree which gives way for quick and efficient searching. Each file has 2 leaf records in catalog file. File record, File thread record and each folder has Folder record, Folder thread records. File Record (HFS+CatalogFile) has standard file metadata like files CNID, time stamps, Unix-style permission, finder information and initial extents of files data. Folder Record: (HFS+CatalogFolder) has standard folder metadata but has no data. Every folder has a valence value representing the number of files and immediate subdirectories. HFSPlusCatalogThread represent file and folder thread records. A record contains name and parent CNID of the catalog node it represents. Thread records represent the hierarchical structure of the file systems by threading together the qualified organization of files and folders.
10.6.3.
Allocation of storage to a file can be non-contiguous. A file record in catalog has space for holding each extent record for the corresponding file data resource forks. If a fork has more than 8 fragments, its remaining extents are stored in leaf nodes of Extent Overflow File. The data structure associated with Extent Overflow File is HFSplusExtentRecord. Its keys are fixed and structure consists of forktype, fileID and startBlock attributes.
10.6.4.
Attribute File
Attribute file sits in the implementation of named forks. Named forks are associated with files or folders and are used to implement extended attributes for files and folder. ACL in Mac OS X 10.4 uses extended attributes store ACL data attached to files and folders. All extended attribute contain Name (Unicode string in decomposed and canonical order) and random data. Mac OS X 10.4 supports only values that will fit in B-Tree. This file uses HFSPlusAttrKey structure which included fileIO, startBlock and AttrName. System calls Setattr(), getxattr(), listattr(), removeattr() are used to operate on file names.
10.6.5.
Startup File
HFS+ supports an optional startup file that contains secondary bootloader while booting the system. The location of startup file is at well-known position a fixed offset from volume header. So there is no necessity to have built in HFS+ support mechanism like the one used for HFS wrapper.
10.7.2.File Encoding
Unicode encoding done for files, folders and extended attributes. This consists of 16-bit length with up to 255 double-byte Unicode characters. These characters are fully decomposed with the composing characters in canonical order. When strings between HFS+ and user space are exchanged, they are encoded by kernel as ASCII compatible UTI 8 bytes. Older Mac OS encoded using Apple only text encoding likes MacGreek, MacRoman etc.
10.7.3.Repairing Permission
Sometimes, there may happen an unintended or misbehaving application that corrupts permission. This problem is handled by Mac OS X with the help of bill of materials (bom) that is installed along with each package. This bom contains all files along with its metadata (File Unix Permission). Bom files are used by tools that repair permission to get the original permission.
10.7.4.Quotas
HFS+ supports volume level quotas based on user and group IDs. The catalog node structure contains an array of disk quota usage records. The array contains 2 elements in MAC OS X10.4 one for user quotas and one for group quotas. Quota filenames are .quota.user and .quota.group. Each file contains a header followed by hash table of structures specifying various quota limits and usage values for user or group IDs.
10.7.5. Hardlinks
They are special features represented by link count value of which will indicate the type of relationship between files. Values of for link count will denote that two files have different pathnames but refer to same physical file on disk. Value of 2 denotes that two files are equivalent. Mac OS X implementation of hard links uses a special file called hard-link file for each directory entry.
10.8. Optimization
The Mac OS X HFS+ implements adaptive optimization in order to improve performance and reduce fragmentation. HFS+ employs following mechanisms to achieve optimization. 1. On-the Fly Defragmentation 2. Hot File Clustering
12. Conclusion
Hence, we have gained an insight about the functioning of the Mac OS X file system and its default file system type. Analyzing all the features, it is quite obvious that files in Mac OS X are handled in a very different and efficient way which has paved way for its popularity. Huge file size with a strong file system mechanism is what is expected from a computer system. Having achieved the latter, it is time to device a huge storage at the lowest cost which forms the hardware part of the system.
References
1. www.developer.apple.com 2. Amit Singh, 2006. Mac OS X Internals : A systems Approach 3. www.Mac-fourm.com