EXTATTR(2)
π extattr(2) β System Calls Manual, bestie edition β¨
πΈ NAME πΈ
extattr_delete_fd, extattr_delete_file, extattr_delete_link, extattr_get_fd, extattr_get_file, extattr_get_link, extattr_list_fd, extattr_list_file, extattr_list_link, extattr_set_fd, extattr_set_file, extattr_set_link β system calls to manipulate VFS extended attributes π«Ά
π LIBRARY π
Standard C Library (libc, -lc).
π¦ SYNOPSIS π¦
#include <sys/types.h>
#include <sys/extattr.h>
int
extattr_delete_fd(int fd, int attrnamespace, const char *attrname);
int
extattr_delete_file(const char *path, int attrnamespace,
const char *attrname);
int
extattr_delete_link(const char *path, int attrnamespace,
const char *attrname);
ssize_t
extattr_get_fd(int fd, int attrnamespace, const char *attrname,
void *data, size_t nbytes);
ssize_t
extattr_get_file(const char *path, int attrnamespace,
const char *attrname, void *data, size_t nbytes);
ssize_t
extattr_get_link(const char *path, int attrnamespace,
const char *attrname, void *data, size_t nbytes);
ssize_t
extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes);
ssize_t
extattr_list_file(const char *path, int attrnamespace, void *data,
size_t nbytes);
ssize_t
extattr_list_link(const char *path, int attrnamespace, void *data,
size_t nbytes);
ssize_t
extattr_set_fd(int fd, int attrnamespace, const char *attrname,
const void *data, size_t nbytes);
ssize_t
extattr_set_file(const char *path, int attrnamespace,
const char *attrname, const void *data, size_t nbytes);
ssize_t
extattr_set_link(const char *path, int attrnamespace,
const char *attrname, const void *data, size_t nbytes);
β¨ DESCRIPTION β¨
Okay so bestie, named extended attributes are meta-data associated with vnodes representing files and directories. They exist as "name=value" pairs within a set of namespaces.
Hereβs the function rundown, no cap:
extattr_get_file()β retrieves the value of the specified extended attribute into a buffer pointed to bydataof sizenbytes.extattr_set_file()β sets the value of the specified extended attribute to the data described bydata.extattr_delete_file()β deletes the specified extended attribute.extattr_list_file()β returns a list of attributes present in the requested namespace. Each list entry consists of a single byte containing the length of the attribute name, followed by the attribute name. The attribute name is not terminated by ASCII 0 (nul).
The extattr_get_file() and extattr_list_file() calls consume the data and nbytes arguments in the style of read(2); extattr_set_file() consumes these arguments in the style of write(2).
If data is NULL in a call to extattr_get_file() and extattr_list_file() then the size of defined extended attribute data will be returned, rather than the quantity read, permitting applications to test the size of the data without performing a read.
The extattr_delete_link(), extattr_get_link(), and extattr_set_link() system calls behave in the same way as their _file counterparts, except that they do not follow symlinks.
The extattr_get_fd(), extattr_delete_fd(), extattr_list_fd(), and extattr_set_fd() calls are identical to their _file counterparts except for the first argument. The _fd functions take a file descriptor, while the _file functions take a path. Both arguments describe a file associated with the extended attribute that should be manipulated. The _fd functions can be used with file descriptors opened with the O_PATH flag.
The following arguments are common to all the system calls described here:
attrnamespaceβ the namespace in which the extended attribute resides; seeextattr(9).attrnameβ the name of the extended attribute.
Named extended attribute semantics vary by file system implementing the call. Not all operations may be supported for a particular attribute. Additionally, the format of the data in data is attribute-specific.
For more information on named extended attributes, please see extattr(9).
π RETURN VALUES π
If successful, these calls β extattr_get_fd(), extattr_get_file(), extattr_get_link(), extattr_list_fd(), extattr_list_file(), extattr_list_link(), extattr_set_fd(), extattr_set_file(), and extattr_set_link() β return the number of bytes that were read or written from the data, respectively.
If data was NULL, then extattr_get_fd(), extattr_get_file(), extattr_get_link(), extattr_list_fd(), extattr_list_file(), and extattr_list_link() return the number of bytes available to read.
If any of the calls are unsuccessful, the value -1 is returned and the global variable errno is set to indicate the error.
The extattr_delete_file() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.
π ERRORS π
The following errors may be returned by the system calls themselves. Additionally, the file system implementing the call may return any other errors it desires.
[EFAULT]β Theattrnamespaceandattrnamearguments, or the memory range defined bydataandnbytespoint outside the processβs allocated address space.[ENAMETOOLONG]β The attribute name was longer thanEXTATTR_MAXNAMELEN.
The extattr_get_fd(), extattr_set_fd(), extattr_delete_fd(), and extattr_list_fd() system calls may also fail if:
[EBADF]β The file descriptor referenced byfdwas invalid.
Additionally, the extattr_get_file(), extattr_set_file(), and extattr_delete_file() calls may also fail due to the following errors:
[ENOATTR]β The requested attribute was not defined for this file.[ENOTDIR]β A component of the path prefix is not a directory.[ENAMETOOLONG]β A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters.[ENOENT]β A component of the path name that must exist does not exist.[EACCES]β Search permission is denied for a component of the path prefix.
π SEE ALSO π
extattr(3), getextattr(8), setextattr(8), extattr(9), VOP_GETEXTATTR(9), VOP_SETEXTATTR(9).
π§ HISTORY π§
Extended attribute support was developed as part of the TrustedBSD Project, and introduced in FreeBSD 5.0. It was developed to support security extensions requiring additional labels to be associated with each file or directory.
β οΈ CAVEATS β οΈ
This interface is under active development, and as such is subject to change as applications are adapted to use it. Developers are discouraged from relying on its stability.
π BUGS π
In earlier versions of this API, passing an empty string for the attribute name to extattr_get_fd(), extattr_get_file(), or extattr_get_link() would return the list of attributes defined for the target object. This interface has been deprecated in preference to using the explicit list API, and should not be used.
okay thatβs the whole page, bestie β source/version: Debian, date: October 11, 2021. byeee π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2001 Dima Dorfman <dima@unixfreak.org>
- Copyright (c) 2003 Robert Watson <rwatson@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms