1XATTR(7)                   Linux Programmer's Manual                  XATTR(7)
2
3
4

NAME

6       xattr - 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).
16       They are often used to provide additional functionality to  a  filesys‐
17       tem—for  example,  additional  security features such as Access Control
18       Lists (ACLs) may be implemented using extended attributes.
19
20       Users with search access to a file or directory may use listxattr(2) to
21       retrieve a list of attribute names defined for that file or directory.
22
23       Extended  attributes  are  accessed  as atomic objects.  Reading (getx‐
24       attr(2)) retrieves the whole value of an attribute and stores it  in  a
25       buffer.  Writing (setxattr(2)) replaces any previous value with the new
26       value.
27
28       Space consumed for extended attributes may be counted towards the  disk
29       quotas of the file owner and file group.
30
31   Extended attribute namespaces
32       Attribute names are null-terminated strings.  The attribute name is al‐
33       ways specified in the fully qualified namespace.attribute form, for ex‐
34       ample,  user.mime_type, trusted.md5sum, system.posix_acl_access, or se‐
35       curity.selinux.
36
37       The namespace mechanism is used to define different classes of extended
38       attributes.  These different classes exist for several reasons; for ex‐
39       ample, the permissions and capabilities required for  manipulating  ex‐
40       tended attributes of one namespace may differ to another.
41
42       Currently,  the  security, system, trusted, and user extended attribute
43       classes are defined as described  below.   Additional  classes  may  be
44       added in the future.
45
46   Extended security attributes
47       The  security  attribute  namespace is used by kernel security modules,
48       such as Security Enhanced Linux, and also to implement  file  capabili‐
49       ties (see capabilities(7)).  Read and write access permissions to secu‐
50       rity attributes depend on the policy implemented for each security  at‐
51       tribute by the security module.  When no security module is loaded, all
52       processes have read access to extended security attributes,  and  write
53       access is limited to processes that have the CAP_SYS_ADMIN capability.
54
55   System extended attributes
56       System  extended  attributes are used by the kernel to store system ob‐
57       jects such as Access Control Lists.  Read and write access  permissions
58       to  system  attributes depend on the policy implemented for each system
59       attribute implemented by filesystems in the kernel.
60
61   Trusted extended attributes
62       Trusted extended attributes are visible and  accessible  only  to  pro‐
63       cesses  that  have  the  CAP_SYS_ADMIN  capability.  Attributes in this
64       class are used to implement mechanisms in user space (i.e., outside the
65       kernel) which keep information in extended attributes to which ordinary
66       processes should not have access.
67
68   User extended attributes
69       User extended attributes may be assigned to files and  directories  for
70       storing arbitrary additional information such as the mime type, charac‐
71       ter set or encoding of a file.  The access  permissions  for  user  at‐
72       tributes  are  defined  by the file permission bits: read permission is
73       required to retrieve the attribute value, and writer permission is  re‐
74       quired to change it.
75
76       The  file  permission  bits of regular files and directories are inter‐
77       preted differently from the file permission bits of special  files  and
78       symbolic  links.  For regular files and directories the file permission
79       bits define access to the file's contents,  while  for  device  special
80       files  they  define access to the device described by the special file.
81       The file permissions of symbolic links are not used in  access  checks.
82       These  differences would allow users to consume filesystem resources in
83       a way not controllable by disk quotas for group or world writable  spe‐
84       cial files and directories.
85
86       For  this reason, user extended attributes are allowed only for regular
87       files and directories, and access to user extended  attributes  is  re‐
88       stricted  to  the  owner and to users with appropriate capabilities for
89       directories with the sticky bit set (see the chmod(1) manual  page  for
90       an explanation of the sticky bit).
91
92   Filesystem differences
93       The  kernel  and  the filesystem may place limits on the maximum number
94       and size of extended attributes that can be  associated  with  a  file.
95       The  VFS  imposes limitations that an attribute names is limited to 255
96       bytes and an attribute value is limited to 64 kB.  The list  of  attri‐
97       bute  names  that can be returned is also limited to 64 kB (see BUGS in
98       listxattr(2)).
99
100       Some filesystems, such as Reiserfs (and, historically, ext2 and  ext3),
101       require  the  filesystem to be mounted with the user_xattr mount option
102       in order for user extended attributes to be used.
103
104       In the current ext2, ext3, and ext4 filesystem implementations, the to‐
105       tal  bytes used by the names and values of all of a file's extended at‐
106       tributes must fit in a single filesystem  block  (1024,  2048  or  4096
107       bytes,  depending  on  the block size specified when the filesystem was
108       created).
109
110       In the Btrfs, XFS, and Reiserfs filesystem implementations, there is no
111       practical  limit on the number of extended attributes associated with a
112       file, and the algorithms used to store extended  attribute  information
113       on disk are scalable.
114
115       In  the JFS, XFS, and Reiserfs filesystem implementations, the limit on
116       bytes used in an EA value is the ceiling imposed by the VFS.
117
118       In the Btrfs filesystem implementation, the total bytes  used  for  the
119       name,  value,  and  implementation  overhead  bytes  is  limited to the
120       filesystem nodesize value (16 kB by default).
121

CONFORMING TO

123       Extended attributes are not specified in POSIX.1, but some  other  sys‐
124       tems (e.g., the BSDs and Solaris) provide a similar feature.
125

NOTES

127       Since  the  filesystems  on  which extended attributes are stored might
128       also be used on architectures with a different byte order  and  machine
129       word  size, care should be taken to store attribute values in an archi‐
130       tecture-independent format.
131
132       This page was formerly named attr(5).
133

SEE ALSO

135       attr(1), getfattr(1), setfattr(1), getxattr(2), ioctl_iflags(2), listx‐
136       attr(2),    removexattr(2),   setxattr(2),   acl(5),   capabilities(7),
137       selinux(8)
138

COLOPHON

140       This page is part of release 5.10 of the Linux  man-pages  project.   A
141       description  of  the project, information about reporting bugs, and the
142       latest    version    of    this    page,    can     be     found     at
143       https://www.kernel.org/doc/man-pages/.
144
145
146
147Linux                             2020-06-09                          XATTR(7)
Impressum