Jump to content

HFS Plus: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Simplify iPod link
Add ''Design and implementation'' section
Line 1: Line 1:
'''HFS Plus''' or '''HFS+''' is a [[file system]] developed by [[Apple Computer]] to replace their [[Hierarchical File System]] (HFS) as the primary file system used on [[Apple Macintosh|Macintosh]] computers. It is also one of the formats used by the [[iPod]] hard-disk based music player. HFS Plus was introduced with the [[January 19]] [[1998]] release of [[Mac OS 8|Mac OS 8.1]]. HFS Plus is the name used by developers, but in user documentation the format is referred to as '''Mac OS Extended'''.
'''HFS Plus''' or '''HFS+''' is a [[file system]] developed by [[Apple Computer]] to replace their [[Hierarchical File System]] (HFS) as the primary file system used on [[Apple Macintosh|Macintosh]] computers. It is also one of the formats used by the [[iPod]] hard-disk based music player.
==History==
HFS Plus was introduced with the [[January 19]] [[1998]] release of [[Mac OS 8|Mac OS 8.1]]. HFS Plus is the name used by developers, but in user documentation the format is referred to as '''Mac OS Extended'''.


HFS Plus is an improved version of HFS, supporting much larger files (64 bit length instead of 32 bit) and using [[Unicode]] (instead of [[MacRoman]]) for naming the items (files, folders). HFS Plus permits filenames up to 255 characters in length, and n-forked files similar to [[NTFS]], though access to forks other than the [[data fork]] and [[resource fork]] requires use of separate APIs, for backward compatibility with HFS. HFS Plus also uses a full 32-bit allocation mapping table, rather than HFS's 16 bits. This was a serious limitation of HFS, meaning that no disk could support more than 65,536 sectors under HFS. When disks were small, this was of little consequence, but as they started to approach the 1GB mark, it meant that the smallest amount of space that any file could occupy (a single sector) became excessively large, wasting significant amounts of disk space. For example, on a 1GB disk, the sector size under HFS is 16KB, so even a 1-byte file would take up 16K of disk space.
HFS Plus is an improved version of HFS, supporting much larger files (64 bit length instead of 32 bit) and using [[Unicode]] (instead of [[MacRoman]]) for naming the items (files, folders). HFS Plus permits filenames up to 255 characters in length, and n-forked files similar to [[NTFS]], though access to forks other than the [[data fork]] and [[resource fork]] requires use of separate APIs, for backward compatibility with HFS. HFS Plus also uses a full 32-bit allocation mapping table, rather than HFS's 16 bits. This was a serious limitation of HFS, meaning that no disk could support more than 65,536 sectors under HFS. When disks were small, this was of little consequence, but as they started to approach the 1GB mark, it meant that the smallest amount of space that any file could occupy (a single sector) became excessively large, wasting significant amounts of disk space. For example, on a 1GB disk, the sector size under HFS is 16KB, so even a 1-byte file would take up 16K of disk space.
Line 7: Line 11:
With the release of the [[Mac OS X 10.2|10.2.2]] update on [[November 11]] [[2002]], Apple added optional journaling features to HFS Plus for improved data reliability. These features were easily accessible in [[Mac OS X]] Server, but only accessible through the command line in the standard desktop client. However, in [[2003]] Mac OS X version 10.3 set all HFS Plus volumes on all Macs to be journaled by default.
With the release of the [[Mac OS X 10.2|10.2.2]] update on [[November 11]] [[2002]], Apple added optional journaling features to HFS Plus for improved data reliability. These features were easily accessible in [[Mac OS X]] Server, but only accessible through the command line in the standard desktop client. However, in [[2003]] Mac OS X version 10.3 set all HFS Plus volumes on all Macs to be journaled by default.


==Design and implementation==
==External link==


HFS Plus volumes are divided into sectors (called logical blocks in HFS), that are usually 512 bytes in size. These sectors are then grouped together into allocation blocks which can contain one or more sectors; the number of allocation blocks depends on the total size of the volume. HFS Plus uses a larger value to address allocation blocks than HFS, 32 bits rather than 16 bits; this means it can access 4,294,967,296 allocation blocks rather than the 65,536 allocation blocks available to HFS.

