Fork (filesystem)

From Wikipedia, the free encyclopedia

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.

File system forks are traditionally associated with Apple's Hierarchical File System (HFS),[1] but are also available in other file systems. In Microsoft's NTFS they are known as Alternate Data Streams (ADS).[2] Other filesystems such as Novell's Novell Storage Services (NSS) and NetWare File System (NWFS), Solaris's UFS (in Solaris 9 and later)[3] 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.

Apple's HFS, and the original Apple Macintosh file system MFS, were designed to allow a file to have a resource fork 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.[4] However the feature was not limited to GUI data, 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 particular non-obvious use is that prior to Mac OS X, PostScript Type 1 fonts have traditionally been stored entirely in the resource fork, the data fork being empty[5]. In addition, old 680x0 applications had all of their code in the resource fork as 32K segments which were loaded on demand[6].

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[7] and image thumbnails.[8] 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.[9]

Contents

[edit] Possible security and data loss risks with forks

When a filesystem supports different forks, the applications should be aware of them, or security risks can arise.

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 are 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.[10] Until Mac OS X v10.4, users using the 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[11].

[edit] See also

[edit] References

  1. ^ Apple (July 2, 1996). File Forks. Apple. Retrieved on 2006-11-18.
  2. ^ Microsoft. Files and Clusters. Microsoft. Retrieved on 2006-11-18.
  3. ^ Sun. What's New in the Solaris 9 8/03 Operating Environment: File System Enhancements. Sun. Retrieved on 2006-11-18.
  4. ^ Bruce Horn. The Grand Unified Model (1) - Resources. Folklore.org. Retrieved on 2006-11-18.
  5. ^ Adobe (July 7, 2004). PostScript Type 1 and Type 3 Fonts General Information. Adobe. Retrieved on 2006-11-18.
  6. ^ Andy Hertzfeld. RMaker. Folklore.org. Retrieved on 2006-11-18.
  7. ^ Dino Esposito (March 2000). A Programmer's Perspective on NTFS 2000 Part 1: Stream and Hard Link. Microsoft. Retrieved on 2006-11-18.
  8. ^ Microsoft (October 27, 2006). Indexing service adds data streams to image files. Microsoft. Retrieved on 2006-11-18.
  9. ^ Bart De Smet (August 19, 2005). Demo of "Attachment Execution Service internals" in Windows XP SP2 and Windows Server 2003 SP1. B# .NET Blog. Retrieved on 2006-11-18.
  10. ^ Bart De Smet (July 13, 2006). Use Vista's DIR command to display alternate data streams. B# .NET Blog. Retrieved on 2007-07-07.
  11. ^ Command-line Backup Solutions on Mac OS X. Apple (October 29, 2005). Retrieved on 2006-11-18.

[edit] External links