Imported Upstream version 2.4.46
[platform/upstream/attr.git] / man / man5 / attr.5
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 .\" This is free documentation; you can redistribute it and/or
8 .\" modify it under the terms of the GNU General Public License as
9 .\" published by the Free Software Foundation; either version 2 of
10 .\" the License, or (at your option) any later version.
11 .\"
12 .\" The GNU General Public License's references to "object code"
13 .\" and "executables" are to be interpreted as the output of any
14 .\" document formatting or typesetting system, including
15 .\" intermediate and printed output.
16 .\"
17 .\" This manual is distributed in the hope that it will be useful,
18 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
19 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 .\" GNU General Public License for more details.
21 .\"
22 .\" You should have received a copy of the GNU General Public
23 .\" License along with this manual.  If not, see
24 .\" <http://www.gnu.org/licenses/>.
25 .\"
26 .TH ATTR 5
27 .SH NAME
28 attr - Extended attributes
29 .SH DESCRIPTION
30 Extended attributes are name:value pairs associated permanently with
31 files and directories, similar to the environment strings associated
32 with a process.
33 An attribute may be defined or undefined.
34 If it is defined, its value may be empty or non-empty.
35 .PP
36 Extended attributes are extensions to the normal attributes which are
37 associated with all inodes in the system (i.e. the
38 .BR stat (2)
39 data).
40 They are often used to provide additional functionality
41 to a filesystem \- for example, additional security features such as
42 Access Control Lists (ACLs) may be implemented using extended attributes.
43 .PP
44 Users with search access to a file or directory may retrieve a list of
45 attribute names defined for that file or directory.
46 .PP
47 Extended attributes are accessed as atomic objects.
48 Reading retrieves the whole value of an attribute and stores it in a buffer.
49 Writing replaces any previous value with the new value.
50 .PP
51 Space consumed for extended attributes is counted towards the disk quotas
52 of the file owner and file group.
53 .PP
54 Currently, support for extended attributes is implemented on Linux by the
55 ext2, ext3, ext4, XFS, JFS and reiserfs filesystems.
56 .SH EXTENDED ATTRIBUTE NAMESPACES
57 Attribute names are zero-terminated strings.
58 The attribute name is always specified in the fully qualified
59 .IR namespace.attribute
60 form, eg.
61 .IR user.mime_type ,
62 .IR trusted.md5sum ,
63 .IR system.posix_acl_access ,
64 or
65 .IR security.selinux .
66 .PP
67 The namespace mechanism is used to define different classes of extended
68 attributes.
69 These different classes exist for several reasons, e.g. the permissions
70 and capabilities required for manipulating extended attributes of one
71 namespace may differ to another.
72 .PP
73 Currently the
74 .IR security ,
75 .IR system ,
76 .IR trusted ,
77 and
78 .IR user
79 extended attribute classes are defined as described below. Additional
80 classes may be added in the future.
81 .SS Extended security attributes
82 The security attribute namespace is used by kernel security modules,
83 such as Security Enhanced Linux.  
84 Read and write access permissions to security attributes depend on the
85 policy implemented for each security attribute by the security module.
86 When no security module is loaded, all processes have read access to
87 extended security attributes, and write access is limited to processes
88 that have the CAP_SYS_ADMIN capability.
89 .SS Extended system attributes
90 Extended system attributes are used by the kernel to store system
91 objects such as Access Control Lists and Capabilities.  Read and write
92 access permissions to system attributes depend on the policy implemented
93 for each system attribute implemented by filesystems in the kernel.
94 .SS Trusted extended attributes
95 Trusted extended attributes are visible and accessible only to processes that
96 have the CAP_SYS_ADMIN capability (the super user usually has this
97 capability).
98 Attributes in this class are used to implement mechanisms in user
99 space (i.e., outside the kernel) which keep information in extended attributes
100 to which ordinary processes should not have access.
101 .SS Extended user attributes
102 Extended user attributes may be assigned to files and directories for
103 storing arbitrary additional information such as the mime type,
104 character set or encoding of a file. The access permissions for user
105 attributes are defined by the file permission bits.
106 .PP
107 The file permission bits of regular files and directories are
108 interpreted differently from the file permission bits of special files
109 and symbolic links. For regular files and directories the file
110 permission bits define access to the file's contents, while for device special
111 files they define access to the device described by the special file.
112 The file permissions of symbolic links are not used in access
113 checks. These differences would allow users to consume filesystem resources in
114 a way not controllable by disk quotas for group or world writable special files and directories.
115 .PP
116 For this reason, extended user attributes are only allowed for regular files and directories, and access to extended user attributes is restricted to the
117 owner and to users with appropriate capabilities for directories with the
118 sticky bit set (see the
119 .BR chmod (1)
120 manual page for an explanation of Sticky Directories).
121 .SH FILESYSTEM DIFFERENCES
122 The kernel and the filesystem may place limits on the maximum number
123 and size of extended attributes that can be associated with a file.
124 Some file systems, such as ext2/3 and reiserfs, require the filesystem
125 to be mounted with the
126 .B user_xattr
127 mount option in order for extended user attributes to be used.
128 .PP
129 In the current ext2, ext3 and ext4 filesystem implementations, each
130 extended attribute must fit on a single filesystem block (1024, 2048
131 or 4096 bytes, depending on the block size specified when the
132 filesystem was created).
133 .PP
134 In the XFS and reiserfs filesystem implementations, there is no
135 practical limit on the number or size of extended attributes
136 associated with a file, and the algorithms used to store extended
137 attribute information on disk are scalable.
138 .PP
139 In the JFS filesystem implementation, names can be up to 255 bytes and
140 values up to 65,535 bytes.
141 .SH ADDITIONAL NOTES
142 Since the filesystems on which extended attributes are stored might also
143 be used on architectures with a different byte order and machine word
144 size, care should be taken to store attribute values in an architecture
145 independent format.
146 .SH AUTHORS
147 Andreas Gruenbacher,
148 .RI < a.gruenbacher@bestbits.at >
149 and the SGI XFS development team,
150 .RI < linux-xfs@oss.sgi.com >.
151 .SH SEE ALSO
152 getfattr(1),
153 setfattr(1).