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
33       always specified in the fully qualified namespace.attribute  form,  for
34       example,  user.mime_type,  trusted.md5sum,  system.posix_acl_access, or
35       security.selinux.
36
37       The namespace mechanism is used to define different classes of extended
38       attributes.   These  different  classes  exist for several reasons; for
39       example, the permissions and  capabilities  required  for  manipulating
40       extended 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
51       attribute  by  the security module.  When no security module is loaded,
52       all processes have read access to  extended  security  attributes,  and
53       write  access is limited to processes that have the CAP_SYS_ADMIN capa‐
54       bility.
55
56   System extended attributes
57       System extended attributes are used  by  the  kernel  to  store  system
58       objects  such  as  Access Control Lists.  Read and write access permis‐
59       sions to system attributes depend on the policy  implemented  for  each
60       system attribute implemented by filesystems in the kernel.
61
62   Trusted extended attributes
63       Trusted  extended  attributes  are  visible and accessible only to pro‐
64       cesses that have the  CAP_SYS_ADMIN  capability.   Attributes  in  this
65       class are used to implement mechanisms in user space (i.e., outside the
66       kernel) which keep information in extended attributes to which ordinary
67       processes should not have access.
68
69   User extended attributes
70       User  extended  attributes may be assigned to files and directories for
71       storing arbitrary additional information such as the mime type, charac‐
72       ter  set  or  encoding  of  a  file.   The  access permissions for user
73       attributes are defined by the file permission bits: read permission  is
74       required  to  retrieve  the  attribute  value, and writer permission is
75       required to change it.
76
77       The file permission bits of regular files and  directories  are  inter‐
78       preted  differently  from the file permission bits of special files and
79       symbolic links.  For regular files and directories the file  permission
80       bits  define  access  to  the file's contents, while for device special
81       files they define access to the device described by the  special  file.
82       The  file  permissions of symbolic links are not used in access checks.
83       These differences would allow users to consume filesystem resources  in
84       a  way not controllable by disk quotas for group or world writable spe‐
85       cial files and directories.
86
87       For this reason, user extended attributes are allowed only for  regular
88       files  and  directories,  and  access  to  user  extended attributes is
89       restricted to the owner and to users with appropriate capabilities  for
90       directories  with  the sticky bit set (see the chmod(1) manual page for
91       an explanation of the sticky bit).
92
93   Filesystem differences
94       The kernel and the filesystem may place limits on  the  maximum  number
95       and  size  of  extended  attributes that can be associated with a file.
96       The VFS imposes limitations that an attribute names is limited  to  255
97       bytes  and  an  attribute  value  is  limited  to  64 kB.   The list of
98       attribute names that can be returned is also limited to 64 kB (see BUGS
99       in listxattr(2)).
100
101       Some  filesystems, such as Reiserfs (and, historically, ext2 and ext3),
102       require the filesystem to be mounted with the user_xattr  mount  option
103       in order for user extended attributes to be used.
104
105       In  the  current  ext2,  ext3, and ext4 filesystem implementations, the
106       total bytes used by the names and values of all of  a  file's  extended
107       attributes  must  fit  in a single filesystem block (1024, 2048 or 4096
108       bytes, depending on the block size specified when  the  filesystem  was
109       created).
110
111       In the Btrfs, XFS, and Reiserfs filesystem implementations, there is no
112       practical limit on the number of extended attributes associated with  a
113       file,  and  the algorithms used to store extended attribute information
114       on disk are scalable.
115
116       In the JFS, XFS, and Reiserfs filesystem implementations, the limit  on
117       bytes used in an EA value is the ceiling imposed by the VFS.
118
119       In  the  Btrfs  filesystem implementation, the total bytes used for the
120       name, value, and  implementation  overhead  bytes  is  limited  to  the
121       filesystem nodesize value (16 kB by default).
122

CONFORMING TO

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

NOTES

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

SEE ALSO

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

COLOPHON

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