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