Chapter 16. Extended Attributes

This chapter describes extended attributes (EAs), which allow arbitrary metadata, in the form of name-value pairs, to be associated with file i-nodes. EAs were added to Linux in version 2.6.

EAs are used to implement access control lists (Chapter 17) and file capabilities (Chapter 39). However, the design of EAs is general enough to allow them to be used for other purposes as well. For example, EAs could be used to record a file version number, information about the MIME type or character set for the file, or (a pointer to) a graphical icon.

EAs are not specified in SUSv3. However, a similar feature is provided on a few other UNIX implementations, notably the modern BSDs (see extattr(2)) and Solaris 9 and later (see fsattr(5)).

EAs require support from the underlying file system. This support is provided in Btrfs, ext2, ext3, ext4, JFS, Reiserfs, and XFS.

EAs have names of the form namespace.name. The namespace component serves to separate EAs into functionally distinct classes. The name component uniquely identifies an EA within the given namespace.

Four values are supported for namespace: user, trusted, system, and security. These four types of EAs are used as follows:

An i-node may have multiple associated EAs, in the same namespace or in different namespaces. The EA names within each namespace are distinct sets. In the user and trusted namespaces, EA names can be arbitrary strings. In the system namespace, only names explicitly permitted by the kernel (e.g., those used for access control lists) are allowed.

Note

JFS supports another namespace, os2, that is not implemented in other file systems. The os2 namespace is provided to support legacy OS/2 file-system EAs. A process doesn’t need to be privileged in order to create os2 EAs.