VOP_GETEXTATTR(9)
π VOP_GETEXTATTR π
okay so bestie, welcome to VOP_GETEXTATTR, section 9 of the Kernel Developer's Manual β aka the vnode call that retrieves a named extended attribute from a vnode. she's giving very much "get me that metadata, bestie" energy and honestly? we're obsessed. π
β¨ SYNOPSIS β¨
first things first, you gotta pull in the headers, no cap:
#include <sys/param.h>
#include <sys/vnode.h>
#include <sys/extattr.h>
int
VOP_GETEXTATTR(struct vnode *vp, int attrnamespace, const char *name,
struct uio *uio, size_t *size, struct ucred *cred,
struct thread *td);
like, that's the whole vibe right there. seven arguments, all iconic, all necessary. π
π¦ DESCRIPTION π¦
so this vnode call is literally the one you use to retrieve a specific named extended attribute from a file or a directory. file or directory, she doesn't discriminate, she just serves. β¨
now let's meet the arguments, one by one, because they ALL matter:
vpβ the vnode of the file or directory. your main character, fr fr.attrnamespaceβ an integer constant indicating which extended attribute namespace the attribute name is present in. she tells you where the name lives.nameβ a pointer to a null-terminated character string containing the attribute name. yes, null-terminated, yes, that's important. π«Άuioβ the location of the data to be read. this is where the goods go.sizeβ if it's notNULL, then on return it will contain the number of bytes required to read all of the attribute data. and listen: in most casesuiowill beNULLwhensizeis not, and vice versa. they're giving mutually exclusive bestie energy, iykyk. πcredβ the user credentials to use in authorizing the request. who's asking, basically.tdβ the thread requesting the extended attribute. hi bestie, it's you. π
and here's a lil detail that lowkey matters a lot: the cred pointer may be NULL to indicate that access control checks are not to be performed, if possible. this cred setting might be used to allow the kernel to authorize extended attribute retrieval that the active process might not be permitted to do. so like, the kernel gets to do things you don't get to do. iconic of her, honestly. π
also, heads up: extended attribute semantics may vary by file system implementing the call. every FS does her own thing, and that's just the tea. β more information on extended attributes may be found in extattr(9).
π LOCKS π
the vnode will be locked on entry and should remain locked on return. don't you dare unlock her mid-flight, bestie, that's not the vibe. π«
π« RETURN VALUES π«
on success, zero will be returned, and the uio structure will be updated to reflect data read. slay. β¨
otherwise, an appropriate error code is returned. and by "appropriate" we mean "she'll tell you exactly what went wrong," so go read the next section. π
π ERRORS π
[ENOATTR]β the requested attribute was not defined for this vnode. she doesn't have it. it's not there. it's giving empty shelf. π[EACCES]β the caller does not have the appropriate privilege. respectfully, who do you think you are? π[ENXIO]β the request was not valid in this file system for the specified vnode and attribute name. wrong FS, wrong vnode, wrong name, wrong everything.[ENOMEM]β sufficient memory is not available to fulfill the request. girl is broke. no memory. π[EFAULT]β theuiostructure refers to an invalid userspace address. that address is not real, bestie, stop pointing at it.[EINVAL]β thename, namespace, oruioargument is invalid. one of the three, or maybe all three, we're not judging (we're a little judging).[EOPNOTSUPP]β the file system does not supportVOP_GETEXTATTR(). she literally cannot, and will not. periodt. π
π SEE ALSO π
go read these next, they're all part of the same friend group:
π BUGS π
okay so this is the messy part and we need to talk about it. by passing in the empty string as the attribute name, some file systems will return a list of defined names on the target vnode for the requested namespace.
and like... that's a bad API. straight up. the manpage said it, not me. it will be replaced by an explicit VOP. so yeah, it's deprecated behavior in spirit, it's a cursed little shortcut, and it's on its way out. don't build your whole personality around it. π
friendly reminder: this page is from the Debian distribution, dated December 23, 1999, and it's filed under VOP_GETEXTATTR(9) in the Kernel Developer's Manual. old but still serving. π
okay that's the whole page bestie, go read your extended attributes, stay locked, and slay π¦β¨ππ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1999, 2000, 2001, 2003 Robert N. M. Watson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms