1getxattr(2)                   System Calls Manual                  getxattr(2)
2
3
4

NAME

6       getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <sys/xattr.h>
13
14       ssize_t getxattr(const char *path, const char *name,
15                        void value[.size], size_t size);
16       ssize_t lgetxattr(const char *path, const char *name,
17                        void value[.size], size_t size);
18       ssize_t fgetxattr(int fd, const char *name,
19                        void value[.size], size_t size);
20

DESCRIPTION

22       Extended attributes are name:value pairs associated with inodes (files,
23       directories, symbolic links, etc.).  They are extensions to the  normal
24       attributes  which  are  associated with all inodes in the system (i.e.,
25       the stat(2) data).  A complete overview of extended attributes concepts
26       can be found in xattr(7).
27
28       getxattr()  retrieves the value of the extended attribute identified by
29       name and associated with the given path in the filesystem.  The  attri‐
30       bute  value is placed in the buffer pointed to by value; size specifies
31       the size of that buffer.  The return value of the call is the number of
32       bytes placed in value.
33
34       lgetxattr()  is  identical  to getxattr(), except in the case of a sym‐
35       bolic link, where the link itself is interrogated, not the file that it
36       refers to.
37
38       fgetxattr()  is identical to getxattr(), only the open file referred to
39       by fd (as returned by open(2)) is interrogated in place of path.
40
41       An extended attribute name is a null-terminated string.  The  name  in‐
42       cludes  a  namespace  prefix; there may be several, disjoint namespaces
43       associated with an individual inode.  The value of an  extended  attri‐
44       bute  is  a chunk of arbitrary textual or binary data that was assigned
45       using setxattr(2).
46
47       If size is specified as zero, these calls return the  current  size  of
48       the  named extended attribute (and leave value unchanged).  This can be
49       used to determine the size of the buffer that should be supplied  in  a
50       subsequent  call.   (But, bear in mind that there is a possibility that
51       the attribute value may change between the two calls,  so  that  it  is
52       still necessary to check the return status from the second call.)
53

RETURN VALUE

55       On  success,  these  calls return a nonnegative value which is the size
56       (in bytes) of the extended attribute value.  On failure, -1 is returned
57       and errno is set to indicate the error.
58

ERRORS

60       E2BIG  The  size of the attribute value is larger than the maximum size
61              allowed; the attribute cannot be retrieved.  This can happen  on
62              filesystems  that  support  very  large attribute values such as
63              NFSv4, for example.
64
65       ENODATA
66              The named attribute does not exist, or the process has no access
67              to this attribute.
68
69       ENOTSUP
70              Extended  attributes are not supported by the filesystem, or are
71              disabled.
72
73       ERANGE The size of the value buffer is too small to hold the result.
74
75       In addition, the errors documented in stat(2) can also occur.
76

STANDARDS

78       Linux.
79

HISTORY

81       Linux 2.4, glibc 2.3.
82

EXAMPLES

84       See listxattr(2).
85

SEE ALSO

87       getfattr(1), setfattr(1), listxattr(2), open(2), removexattr(2),  setx‐
88       attr(2), stat(2), symlink(7), xattr(7)
89
90
91
92Linux man-pages 6.05              2023-07-28                       getxattr(2)
Impressum