Revert "keyrings.7: ffix"
[man-pages.git] / man / man7 / xattr.7
blob350038820dc7a1d7436de5636a6efb76de505fa7
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 .\" SPDX-License-Identifier: GPL-2.0-or-later
8 .\"
9 .TH xattr 7 (date) "Linux man-pages (unreleased)"
10 .SH NAME
11 xattr \- Extended attributes
12 .SH DESCRIPTION
13 Extended attributes are name:value pairs associated permanently with
14 files and directories, similar to the environment strings associated
15 with a process.
16 An attribute may be defined or undefined.
17 If it is defined, its value may be empty or non-empty.
19 Extended attributes are extensions to the normal attributes which are
20 associated with all inodes in the system (i.e., the
21 .BR stat (2)
22 data).
23 They are often used to provide additional functionality
24 to a filesystem\[em]for example, additional security features such as
25 Access Control Lists (ACLs) may be implemented using extended attributes.
27 Users with search access to a file or directory may use
28 .BR listxattr (2)
29 to retrieve a list of attribute names defined for that file or directory.
31 Extended attributes are accessed as atomic objects.
32 Reading
33 .RB ( getxattr (2))
34 retrieves the whole value of an attribute and stores it in a buffer.
35 Writing
36 .RB ( setxattr (2))
37 replaces any previous value with the new value.
39 Space consumed for extended attributes may be counted towards the disk quotas
40 of the file owner and file group.
41 .SS Extended attribute namespaces
42 Attribute names are null-terminated strings.
43 The attribute name is always specified in the fully qualified
44 .I namespace.attribute
45 form, for example,
46 .IR user.mime_type ,
47 .IR trusted.md5sum ,
48 .IR system.posix_acl_access ,
50 .IR security.selinux .
52 The namespace mechanism is used to define different classes of extended
53 attributes.
54 These different classes exist for several reasons;
55 for example, the permissions
56 and capabilities required for manipulating extended attributes of one
57 namespace may differ to another.
59 Currently, the
60 .IR security ,
61 .IR system ,
62 .IR trusted ,
63 and
64 .I user
65 extended attribute classes are defined as described below.
66 Additional classes may be added in the future.
67 .SS Extended security attributes
68 The security attribute namespace is used by kernel security modules,
69 such as Security Enhanced Linux, and also to implement file capabilities (see
70 .BR capabilities (7)).
71 Read and write access permissions to security attributes depend on the
72 policy implemented for each security attribute by the security module.
73 When no security module is loaded, all processes have read access to
74 extended security attributes, and write access is limited to processes
75 that have the
76 .B CAP_SYS_ADMIN
77 capability.
78 .SS System extended attributes
79 System extended attributes are used by the kernel to store system
80 objects such as Access Control Lists.
81 Read and write
82 access permissions to system attributes depend on the policy implemented
83 for each system attribute implemented by filesystems in the kernel.
84 .SS Trusted extended attributes
85 Trusted extended attributes are visible and accessible only to processes that
86 have the
87 .B CAP_SYS_ADMIN
88 capability.
89 Attributes in this class are used to implement mechanisms in user
90 space (i.e., outside the kernel) which keep information in extended attributes
91 to which ordinary processes should not have access.
92 .SS User extended attributes
93 User extended attributes may be assigned to files and directories for
94 storing arbitrary additional information such as the mime type,
95 character set or encoding of a file.
96 The access permissions for user
97 attributes are defined by the file permission bits:
98 read permission is required to retrieve the attribute value,
99 and writer permission is required to change it.
101 The file permission bits of regular files and directories are
102 interpreted differently from the file permission bits of special files
103 and symbolic links.
104 For regular files and directories the file
105 permission bits define access to the file's contents, while for device special
106 files they define access to the device described by the special file.
107 The file permissions of symbolic links are not used in access checks.
108 These differences would allow users to consume filesystem resources in
109 a way not controllable by disk quotas for group or world writable
110 special files and directories.
112 For this reason,
113 user extended attributes are allowed only for regular files and directories,
114 and access to user extended attributes is restricted to the
115 owner and to users with appropriate capabilities for directories with the
116 sticky bit set (see the
117 .BR chmod (1)
118 manual page for an explanation of the sticky bit).
119 .SS Filesystem differences
120 The kernel and the filesystem may place limits on the maximum number
121 and size of extended attributes that can be associated with a file.
122 The VFS-imposed limits on attribute names and values are 255 bytes
123 and 64\ kB, respectively.
124 The list of attribute names that
125 can be returned is also limited to 64\ kB
126 (see BUGS in
127 .BR listxattr (2)).
129 Some filesystems, such as Reiserfs (and, historically, ext2 and ext3),
130 require the filesystem to be mounted with the
131 .B user_xattr
132 mount option in order for user extended attributes to be used.
134 In the current ext2, ext3, and ext4 filesystem implementations,
135 the total bytes used by the names and values of all of a file's
136 extended attributes must fit in a single filesystem block (1024, 2048
137 or 4096 bytes, depending on the block size specified when the
138 filesystem was created).
140 In the Btrfs, XFS, and Reiserfs filesystem implementations, there is no
141 practical limit on the number of extended attributes
142 associated with a file, and the algorithms used to store extended
143 attribute information on disk are scalable.
145 In the JFS, XFS, and Reiserfs filesystem implementations,
146 the limit on bytes used in an EA value is the ceiling imposed by the VFS.
148 In the Btrfs filesystem implementation,
149 the total bytes used for the name, value, and implementation overhead bytes
150 is limited to the filesystem
151 .I nodesize
152 value (16\ kB by default).
153 .SH STANDARDS
154 Extended attributes are not specified in POSIX.1, but some other systems
155 (e.g., the BSDs and Solaris) provide a similar feature.
156 .SH NOTES
157 Since the filesystems on which extended attributes are stored might also
158 be used on architectures with a different byte order and machine word
159 size, care should be taken to store attribute values in an
160 architecture-independent format.
162 This page was formerly named
163 .BR attr (5).
164 .\" .SH AUTHORS
165 .\" Andreas Gruenbacher,
166 .\" .RI < a.gruenbacher@bestbits.at >
167 .\" and the SGI XFS development team,
168 .\" .RI < linux-xfs@oss.sgi.com >.
169 .SH SEE ALSO
170 .BR attr (1),
171 .BR getfattr (1),
172 .BR setfattr (1),
173 .BR getxattr (2),
174 .BR FS_IOC_GETFLAGS (2const),
175 .BR FS_IOC_SETFLAGS (2const),
176 .BR listxattr (2),
177 .BR removexattr (2),
178 .BR setxattr (2),
179 .BR acl (5),
180 .BR capabilities (7),
181 .BR selinux (8)