2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
|
|
|
.\" Extended attributes system calls manual pages
|
|
|
|
.\"
|
2008-07-08 14:32:54 +00:00
|
|
|
.\" Copyright (C) Andreas Gruenbacher, February 2001
|
|
|
|
.\" Copyright (C) Silicon Graphics Inc, September 2001
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
|
|
|
.\" This is free documentation; you can redistribute it and/or
|
|
|
|
.\" modify it under the terms of the GNU General Public License as
|
|
|
|
.\" published by the Free Software Foundation; either version 2 of
|
|
|
|
.\" the License, or (at your option) any later version.
|
|
|
|
.\"
|
|
|
|
.\" The GNU General Public License's references to "object code"
|
|
|
|
.\" and "executables" are to be interpreted as the output of any
|
|
|
|
.\" document formatting or typesetting system, including
|
|
|
|
.\" intermediate and printed output.
|
|
|
|
.\"
|
|
|
|
.\" This manual is distributed in the hope that it will be useful,
|
|
|
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
.\" GNU General Public License for more details.
|
|
|
|
.\"
|
|
|
|
.\" You should have received a copy of the GNU General Public
|
|
|
|
.\" License along with this manual; if not, write to the Free
|
|
|
|
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
|
|
|
|
.\" USA.
|
|
|
|
.\"
|
2007-05-18 09:55:10 +00:00
|
|
|
.TH GETXATTR 2 2001-12-01 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
getxattr, lgetxattr, fgetxattr \- retrieve an extended attribute value
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.fam C
|
|
|
|
.nf
|
|
|
|
.B #include <sys/types.h>
|
|
|
|
.B #include <attr/xattr.h>
|
|
|
|
.sp
|
2006-05-31 22:16:55 +00:00
|
|
|
.BI "ssize_t getxattr(const char\ *" path ", const char\ *" name ,
|
|
|
|
.BI " void\ *" value ", size_t " size );
|
|
|
|
.BI "ssize_t lgetxattr(const char\ *" path ", const char\ *" name ,
|
|
|
|
.BI " void\ *" value ", size_t " size );
|
2007-12-23 21:56:27 +00:00
|
|
|
.BI "ssize_t fgetxattr(int " fd ", const char\ *" name ,
|
2006-05-31 22:16:55 +00:00
|
|
|
.BI " void\ *" value ", size_t " size );
|
2004-11-03 13:51:07 +00:00
|
|
|
.fi
|
|
|
|
.fam T
|
|
|
|
.SH DESCRIPTION
|
|
|
|
Extended attributes are
|
|
|
|
.IR name :\c
|
|
|
|
.I value
|
2007-12-22 22:43:42 +00:00
|
|
|
pairs associated with inodes (files, directories, symbolic links, etc.).
|
2004-11-03 13:51:07 +00:00
|
|
|
They are extensions to the normal attributes which are associated
|
2007-06-08 11:56:22 +00:00
|
|
|
with all inodes in the system (i.e., the
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR stat (2)
|
|
|
|
data).
|
|
|
|
A complete overview of extended attributes concepts can be found in
|
|
|
|
.BR attr (5).
|
|
|
|
.PP
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR getxattr ()
|
2004-11-03 13:51:07 +00:00
|
|
|
retrieves the
|
|
|
|
.I value
|
|
|
|
of the extended attribute identified by
|
|
|
|
.I name
|
|
|
|
and associated with the given
|
|
|
|
.I path
|
2008-03-19 07:26:08 +00:00
|
|
|
in the file system.
|
2004-11-03 13:51:07 +00:00
|
|
|
The length of the attribute
|
|
|
|
.I value
|
|
|
|
is returned.
|
|
|
|
.PP
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR lgetxattr ()
|
2007-04-12 22:42:49 +00:00
|
|
|
is identical to
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR getxattr (),
|
2004-11-03 13:51:07 +00:00
|
|
|
except in the case of a symbolic link, where the link itself is
|
|
|
|
interrogated, not the file that it refers to.
|
|
|
|
.PP
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR fgetxattr ()
|
2004-11-03 13:51:07 +00:00
|
|
|
is identical to
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR getxattr (),
|
2007-12-23 21:56:27 +00:00
|
|
|
only the open file referred to by
|
|
|
|
.I fd
|
2004-11-03 13:51:07 +00:00
|
|
|
(as returned by
|
|
|
|
.BR open (2))
|
|
|
|
is interrogated in place of
|
|
|
|
.IR path .
|
|
|
|
.PP
|
|
|
|
An extended attribute
|
|
|
|
.I name
|
2005-11-02 11:55:24 +00:00
|
|
|
is a simple null-terminated string.
|
2005-07-18 12:43:00 +00:00
|
|
|
The name includes a namespace prefix; there may be several, disjoint
|
2004-11-03 13:51:07 +00:00
|
|
|
namespaces associated with an individual inode.
|
|
|
|
The value of an extended attribute is a chunk of arbitrary textual or
|
|
|
|
binary data of specified length.
|
|
|
|
.PP
|
|
|
|
An empty buffer of
|
|
|
|
.I size
|
|
|
|
zero can be passed into these calls to return the current size of the
|
|
|
|
named extended attribute, which can be used to estimate the size of a
|
|
|
|
buffer which is sufficiently large to hold the value associated with
|
|
|
|
the extended attribute.
|
|
|
|
.PP
|
|
|
|
The interface is designed to allow guessing of initial buffer
|
|
|
|
sizes, and to enlarge buffers when the return value indicates
|
|
|
|
that the buffer provided was too small.
|
|
|
|
.SH RETURN VALUE
|
|
|
|
On success, a positive number is returned indicating the size of the
|
|
|
|
extended attribute value.
|
|
|
|
On failure, \-1 is returned and
|
|
|
|
.I errno
|
|
|
|
is set appropriately.
|
|
|
|
.PP
|
|
|
|
If the named attribute does not exist, or the process has no access to
|
|
|
|
this attribute,
|
|
|
|
.I errno
|
2007-06-22 17:16:20 +00:00
|
|
|
is set to
|
|
|
|
.BR ENOATTR .
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
If the
|
|
|
|
.I size
|
|
|
|
of the
|
|
|
|
.I value
|
|
|
|
buffer is too small to hold the result,
|
|
|
|
.I errno
|
2007-06-22 17:16:20 +00:00
|
|
|
is set to
|
|
|
|
.BR ERANGE .
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2008-03-19 07:26:08 +00:00
|
|
|
If extended attributes are not supported by the file system, or are disabled,
|
2004-11-03 13:51:07 +00:00
|
|
|
.I errno
|
2007-06-22 17:16:20 +00:00
|
|
|
is set to
|
|
|
|
.BR ENOTSUP .
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
The errors documented for the
|
|
|
|
.BR stat (2)
|
|
|
|
system call are also applicable here.
|
2007-06-05 06:32:07 +00:00
|
|
|
.SH VERSIONS
|
|
|
|
These system calls have been available on Linux since kernel 2.4;
|
|
|
|
glibc support is provided since version 2.3.
|
2006-08-04 09:41:28 +00:00
|
|
|
.SH "CONFORMING TO"
|
2007-12-25 21:28:09 +00:00
|
|
|
These system calls are Linux-specific.
|
2007-05-16 03:44:47 +00:00
|
|
|
.\" .SH AUTHORS
|
|
|
|
.\" Andreas Gruenbacher,
|
|
|
|
.\" .RI < a.gruenbacher@computer.org >
|
|
|
|
.\" and the SGI XFS development team,
|
|
|
|
.\" .RI < linux-xfs@oss.sgi.com >.
|
|
|
|
.\" Please send any bug reports or comments to these addresses.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH SEE ALSO
|
|
|
|
.BR getfattr (1),
|
|
|
|
.BR setfattr (1),
|
|
|
|
.BR listxattr (2),
|
|
|
|
.BR open (2),
|
|
|
|
.BR removexattr (2),
|
|
|
|
.BR setxattr (2),
|
|
|
|
.BR stat (2),
|
2008-06-11 21:50:53 +00:00
|
|
|
.BR attr (5),
|
|
|
|
.BR symlink (7)
|