Typically an HFS Plus volume is embedded inside an '''HFS Wrapper'''. The wrapper was designed for two purposes. It allowed Macintosh computers without HFS Plus support in their ROM to boot HFS Plus volumes. It also was designed to help users transition to HFS Plus, by including a minimal HFS volume with a read-only file called ''Where_have_all_my_files_gone?'', explaining to users with versions of the Mac OS without HFS Plus, that the volume requires a system with HFS Plus support.

There are nine structures that make up a typical HFS Plus volume:

# Sectors 0 and 1 of the volume are HFS '''boot blocks'''. These are identical to the boot blocks in an HFS volume. They are part of the HFS wrapper.

# Sector 2 contains the '''Volume Header''' equivalent to the Master Directory Block in an HFS volume. The Volume Header stores a wide variety of data about the volume itself, for example the size of allocation blocks, a timestamp that indicates when the volume was created or the location of other volume structures such as the Catalog File or Extent Overflow File. The Volume Header is always located in the same place.

# The '''Allocation File''' which keeps track of which allocation blocks are free and which are in use. It is similar to the Volume Bitmap in HFS, each allocation block is represented by one bit. A zero means the block is free and a one means the block is in use. The main difference with the HFS Volume Bitmap, is that the Allocation File is stored as a regular file, it does not occupy a special reserved space near the beginning of the volume. The Allocation File can also change size and does not have to be stored contiguously within a volume.

# The '''Catalog File''' is a [[B-tree]] that contains records for all the files and directories stored in the volume. The HFS Plus Catalog File is very similar to the [[Hierarchical File System#Catalog File|HFS Catalog File]], the main differences being records are larger to allow more fields and to allow for those fields to be larger (for example to allow the longer 255-character unicode file names in HFS Plus). A record in the HFS Catalog File is 512 bytes in size, a record in the HFS Plus Catalog File is 4KB in Mac OS and 8KB in Mac OS X. Fields in HFS are of fixed size, in HFS Plus the size can vary depending on the actual size of the data they store.

# The '''Extents Overflow File''' is another [[B-Tree]] that records the allocation blocks that are allocated to each file as extents. Each file record in the Catalog File is capable of recording eight extents for each fork of a file, once those are used extents are recorded in the Extents Overflow File. Bad blocks are also recorded as extents in the Extents Overflow File. The default size of an extent record in Mac OS is 1KB and 4KB in Mac OS X.

# The '''Attributes File''' is a new B-tree in HFS Plus that does not have a corresponding structure in HFS. The Attributes File can store three different types of 4KB records ''Inline Data Attribute'' records (which are not currently used but reserved for future use), ''Fork Data Attribute'' records and ''Extension Attribute'' records. Fork Data Attribute records contain references to extents that hold large attributes. Extension Attributes are used to extend a Fork Data Attribute record when its eight extent records are already used.

# The '''Startup File''' is designed for non-Mac OS systems that don't have HFS or HFS Plus support. It is similar to the Boot Blocks of an HFS volume.

# The second to last sector contains the '''Alternate Volume Header''' equivalent to the Alternate Master Directory Block of HFS.

# The last sector in the volume is reserved for use by Apple. It is used during the computer manufacturer process.

