1GETXATTR(2) Linux Programmer's Manual GETXATTR(2)
2
3
4
6 getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
7
9 #include <sys/types.h>
10 #include <sys/xattr.h>
11
12 ssize_t getxattr(const char *path, const char *name,
13 void *value, size_t size);
14 ssize_t lgetxattr(const char *path, const char *name,
15 void *value, size_t size);
16 ssize_t fgetxattr(int fd, const char *name,
17 void *value, size_t size);
18
20 Extended attributes are name:value pairs associated with inodes (files,
21 directories, symbolic links, etc.). They are extensions to the normal
22 attributes which are associated with all inodes in the system (i.e.,
23 the stat(2) data). A complete overview of extended attributes concepts
24 can be found in xattr(7).
25
26 getxattr() retrieves the value of the extended attribute identified by
27 name and associated with the given path in the filesystem. The
28 attribute value is placed in the buffer pointed to by value; size spec‐
29 ifies the size of that buffer. The return value of the call is the
30 number of bytes placed in value.
31
32 lgetxattr() is identical to getxattr(), except in the case of a sym‐
33 bolic link, where the link itself is interrogated, not the file that it
34 refers to.
35
36 fgetxattr() is identical to getxattr(), only the open file referred to
37 by fd (as returned by open(2)) is interrogated in place of path.
38
39 An extended attribute name is a null-terminated string. The name
40 includes a namespace prefix; there may be several, disjoint namespaces
41 associated with an individual inode. The value of an extended
42 attribute is a chunk of arbitrary textual or binary data that was
43 assigned using setxattr(2).
44
45 If size is specified as zero, these calls return the current size of
46 the named extended attribute (and leave value unchanged). This can be
47 used to determine the size of the buffer that should be supplied in a
48 subsequent call. (But, bear in mind that there is a possibility that
49 the attribute value may change between the two calls, so that it is
50 still necessary to check the return status from the second call.)
51
53 On success, these calls return a nonnegative value which is the size
54 (in bytes) of the extended attribute value. On failure, -1 is returned
55 and errno is set appropriately.
56
58 E2BIG The size of the attribute value is larger than the maximum size
59 allowed; the attribute cannot be retrieved. This can happen on
60 filesystems that support very large attribute values such as
61 NFSv4, for example.
62
63 ENODATA
64 The named attribute does not exist, or the process has no access
65 to this attribute.
66
67 ENOTSUP
68 Extended attributes are not supported by the filesystem, or are
69 disabled.
70
71 ERANGE The size of the value buffer is too small to hold the result.
72
73 In addition, the errors documented in stat(2) can also occur.
74
76 These system calls have been available on Linux since kernel 2.4; glibc
77 support is provided since version 2.3.
78
80 These system calls are Linux-specific.
81
83 See listxattr(2).
84
86 getfattr(1), setfattr(1), listxattr(2), open(2), removexattr(2), setx‐
87 attr(2), stat(2), symlink(7), xattr(7)
88
90 This page is part of release 5.04 of the Linux man-pages project. A
91 description of the project, information about reporting bugs, and the
92 latest version of this page, can be found at
93 https://www.kernel.org/doc/man-pages/.
94
95
96
97Linux 2019-03-06 GETXATTR(2)