|
Packit |
7cfc04 |
.\" Copyright (C) Andreas Gruenbacher, February 2001
|
|
Packit |
7cfc04 |
.\" Copyright (C) Silicon Graphics Inc, September 2001
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
|
|
Packit |
7cfc04 |
.\" This is free documentation; you can redistribute it and/or
|
|
Packit |
7cfc04 |
.\" modify it under the terms of the GNU General Public License as
|
|
Packit |
7cfc04 |
.\" published by the Free Software Foundation; either version 2 of
|
|
Packit |
7cfc04 |
.\" the License, or (at your option) any later version.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" The GNU General Public License's references to "object code"
|
|
Packit |
7cfc04 |
.\" and "executables" are to be interpreted as the output of any
|
|
Packit |
7cfc04 |
.\" document formatting or typesetting system, including
|
|
Packit |
7cfc04 |
.\" intermediate and printed output.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" This manual is distributed in the hope that it will be useful,
|
|
Packit |
7cfc04 |
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
7cfc04 |
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
7cfc04 |
.\" GNU General Public License for more details.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" You should have received a copy of the GNU General Public
|
|
Packit |
7cfc04 |
.\" License along with this manual; if not, see
|
|
Packit |
7cfc04 |
.\" <http://www.gnu.org/licenses/>.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH GETXATTR 2 2017-03-13 "Linux" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
getxattr, lgetxattr, fgetxattr \- retrieve an extended attribute value
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.fam C
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
.B #include <sys/types.h>
|
|
Packit |
7cfc04 |
.B #include <sys/xattr.h>
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BI "ssize_t getxattr(const char\ *" path ", const char\ *" name ,
|
|
Packit |
7cfc04 |
.BI " void\ *" value ", size_t " size );
|
|
Packit |
7cfc04 |
.BI "ssize_t lgetxattr(const char\ *" path ", const char\ *" name ,
|
|
Packit |
7cfc04 |
.BI " void\ *" value ", size_t " size );
|
|
Packit |
7cfc04 |
.BI "ssize_t fgetxattr(int " fd ", const char\ *" name ,
|
|
Packit |
7cfc04 |
.BI " void\ *" value ", size_t " size );
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.fam T
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
Extended attributes are
|
|
Packit |
7cfc04 |
.IR name :\c
|
|
Packit |
7cfc04 |
.I value
|
|
Packit |
7cfc04 |
pairs associated with inodes (files, directories, symbolic links, etc.).
|
|
Packit |
7cfc04 |
They are extensions to the normal attributes which are associated
|
|
Packit |
7cfc04 |
with all inodes in the system (i.e., the
|
|
Packit |
7cfc04 |
.BR stat (2)
|
|
Packit |
7cfc04 |
data).
|
|
Packit |
7cfc04 |
A complete overview of extended attributes concepts can be found in
|
|
Packit |
7cfc04 |
.BR xattr (7).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BR getxattr ()
|
|
Packit |
7cfc04 |
retrieves the value of the extended attribute identified by
|
|
Packit |
7cfc04 |
.I name
|
|
Packit |
7cfc04 |
and associated with the given
|
|
Packit |
7cfc04 |
.I path
|
|
Packit |
7cfc04 |
in the filesystem.
|
|
Packit |
7cfc04 |
The attribute value is placed in the buffer pointed to by
|
|
Packit |
7cfc04 |
.IR value ;
|
|
Packit |
7cfc04 |
.I size
|
|
Packit |
7cfc04 |
specifies the size of that buffer.
|
|
Packit |
7cfc04 |
The return value of the call is the number of bytes placed in
|
|
Packit |
7cfc04 |
.IR value .
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BR lgetxattr ()
|
|
Packit |
7cfc04 |
is identical to
|
|
Packit |
7cfc04 |
.BR getxattr (),
|
|
Packit |
7cfc04 |
except in the case of a symbolic link, where the link itself is
|
|
Packit |
7cfc04 |
interrogated, not the file that it refers to.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BR fgetxattr ()
|
|
Packit |
7cfc04 |
is identical to
|
|
Packit |
7cfc04 |
.BR getxattr (),
|
|
Packit |
7cfc04 |
only the open file referred to by
|
|
Packit |
7cfc04 |
.I fd
|
|
Packit |
7cfc04 |
(as returned by
|
|
Packit |
7cfc04 |
.BR open (2))
|
|
Packit |
7cfc04 |
is interrogated in place of
|
|
Packit |
7cfc04 |
.IR path .
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
An extended attribute
|
|
Packit |
7cfc04 |
.I name
|
|
Packit |
7cfc04 |
is a null-terminated string.
|
|
Packit |
7cfc04 |
The name includes a namespace prefix; there may be several, disjoint
|
|
Packit |
7cfc04 |
namespaces associated with an individual inode.
|
|
Packit |
7cfc04 |
The value of an extended attribute is a chunk of arbitrary textual or
|
|
Packit |
7cfc04 |
binary data that was assigned using
|
|
Packit |
7cfc04 |
.BR setxattr (2).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I size
|
|
Packit |
7cfc04 |
is specified as zero, these calls return the current size of the
|
|
Packit |
7cfc04 |
named extended attribute (and leave
|
|
Packit |
7cfc04 |
.I value
|
|
Packit |
7cfc04 |
unchanged).
|
|
Packit |
7cfc04 |
This can be used to determine the size of the buffer that
|
|
Packit |
7cfc04 |
should be supplied in a subsequent call.
|
|
Packit |
7cfc04 |
(But, bear in mind that there is a possibility that the
|
|
Packit |
7cfc04 |
attribute value may change between the two calls,
|
|
Packit |
7cfc04 |
so that it is still necessary to check the return status
|
|
Packit |
7cfc04 |
from the second call.)
|
|
Packit |
7cfc04 |
.SH RETURN VALUE
|
|
Packit |
7cfc04 |
On success, these calls return a nonnegative value which is
|
|
Packit |
7cfc04 |
the size (in bytes) of the extended attribute value.
|
|
Packit |
7cfc04 |
On failure, \-1 is returned and
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
is set appropriately.
|
|
Packit |
7cfc04 |
.SH ERRORS
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B E2BIG
|
|
Packit |
7cfc04 |
The size of the attribute value is larger than the maximum size allowed; the
|
|
Packit |
7cfc04 |
attribute cannot be retrieved.
|
|
Packit |
7cfc04 |
This can happen on filesystems that support
|
|
Packit |
7cfc04 |
very large attribute values such as NFSv4, for example.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B ENOATTR
|
|
Packit |
7cfc04 |
The named attribute does not exist, or the process has no access to
|
|
Packit |
7cfc04 |
this attribute.
|
|
Packit |
7cfc04 |
.RB ( ENOATTR
|
|
Packit |
7cfc04 |
is defined to be a synonym for
|
|
Packit |
7cfc04 |
.BR ENODATA
|
|
Packit |
7cfc04 |
in
|
|
Packit |
7cfc04 |
.IR <attr/xattr.h> .)
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B ENOTSUP
|
|
Packit |
7cfc04 |
Extended attributes are not supported by the filesystem, or are disabled.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B ERANGE
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.I size
|
|
Packit |
7cfc04 |
of the
|
|
Packit |
7cfc04 |
.I value
|
|
Packit |
7cfc04 |
buffer is too small to hold the result.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
In addition, the errors documented in
|
|
Packit |
7cfc04 |
.BR stat (2)
|
|
Packit |
7cfc04 |
can also occur.
|
|
Packit |
7cfc04 |
.SH VERSIONS
|
|
Packit |
7cfc04 |
These system calls have been available on Linux since kernel 2.4;
|
|
Packit |
7cfc04 |
glibc support is provided since version 2.3.
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
These system calls are Linux-specific.
|
|
Packit |
7cfc04 |
.\" .SH AUTHORS
|
|
Packit |
7cfc04 |
.\" Andreas Gruenbacher,
|
|
Packit |
7cfc04 |
.\" .RI < a.gruenbacher@computer.org >
|
|
Packit |
7cfc04 |
.\" and the SGI XFS development team,
|
|
Packit |
7cfc04 |
.\" .RI < linux-xfs@oss.sgi.com >.
|
|
Packit |
7cfc04 |
.\" Please send any bug reports or comments to these addresses.
|
|
Packit |
7cfc04 |
.SH EXAMPLE
|
|
Packit |
7cfc04 |
See
|
|
Packit |
7cfc04 |
.BR listxattr (2).
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR getfattr (1),
|
|
Packit |
7cfc04 |
.BR setfattr (1),
|
|
Packit |
7cfc04 |
.BR listxattr (2),
|
|
Packit |
7cfc04 |
.BR open (2),
|
|
Packit |
7cfc04 |
.BR removexattr (2),
|
|
Packit |
7cfc04 |
.BR setxattr (2),
|
|
Packit |
7cfc04 |
.BR stat (2),
|
|
Packit |
7cfc04 |
.BR symlink (7),
|
|
Packit |
7cfc04 |
.BR xattr (7)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|