==External link==
*[http://developer.apple.com/technotes/tn/tn1150.html Technote 1150 HFS Plus Volume Format] from apple.com
*[http://developer.apple.com/technotes/tn/tn1150.html Technote 1150 HFS Plus Volume Format] from apple.com



Revision as of 17:01, 4 December 2004

HFS Plus or HFS+ is a file system developed by Apple Computer to replace their Hierarchical File System (HFS) as the primary file system used on Macintosh computers. It is also one of the formats used by the iPod hard-disk based music player.

History

HFS Plus was introduced with the January 19 1998 release of Mac OS 8.1. HFS Plus is the name used by developers, but in user documentation the format is referred to as Mac OS Extended.

HFS Plus is an improved version of HFS, supporting much larger files (64 bit length instead of 32 bit) and using Unicode (instead of MacRoman) for naming the items (files, folders). HFS Plus permits filenames up to 255 characters in length, and n-forked files similar to NTFS, though access to forks other than the data fork and resource fork requires use of separate APIs, for backward compatibility with HFS. HFS Plus also uses a full 32-bit allocation mapping table, rather than HFS's 16 bits. This was a serious limitation of HFS, meaning that no disk could support more than 65,536 sectors under HFS. When disks were small, this was of little consequence, but as they started to approach the 1GB mark, it meant that the smallest amount of space that any file could occupy (a single sector) became excessively large, wasting significant amounts of disk space. For example, on a 1GB disk, the sector size under HFS is 16KB, so even a 1-byte file would take up 16K of disk space.

Like HFS, HFS Plus uses B-trees to store most volume metadata.

With the release of the 10.2.2 update on November 11 2002, Apple added optional journaling features to HFS Plus for improved data reliability. These features were easily accessible in Mac OS X Server, but only accessible through the command line in the standard desktop client. However, in 2003 Mac OS X version 10.3 set all HFS Plus volumes on all Macs to be journaled by default.

Design and implementation

HFS Plus volumes are divided into sectors (called logical blocks in HFS), that are usually 512 bytes in size. These sectors are then grouped together into allocation blocks which can contain one or more sectors; the number of allocation blocks depends on the total size of the volume. HFS Plus uses a larger value to address allocation blocks than HFS, 32 bits rather than 16 bits; this means it can access 4,294,967,296 allocation blocks rather than the 65,536 allocation blocks available to HFS.

Typically an HFS Plus volume is embedded inside an HFS Wrapper. The wrapper was designed for two purposes. It allowed Macintosh computers without HFS Plus support in their ROM to boot HFS Plus volumes. It also was designed to help users transition to HFS Plus, by including a minimal HFS volume with a read-only file called Where_have_all_my_files_gone?, explaining to users with versions of the Mac OS without HFS Plus, that the volume requires a system with HFS Plus support.

There are nine structures that make up a typical HFS Plus volume:

  1. Sectors 0 and 1 of the volume are HFS boot blocks. These are identical to the boot blocks in an HFS volume. They are part of the HFS wrapper.
  1. Sector 2 contains the Volume Header equivalent to the Master Directory Block in an HFS volume. The Volume Header stores a wide variety of data about the volume itself, for example the size of allocation blocks, a timestamp that indicates when the volume was created or the location of other volume structures such as the Catalog File or Extent Overflow File. The Volume Header is always located in the same place.
  1. The Allocation File which keeps track of which allocation blocks are free and which are in use. It is similar to the Volume Bitmap in HFS, each allocation block is represented by one bit. A zero means the block is free and a one means the block is in use. The main difference with the HFS Volume Bitmap, is that the Allocation File is stored as a regular file, it does not occupy a special reserved space near the beginning of the volume. The Allocation File can also change size and does not have to be stored contiguously within a volume.
  1. The Catalog File is a B-tree that contains records for all the files and directories stored in the volume. The HFS Plus Catalog File is very similar to the HFS Catalog File, the main differences being records are larger to allow more fields and to allow for those fields to be larger (for example to allow the longer 255-character unicode file names in HFS Plus). A record in the HFS Catalog File is 512 bytes in size, a record in the HFS Plus Catalog File is 4KB in Mac OS and 8KB in Mac OS X. Fields in HFS are of fixed size, in HFS Plus the size can vary depending on the actual size of the data they store.
  1. The Extents Overflow File is another B-Tree that records the allocation blocks that are allocated to each file as extents. Each file record in the Catalog File is capable of recording eight extents for each fork of a file, once those are used extents are recorded in the Extents Overflow File. Bad blocks are also recorded as extents in the Extents Overflow File. The default size of an extent record in Mac OS is 1KB and 4KB in Mac OS X.
  1. The Attributes File is a new B-tree in HFS Plus that does not have a corresponding structure in HFS. The Attributes File can store three different types of 4KB records Inline Data Attribute records (which are not currently used but reserved for future use), Fork Data Attribute records and Extension Attribute records. Fork Data Attribute records contain references to extents that hold large attributes. Extension Attributes are used to extend a Fork Data Attribute record when its eight extent records are already used.
  1. The Startup File is designed for non-Mac OS systems that don't have HFS or HFS Plus support. It is similar to the Boot Blocks of an HFS volume.
  1. The second to last sector contains the Alternate Volume Header equivalent to the Alternate Master Directory Block of HFS.
  1. The last sector in the volume is reserved for use by Apple. It is used during the computer manufacturer process.

External link