1GETXATTR(2)                Linux Programmer's Manual               GETXATTR(2)
2
3
4

NAME

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

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

VERSIONS

75       These system calls have been available on Linux since kernel 2.4; glibc
76       support is provided since version 2.3.
77

CONFORMING TO

79       These system calls are Linux-specific.
80

EXAMPLES

82       See listxattr(2).
83

SEE ALSO

85       getfattr(1),  setfattr(1), listxattr(2), open(2), removexattr(2), setx‐
86       attr(2), stat(2), symlink(7), xattr(7)
87

COLOPHON

89       This page is part of release 5.13 of the Linux  man-pages  project.   A
90       description  of  the project, information about reporting bugs, and the
91       latest    version    of    this    page,    can     be     found     at
92       https://www.kernel.org/doc/man-pages/.
93
94
95
96Linux                             2021-03-22                       GETXATTR(2)
Impressum