Extended file attributes explained

Extended file attributes are file system features that enable users to associate computer files with metadata not interpreted by the filesystem, whereas regular attributes have a purpose strictly defined by the filesystem (such as permissions or records of creation and modification times). Unlike forks, which can usually be as large as the maximum file size, extended attributes are usually limited in size to a value significantly smaller than the maximum file size. Typical uses include storing the author of a document, the character encoding of a plain-text document, or a checksum, cryptographic hash or digital certificate, and discretionary access control information.

In Unix-like systems, extended attributes are usually abbreviated as xattr.

Implementations

AIX

In AIX, the JFS2 v2 filesystem supports extended attributes, which are accessible using the command.[1] The,[2],[3],[4],[5] and [6] APIs support fetching, setting, listing, getting information about, and removing extended attributes.

BeOS/Haiku

In the now-defunct BeOS and successors like Haiku, extended file attributes are widely used in base and third-party programs. The Be File System allows the indexing and querying of attributes, essentially giving the filesystem database-like characteristics. The uses of extended attributes in Be-like systems are varied: For example, Tracker and OpenTracker, the file-managers of BeOS and Haiku respectively, both store the locations of file icons in attributes,[7] Haiku's "Mail" service stores all message content and metadata in extended file attributes,[8] and the MIME types of files are stored in their attributes. Extended file attributes can be viewed and edited in Be-like systems' GUI through the file-manager, often Tracker or derivatives thereof.

FreeBSD

In FreeBSD 5.0 and later, the UFS1, UFS2, and ZFS filesystems support extended attributes, using the family of system calls. Any regular file may have a list of extended attributes. Each attribute consists of a name and the associated data. The name must be a null-terminated string, and exists in a namespace identified by a small-integer namespace identifier. Currently, two namespaces exist: user and system. The user namespace has no restrictions with regard to naming or contents. The system namespace is primarily used by the kernel for access control lists and mandatory access control.

Linux

In Linux, the ext2, ext3, ext4, JFS, Squashfs, UBIFS, Yaffs2, ReiserFS, Reiser4, XFS, Btrfs, OrangeFS, Lustre, OCFS2 1.6, ZFS, and F2FS[9] filesystems support extended attributes (abbreviated xattr) when enabled in the kernel configuration. Any regular file or directory may have extended attributes consisting of a name and associated data. The name must be a null-terminated string prefixed by a namespace identifier and a dot character. Currently, four namespaces exist: user, trusted, security and system. The user namespace has no restrictions with regard to naming or contents. The system namespace is primarily used by the kernel for access control lists. The security namespace is used by SELinux, for example.

Support for the extended attribute concept from a POSIX.1e draft that had been withdrawn[10] in 1997 was added to Linux around 2002.[11] [12] As of 2016, they are not yet in widespread use by user-space Linux programs, but are used by Beagle, OpenStack Swift, Dropbox, KDE's semantic metadata framework (Baloo), Chromium, Wget and cURL.

The Linux kernel allows extended attribute to have names of up to 255 bytes and values of up to 64 KiB,[13] as do XFS and ReiserFS, but ext2/3/4 and btrfs impose much smaller limits, requiring all the attributes (names and values) of one file to fit in one "filesystem block" (usually 4 KiB). Per POSIX.1e, the names are required to start with one of security, system, trusted, and user plus a period. This defines the four namespaces of extended attributes.

Extended attributes can be accessed and modified using the getfattr and setfattr commands from the attr package on most distributions.[14] The APIs are called and .

macOS

Mac OS X 10.4 and later support extended attributes by making use of the HFS+ filesystem Attributes File B*-tree feature which allows for named forks. Although the named forks in HFS+ support arbitrarily large amounts of data through extents, the OS support for extended attributes only supports inline attributes, limiting their size to that which can fit within a single B*-tree node. Any regular file may have a list of extended attributes. HFS+ supports an arbitrary number of named forks, and it is unknown if macOS imposes any limit on the number of extended attributes.

Each attribute consists of a name and the associated data. The name is a null-terminated Unicode string. No namespace restrictions are present (making this an open xattr system) and the convention is to use a reverse DNS string (similar to Uniform Type Identifiers) as the attribute name.

macOS supports listing, getting, setting, and removing extended attributes from files or directories using a Linux-like API. From the command line, these abilities are exposed through the xattr utility.

Since macOS 10.5, files originating from the web are marked with com.apple.quarantine via extended file attributes.[15] In some older versions of macOS (such as Mac OS X 10.6), user space extended attributes were not preserved on save in common Cocoa applications (TextEdit, Preview etc.).

OpenBSD

Support for extended file attributes was removed from the OpenBSD source code in 2005 due to a lack of interest in Access Control Lists.[16]

OS/2

