Chapter 12. The HFS Plus File System


The HFS Plus file system (or simply HFS+) is the preferred and default volume format on Mac OS X. The term HFS stands for Hierarchical File System, which replaced the flat Macintosh File System (MFS) used in early Macintosh operating systems. HFS remained the primary volume format for Macintosh systems before Mac OS 8.1, which was the first Apple operating system to support HFS+. Also called the Mac OS X Extended volume format, HFS+ is architecturally similar to HFS but provides several important benefits over the latter.[1] Moreover, HFS+ itself has evolved greatly since its inceptionnot so much in fundamental architecture but in its implementation. In this chapter, we will discuss features and implementation details of HFS+ in Mac OS X.

[1] Two of the major limitations in HFS were that it was largely single threaded and that it supported only 16-bit allocation blocks.

Looking Back

Apple filed a patent for the Macintosh Hierarchical File System (U.S. Patent Number 4,945,475) in late 1989. The patent was granted in mid-1990. The original HFS was implemented using two B-Tree data structures: the Catalog B-Tree and the Extents B-Tree. As we will see in this chapter, HFS+ uses both of these B-Trees. Lisa OSthe operating system for Apple's Lisa computer (1983)used a hierarchical file system before the Macintosh. Indeed, the HFS volume format benefited from work done on the Lisa's file system.

As we noted in Chapter 11, one hallmark of HFS was that it lent support to the graphical user interface by providing a separate data stream in a filethe resource forkfor storing application icons, resources, and other auxiliary data independently of the file's "main" data.


Noteworthy features of HFS+ include the following:

  • Support for files up to 263 bytes in size

  • Unicode-based file/directory name encoding, with support for names containing up to 255 16-bit Unicode characters[2]

    [2] HFS+ stores Unicode characters in canonical, fully decomposed form.

  • A B+ Tree (the Catalog B-Tree) for storing the file system's hierarchical structure, allowing tree-based indexing

  • Extent-based allocation of storage space using 32-bit allocation block numbers, with delayed allocation of physical blocks

  • A B+ Tree (the Extents Overflow B-Tree) for recording files' "overflow" extents (the ninth and subsequentfor files with more than eight extents)

  • Multiple byte-streams (or forks) per file, with two predefined forks and an arbitrary number of other, named forks that are stored in a separate B-Tree (see next item).

  • A B+ Tree (the Attributes B-Tree) for storing arbitrary metadata[3] per file, thus providing native support for extended file system attributes (the names of which are Unicode strings up to 128 16-bit Unicode characters in length)

    [3] The size of the data associated with a single extended attribute is limited to slightly less than 4KB in Mac OS X 10.4.

  • Metadata journaling through the kernel's VFS-level journaling mechanism

  • Multiple mechanisms to allow one file system object to refer to another: aliases, hard links, and symbolic links

  • An adaptive clustering scheme called Hot File Clustering for improving the performance of small, frequently accessed files

  • Dynamic relocation of small fragmented filesbased on several conditionsto promote file contiguity

  • Native support for access control lists (ACLs), with ACLs being stored as extended attributes

  • Unix-style file permissions

  • BSD-style file flags, allowing files to be designated as append-only, immutable, undeletable, and so on

  • Support for volume-level user and group quotas

  • Provision for storing Finder information in a file system object's metadata, allowing per-file maintenance of properties such as file-extension hiding and color-coded labels

  • Support for the searchfs() system call, which searches a volume for file system objects matching the given criteria (e.g., object name, Finder information, and modification date)

  • Provision for storing multiple timestamps per file system object, including an explicit creation date

  • Support for case sensitivity (although by default, HFS+ is case-preserving but not case-sensitive)

  • The dedicated Startup file, whose location is stored at a fixed offset in the volume header (allowing it to be found without having to know details of the volume format) and which can be used by a nonMac OS X operating system to boot from an HFS+ volume

  • Support for byte-range and whole-file advisory locking[4]

    [4] HFS+ does not implement lockingit uses the locking implemented in the kernel's VFS layer.

HFS+ does not support sparse files. However, it does support deferred zeroing of ranges of a file that have never been written. Such ranges are marked invalid until they are physically writtenfor example, because of a sync operation.


We will discuss most of these features in this chapter.




Mac OS X Internals. A Systems Approach
Mac OS X Internals: A Systems Approach
ISBN: 0321278542
EAN: 2147483647
Year: 2006
Pages: 161
Authors: Amit Singh

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net