]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man7/xattr.7
Various pages: Add missing commas in SEE ALSO part II
[thirdparty/man-pages.git] / man7 / xattr.7
1 .\" Extended attributes manual page
2 .\"
3 .\" Copyright (C) 2000, 2002, 2007 Andreas Gruenbacher <agruen@suse.de>
4 .\" Copyright (C) 2001, 2002, 2004, 2007 Silicon Graphics, Inc.
5 .\" All rights reserved.
6 .\"
7 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
8 .\" This is free documentation; you can redistribute it and/or
9 .\" modify it under the terms of the GNU General Public License as
10 .\" published by the Free Software Foundation; either version 2 of
11 .\" the License, or (at your option) any later version.
12 .\"
13 .\" The GNU General Public License's references to "object code"
14 .\" and "executables" are to be interpreted as the output of any
15 .\" document formatting or typesetting system, including
16 .\" intermediate and printed output.
17 .\"
18 .\" This manual is distributed in the hope that it will be useful,
19 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
20 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 .\" GNU General Public License for more details.
22 .\"
23 .\" You should have received a copy of the GNU General Public
24 .\" License along with this manual. If not, see
25 .\" <http://www.gnu.org/licenses/>.
26 .\" %%%LICENSE_END
27 .\"
28 .TH XATTR 7 2019-08-02 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 xattr \- Extended attributes
31 .SH DESCRIPTION
32 Extended attributes are name:value pairs associated permanently with
33 files and directories, similar to the environment strings associated
34 with a process.
35 An attribute may be defined or undefined.
36 If it is defined, its value may be empty or non-empty.
37 .PP
38 Extended attributes are extensions to the normal attributes which are
39 associated with all inodes in the system (i.e., the
40 .BR stat (2)
41 data).
42 They are often used to provide additional functionality
43 to a filesystem\(emfor example, additional security features such as
44 Access Control Lists (ACLs) may be implemented using extended attributes.
45 .PP
46 Users with search access to a file or directory may use
47 .BR listxattr (2)
48 to retrieve a list of attribute names defined for that file or directory.
49 .PP
50 Extended attributes are accessed as atomic objects.
51 Reading
52 .RB ( getxattr (2))
53 retrieves the whole value of an attribute and stores it in a buffer.
54 Writing
55 .RB ( setxattr (2))
56 replaces any previous value with the new value.
57 .PP
58 Space consumed for extended attributes may be counted towards the disk quotas
59 of the file owner and file group.
60 .SS Extended attribute namespaces
61 Attribute names are null-terminated strings.
62 The attribute name is always specified in the fully qualified
63 .IR namespace.attribute
64 form, for example,
65 .IR user.mime_type ,
66 .IR trusted.md5sum ,
67 .IR system.posix_acl_access ,
68 or
69 .IR security.selinux .
70 .PP
71 The namespace mechanism is used to define different classes of extended
72 attributes.
73 These different classes exist for several reasons;
74 for example, the permissions
75 and capabilities required for manipulating extended attributes of one
76 namespace may differ to another.
77 .PP
78 Currently, the
79 .IR security ,
80 .IR system ,
81 .IR trusted ,
82 and
83 .IR user
84 extended attribute classes are defined as described below.
85 Additional classes may be added in the future.
86 .SS Extended security attributes
87 The security attribute namespace is used by kernel security modules,
88 such as Security Enhanced Linux, and also to implement file capabilities (see
89 .BR capabilities (7)).
90 Read and write access permissions to security attributes depend on the
91 policy implemented for each security attribute by the security module.
92 When no security module is loaded, all processes have read access to
93 extended security attributes, and write access is limited to processes
94 that have the
95 .B CAP_SYS_ADMIN
96 capability.
97 .SS System extended attributes
98 System extended attributes are used by the kernel to store system
99 objects such as Access Control Lists.
100 Read and write
101 access permissions to system attributes depend on the policy implemented
102 for each system attribute implemented by filesystems in the kernel.
103 .SS Trusted extended attributes
104 Trusted extended attributes are visible and accessible only to processes that
105 have the
106 .B CAP_SYS_ADMIN
107 capability.
108 Attributes in this class are used to implement mechanisms in user
109 space (i.e., outside the kernel) which keep information in extended attributes
110 to which ordinary processes should not have access.
111 .SS User extended attributes
112 User extended attributes may be assigned to files and directories for
113 storing arbitrary additional information such as the mime type,
114 character set or encoding of a file.
115 The access permissions for user
116 attributes are defined by the file permission bits:
117 read permission is required to retrieve the attribute value,
118 and writer permission is required to change it.
119 .PP
120 The file permission bits of regular files and directories are
121 interpreted differently from the file permission bits of special files
122 and symbolic links.
123 For regular files and directories the file
124 permission bits define access to the file's contents, while for device special
125 files they define access to the device described by the special file.
126 The file permissions of symbolic links are not used in access checks.
127 These differences would allow users to consume filesystem resources in
128 a way not controllable by disk quotas for group or world writable
129 special files and directories.
130 .PP
131 For this reason,
132 user extended attributes are allowed only for regular files and directories,
133 and access to user extended attributes is restricted to the
134 owner and to users with appropriate capabilities for directories with the
135 sticky bit set (see the
136 .BR chmod (1)
137 manual page for an explanation of the sticky bit).
138 .SS Filesystem differences
139 The kernel and the filesystem may place limits on the maximum number
140 and size of extended attributes that can be associated with a file.
141 The VFS imposes limitations that an attribute names is limited to 255 bytes
142 and an attribute value is limited to 64\ kB.
143 The list of attribute names that
144 can be returned is also limited to 64\ kB
145 (see BUGS in
146 .BR listxattr (2)).
147 .PP
148 Some filesystems, such as Reiserfs (and, historically, ext2 and ext3),
149 require the filesystem to be mounted with the
150 .B user_xattr
151 mount option in order for user extended attributes to be used.
152 .PP
153 In the current ext2, ext3, and ext4 filesystem implementations,
154 the total bytes used by the names and values of all of a file's
155 extended attributes must fit in a single filesystem block (1024, 2048
156 or 4096 bytes, depending on the block size specified when the
157 filesystem was created).
158 .PP
159 In the Btrfs, XFS, and Reiserfs filesystem implementations, there is no
160 practical limit on the number of extended attributes
161 associated with a file, and the algorithms used to store extended
162 attribute information on disk are scalable.
163 .PP
164 In the JFS, XFS, and Reiserfs filesystem implementations,
165 the limit on bytes used in an EA value is the ceiling imposed by the VFS.
166 .PP
167 In the Btrfs filesystem implementation,
168 the total bytes used for the name, value, and implementation overhead bytes
169 is limited to the filesystem
170 .I nodesize
171 value (16\ kB by default).
172 .SH CONFORMING TO
173 Extended attributes are not specified in POSIX.1, but some other systems
174 (e.g., the BSDs and Solaris) provide a similar feature.
175 .SH NOTES
176 Since the filesystems on which extended attributes are stored might also
177 be used on architectures with a different byte order and machine word
178 size, care should be taken to store attribute values in an
179 architecture-independent format.
180 .PP
181 This page was formerly named
182 .BR attr (5).
183 .\" .SH AUTHORS
184 .\" Andreas Gruenbacher,
185 .\" .RI < a.gruenbacher@bestbits.at >
186 .\" and the SGI XFS development team,
187 .\" .RI < linux-xfs@oss.sgi.com >.
188 .SH SEE ALSO
189 .BR getfattr (1),
190 .BR setfattr (1),
191 .BR getxattr (2),
192 .BR attr (1),
193 .BR ioctl_iflags (2),
194 .BR listxattr (2),
195 .BR removexattr (2),
196 .BR setxattr (2),
197 .BR acl (5),
198 .BR capabilities (7),
199 .BR selinux (8)