In OS/2 version 1.2 and later, the High Performance File System was designed with extended attributes in mind, but support for them was also retro-fitted on the FAT filesystem of DOS.For compatibility with other operating systems using a FAT partition, OS/2 attributes are stored inside a single file "" located in the root directory. This file is normally inaccessible when an operating system supporting extended attributes manages the disk, but can be freely manipulated under, for example, DOS. Files and directories having extended attributes use one or more clusters inside this file. The logical cluster number of the first used cluster is stored inside the owning file's or directory's directory entry.[17] These two bytes are used for other purposes on the FAT32 filesystem, and hence OS/2 extended attributes cannot be stored on this filesystem.

Parts of OS/2 version 2.0 and later such as the Workplace Shell uses several standardized extended attributes (also called EAs) for purposes like identifying the filetype, comments, computer icons and keywords about the file.Programs written in the interpreted language Rexx store an already parsed version of the code as an extended attribute, to allow faster execution.

Solaris

Solaris version 9 and later allows files to have "extended attributes", which are actually forks; the maximum size of an "extended attribute" is the same as the maximum size of a file, and they are read and written in the same fashion as files. Internally, they are actually stored and accessed like normal files, so their names cannot contain "/" characters and their ownership and permissions can differ from those of the parent file.

Version 4 of the Network File System supports extended attributes in much the same way as Solaris.

Windows NT

On Windows NT, limited-length extended attributes are supported by FAT,[17] HPFS, and NTFS. This was implemented as part of the OS/2 subsystem. They are notably used by the NFS server of the Interix POSIX subsystem in order to implement Unix-like permissions. The Windows Subsystem for Linux added in the Windows 10 Anniversary Update uses them for similar purposes, storing the Linux file mode, owner, device ID (if applicable), and file times in the extended attributes.[18]

Additionally, NTFS can store arbitrary-length extended attributes in the form of alternate data streams (ADS), a type of resource fork. Plugins for the file manager Total Commander, like NTFS Descriptions and QuickSearch eXtended support filtering the file list by or searching for metadata contained in ADS.[19] [20] NTFS-3G supports mapping ADS to extended attributes in FUSE; it also maps file attributes that way.[21]

See also

Notes and References

  1. Web site: getea Command. IBM AIX V7.2 documentation. IBM. 2017-07-11.
  2. Web site: getea Subroutine. IBM AIX V7.2 documentation: Base Operating System and Extensions, Volume 1. IBM. 2017-07-11.
  3. Web site: setea Subroutine. IBM AIX V7.2 documentation: Base Operating System and Extensions, Volume 2. IBM. 2017-07-11.
  4. Web site: listea Subroutine. IBM AIX V7.2 documentation: Base Operating System and Extensions, Volume 1. IBM. 2017-07-11.
  5. Web site: statea Subroutine. IBM AIX V7.2 documentation: Base Operating System and Extensions, Volume 2. IBM. 2017-07-11.
  6. Web site: removeea Subroutine. IBM AIX V7.2 documentation: Base Operating System and Extensions, Volume 2. IBM. 2017-07-11.
  7. Web site: Attributes . Haiku User Guide . Haiku, Inc. . 28 January 2021.
  8. Web site: Workshop: Managing Emails . Haiku User Guide . Haiku, Inc. . 28 January 2021.
  9. Web site: [PATCH 13/16] f2fs: add xattr and acl functionalities]. Jaegeuk. Kim. 2012-10-05. 2017-07-11.
  10. Posix.1e? . Casey . Schaufler . 2002-04-30 . comp.security.unix.
  11. Web site: v2.5.3 git commit log. 2002-02-05. 2017-07-11.
  12. Web site: Red Hat Enterprise Linux AS 3 Release Notes (x86 Edition). EA (Extended Attributes) and ACL (Access Control Lists) functionality is now available for ext3 file systems. In addition, ACL functionality is available for NFS.. 2003. Red Hat. https://web.archive.org/web/20170709142229/https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/Release_Notes/as-x86/index.html. 2017-07-09. dead. 2017-07-11.
  13. Web site: linux/include/uapi/linux/limits.h. 2012-10-13. 2017-07-11.
  14. Web site: Commands for Manipulating Filesystem Extended Attributes. GNU Savannah. 2017-07-11.
  15. Web site: Launch Services Release Notes . developer.apple.com.
  16. Web site: CVS log for src/sys/ufs/ufs/Attic/extattr.h . 2005-07-03. Dale Rahn.
  17. Web site: Implementation of extended attributes on the FAT file system. Bob. Eager. 2000-10-28. 2017-07-11.
  18. Web site: WSL File System Support. Jack. Hammons. 2016-06-15. MSDN. 2017-07-11.
  19. Web site: NTFS Descriptions 1.2.1. TotalCmd.net. 16 April 2018.
  20. Web site: QuickSearch eXtended. TotalCmd.net. 16 April 2018.
  21. Web site: Extended Attributes . Tuxera . https://web.archive.org/web/20200814021136/https://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/ . 2020-08-14 . dead.