1ATTR(5)                       File Formats Manual                      ATTR(5)
2
3
4

NAME

6       attr - Extended attributes
7

DESCRIPTION

9       Extended  attributes  are  name:value pairs associated permanently with
10       files and directories, similar to the  environment  strings  associated
11       with  a  process.   An attribute may be defined or undefined.  If it is
12       defined, its value may be empty or non-empty.
13
14       Extended attributes are extensions to the normal attributes  which  are
15       associated with all inodes in the system (i.e. the stat(2) data).  They
16       are often used to provide additional functionality to  a  filesystem  -
17       for  example, additional security features such as Access Control Lists
18       (ACLs) may be implemented using extended attributes.
19
20       Users with search access to a file or directory may retrieve a list  of
21       attribute names defined for that file or directory.
22
23       Extended  attributes are accessed as atomic objects.  Reading retrieves
24       the whole value of an attribute and stores it  in  a  buffer.   Writing
25       replaces any previous value with the new value.
26
27       Space consumed for extended attributes is counted towards the disk quo‐
28       tas of the file owner and file group.
29
30       Currently, support for extended attributes is implemented on  Linux  by
31       the ext2, ext3, ext4, XFS, JFS and reiserfs filesystems.
32

EXTENDED ATTRIBUTE NAMESPACES

34       Attribute  names  are  zero-terminated  strings.  The attribute name is
35       always specified in the fully qualified namespace.attribute  form,  eg.
36       user.mime_type,   trusted.md5sum,   system.posix_acl_access,  or  secu‐
37       rity.selinux.
38
39       The namespace mechanism is used to define different classes of extended
40       attributes.   These  different  classes exist for several reasons, e.g.
41       the permissions and capabilities  required  for  manipulating  extended
42       attributes of one namespace may differ to another.
43
44       Currently  the  security,  system, trusted, and user extended attribute
45       classes are defined as described below. Additional classes may be added
46       in the future.
47
48   Extended security attributes
49       The  security  attribute  namespace is used by kernel security modules,
50       such as Security Enhanced Linux.  Read and write access permissions  to
51       security  attributes depend on the policy implemented for each security
52       attribute by the security module.  When no security module  is  loaded,
53       all  processes  have  read  access to extended security attributes, and
54       write access is limited to processes that have the CAP_SYS_ADMIN  capa‐
55       bility.
56
57   Extended system attributes
58       Extended  system  attributes  are  used  by  the kernel to store system
59       objects such as Access Control Lists and Capabilities.  Read and  write
60       access  permissions  to  system  attributes depend on the policy imple‐
61       mented for each system attribute implemented by filesystems in the ker‐
62       nel.
63
64   Trusted extended attributes
65       Trusted  extended  attributes  are  visible and accessible only to pro‐
66       cesses that have the CAP_SYS_ADMIN capability (the super  user  usually
67       has  this  capability).  Attributes in this class are used to implement
68       mechanisms in user space (i.e., outside the kernel) which keep informa‐
69       tion in extended attributes to which ordinary processes should not have
70       access.
71
72   Extended user attributes
73       Extended user attributes may be assigned to files and  directories  for
74       storing arbitrary additional information such as the mime type, charac‐
75       ter set or  encoding  of  a  file.  The  access  permissions  for  user
76       attributes are defined by the file permission bits.
77
78       The  file  permission  bits of regular files and directories are inter‐
79       preted differently from the file permission bits of special  files  and
80       symbolic  links.  For regular files and directories the file permission
81       bits define access to the file's contents,  while  for  device  special
82       files  they  define access to the device described by the special file.
83       The file permissions of symbolic links are not used in  access  checks.
84       These  differences would allow users to consume filesystem resources in
85       a way not controllable by disk quotas for group or world writable  spe‐
86       cial files and directories.
87
88       For  this reason, extended user attributes are only allowed for regular
89       files and directories,  and  access  to  extended  user  attributes  is
90       restricted  to the owner and to users with appropriate capabilities for
91       directories with the sticky bit set (see the chmod(1) manual  page  for
92       an explanation of Sticky Directories).
93

FILESYSTEM DIFFERENCES

95       The  kernel  and  the filesystem may place limits on the maximum number
96       and size of extended attributes that can be  associated  with  a  file.
97       Some  file systems, such as ext2/3 and reiserfs, require the filesystem
98       to be mounted with the user_xattr mount option in  order  for  extended
99       user attributes to be used.
100
101       In  the  current  ext2,  ext3 and ext4 filesystem implementations, each
102       extended attribute must fit on a single filesystem block (1024, 2048 or
103       4096  bytes,  depending on the block size specified when the filesystem
104       was created).
105
106       In the XFS and reiserfs filesystem implementations, there is no practi‐
107       cal  limit on the number or size of extended attributes associated with
108       a file, and the algorithms used to store extended attribute information
109       on disk are scalable.
110
111       In  the JFS filesystem implementation, names can be up to 255 bytes and
112       values up to 65,535 bytes.
113

ADDITIONAL NOTES

115       Since the filesystems on which extended  attributes  are  stored  might
116       also  be  used on architectures with a different byte order and machine
117       word size, care should be taken to store attribute values in an  archi‐
118       tecture independent format.
119

AUTHORS

121       Andreas Gruenbacher, <a.gruenbacher@bestbits.at> and the SGI XFS devel‐
122       opment team, <linux-xfs@oss.sgi.com>.
123

SEE ALSO

125       getfattr(1), setfattr(1).
126
127
128
129                                                                       ATTR(5)
Impressum