Fork (filesystem)

From Wikipedia, the free encyclopedia

Jump to: navigation, search

In computer file systems, a fork is additional data associated with a file system object. A file system might support only one fork per file or might support multiple named forks. Unlike extended attributes, which are typically limited in size, a fork can be of arbitrary size, possibly even larger than the file's data.

Contents

[edit] Apple

Apple's HFS, and the original Apple Macintosh file system MFS, allowed a file to have a resource fork. The contents of a file's resource fork is essentially a simple relational database, making it ideal for the organized storage of many small pieces of data without the overhead of a file system.

The resource fork was designed to store metadata that would be used by the system's graphical user interface (GUI), such as a file's icon to be used by the Finder or the menus and dialog boxes associated with an application.[1] However the feature was very flexible, so additional uses were found, such as splitting a word processing document into content and presentation, then storing the presentation information in the resource fork.

One of HFS+'s more obscure features is that a file may have an arbitrary number of custom “named forks” in addition to the traditional data and resource forks. This feature has gone largely unused, as Apple never added support for it under Mac OS 8.1-10.3.9. Beginning with 10.4, a partial implementation was made to support Apple's extended inline attributes.

[edit] Other implementations

File system forks are traditionally associated with Apple's Hierarchical File System (HFS),[2] but are also available in other file systems. In Microsoft's NTFS they are known as Alternate Data Streams (ADS).[3] Other filesystems such as Novell's Novell Storage Services (NSS) and NetWare File System (NWFS), Solaris's UFS (in Solaris 9 and later)[4] and ZFS, and Veritas Software's Veritas File System (VxFS) also support file system forks. In Solaris they are known as extended attributes, although they can be as large as a file and are accessed in the same way a file's data is and thus behave like a fork. UDF, being a universal file system for general data exchange, supports forks as well.

Starting in 1985, NWFS and its successor NSS were designed from the ground up to use a variety of methods to store a file's metadata. Some metadata resides in Novell Directory Services (NDS), some is stored in the directory structure on the disk, and some is stored in, as Novell terms it, 'multiple data streams' with the file itself. Multiple data streams also allow Macintosh clients to attach to and use NetWare servers.

In 1993, Microsoft released the first version of the Windows NT operating system which introduced the NTFS filesystem. This filesystem includes support for multiple named forks as alternate data streams for compatibility with pre-existing operating systems that support forks. With Windows 2000, Microsoft started using alternate data streams in NTFS to store things such as author or title file attributes[5] and image thumbnails.[6] With Service Pack 2 for Windows XP, Microsoft introduced the Attachment Execution Service that stores details on the origin of downloaded files in alternate data streams attached to files, in an effort to protect users from downloaded files that may present a risk.[7]

[edit] Possible security and data loss risks with incomplete software

When a filesystem supports different forks, the applications should be aware of them, or security risks can arise. Allowing Legacy software to access data without appropriate shims in place is the primary culprit for such problems.

If the different system utilities (disk explorer, antivirus software, archivers, and so on), are not aware of the different forks, the following problems can arise:

  • The user will never know the presence of any alternate fork nor the total size of the file, just of the main data fork.
  • Computer viruses can hide in alternate forks on Windows and never get detected if the antivirus software is not aware of forks.
  • Data can be lost when sending files via fork-unaware channels, such as e-mail, filesystems without support for forks, or even when copying files between filesystems with forks support if the program that made the copy does not support forks or when compressing files with software that does not support forks.

Windows NT versions include the ability to use forks in the API, and some command line tools can be used to create and access forks, but they are ignored by most programs, including Windows Explorer and the DIR command. Windows Explorer copies forks and warns when the target file system doesn't support them, but only counts the main fork's size and it doesn't list a file or folder's streams. The DIR command has been updated in Vista to include an option that will list forks.[8]

Until Mac OS X v10.4, users running the legacy Unix command line utilities (such as tar) included with Mac OS X would risk data loss, as the utilities were not updated to handle the resource forks of files until v10.4[9].

[edit] See also

[edit] References

  1. ^ Bruce Horn. "The Grand Unified Model (1) - Resources". Folklore.org. http://folklore.org/StoryView.py?project=Macintosh&story=The_Grand_Unified_Model.txt. Retrieved on 2006-11-18. 
  2. ^ Apple (1996-07-02). "File Forks". Apple. http://developer.apple.com/documentation/mac/Files/Files-14.html. Retrieved on 2006-11-18. 
  3. ^ Microsoft. "Files and Clusters". Microsoft. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/files_and_clusters.asp. Retrieved on 2006-11-18. 
  4. ^ Sun. "What's New in the Solaris 9 8/03 Operating Environment: File System Enhancements". Sun. http://docs.sun.com/app/docs/doc/817-0493/6mg9pruau?a=view. Retrieved on 2006-11-18. 
  5. ^ Dino Esposito (March 2000). "A Programmer's Perspective on NTFS 2000 Part 1: Stream and Hard Link". Microsoft. http://msdn2.microsoft.com/en-us/library/ms810604.aspx. Retrieved on 2006-11-18. 
  6. ^ Microsoft (2006-10-27). "Indexing service adds data streams to image files". Microsoft. http://support.microsoft.com/kb/319300. Retrieved on 2006-11-18. 
  7. ^ Bart De Smet (2005-08-19). "Demo of "Attachment Execution Service internals" in Windows XP SP2 and Windows Server 2003 SP1". B# .NET Blog. http://community.bartdesmet.net/blogs/bart/archive/2005/08/19/3485.aspx. Retrieved on 2006-11-18. 
  8. ^ Bart De Smet (2006-07-13). "Use Vista's DIR command to display alternate data streams". B# .NET Blog. http://bartdesmet.net/blogs/bart/archive/2006/07/13/4129.aspx. Retrieved on 2007-07-07. 
  9. ^ "Command-line Backup Solutions on Mac OS X". Apple. 2005-10-29. http://developer.apple.com/macosx/backuponmacosx.html. Retrieved on 2006-11-18. 

[edit] External links

Personal tools