1xattr(7)               Miscellaneous Information 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-imposed limits on attribute names and values are 255 bytes and
96       64 kB, respectively.  The list of attribute names that can be  returned
97       is also limited to 64 kB (see BUGS in listxattr(2)).
98
99       Some  filesystems, such as Reiserfs (and, historically, ext2 and ext3),
100       require the filesystem to be mounted with the user_xattr  mount  option
101       in order for user extended attributes to be used.
102
103       In the current ext2, ext3, and ext4 filesystem implementations, the to‐
104       tal bytes used by the names and values of all of a file's extended  at‐
105       tributes  must  fit  in  a  single filesystem block (1024, 2048 or 4096
106       bytes, depending on the block size specified when  the  filesystem  was
107       created).
108
109       In the Btrfs, XFS, and Reiserfs filesystem implementations, there is no
110       practical limit on the number of extended attributes associated with  a
111       file,  and  the algorithms used to store extended attribute information
112       on disk are scalable.
113
114       In the JFS, XFS, and Reiserfs filesystem implementations, the limit  on
115       bytes used in an EA value is the ceiling imposed by the VFS.
116
117       In  the  Btrfs  filesystem implementation, the total bytes used for the
118       name, value, and  implementation  overhead  bytes  is  limited  to  the
119       filesystem nodesize value (16 kB by default).
120

STANDARDS

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

NOTES

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

SEE ALSO

134       attr(1), getfattr(1), setfattr(1), getxattr(2), ioctl_iflags(2), listx‐
135       attr(2),   removexattr(2),   setxattr(2),   acl(5),    capabilities(7),
136       selinux(8)
137
138
139
140Linux man-pages 6.04              2023-02-05                          xattr(7)
Impressum