VOP_GETEXTATTR(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

✨ VOP_GETEXTATTR πŸ’…

okay so bestie, welcome to VOP_GETEXTATTR(9) from the Kernel Developer's Manual β€” this is the vnode call that pulls a named extended attribute off a file or directory. it's giving very "fetching the vibes attached to your file" energy, and honestly? iconic.


🌸 SYNOPSIS 🌸

like, first you gotta include these headers or nothing works, periodt:

#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);

πŸ¦‹ DESCRIPTION πŸ¦‹

this vnode call is your main character moment for retrieving a specific named extended attribute from a file or directory. slay.

its arguments are, in order:

  • vp β€” the vnode of the file or directory. like, the target.
  • attrnamespace β€” an integer constant telling you which extended attribute namespace the attribute name lives in. who's she hanging out with, basically.
  • name β€” pointer to a null-terminated character string containing the attribute name. no cap, it must be null-terminated.
  • uio β€” the location of the data to be read.
  • size β€” if it's not NULL, then on return it will contain the number of bytes required to read all of the attribute data. in most cases uio will be NULL when size is not, and vice versa. they're giving "you can't sit with us" to each other.
  • cred β€” the user credentials to use in authorizing the request.
  • td β€” the thread requesting the extended attribute.

lowkey important: 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 it's like a VIP pass for the kernel itself, iykyk.

extended attribute semantics may vary by file system implementing the call β€” every fs has her own little quirks. more info on extended attributes lives in extattr(9).


πŸ”’ LOCKS πŸ”’

the vnode will be locked on entry and should remain locked on return. no sneaky unlocking, bestie. that's the rule.


πŸ’– RETURN VALUES πŸ’–

on success, zero will be returned, and the uio structure will be updated to reflect data read. otherwise, an appropriate error code is returned. simple as that, periodt.


πŸ’€ ERRORS πŸ’€

okay so when things go wrong (and they might πŸ™ˆ), here's the tea:

  • [ENOATTR] β€” the requested attribute was not defined for this vnode. she's not here, bestie.
  • [EACCES] β€” the caller does not have the appropriate privilege. rude but fair.
  • [ENXIO] β€” the request was not valid in this file system for the specified vnode and attribute name. wrong fs, wrong vnode, wrong name β€” just wrong.
  • [ENOMEM] β€” sufficient memory is not available to fulfill the request. she's broke, no cap.
  • [EFAULT] β€” the uio structure refers to an invalid userspace address. bad pointer energy.
  • [EINVAL] β€” the name, namespace, or uio argument is invalid. invalid is invalid.
  • [EOPNOTSUPP] β€” the file system does not support VOP_GETEXTATTR(). she just can't, and that's okay.

πŸ‘‘ SEE ALSO πŸ‘‘

extattr(9), vnode(9), VOP_LISTEXTATTR(9), VOP_SETEXTATTR(9)

go read those too, they're literally the friend group.


πŸ™ˆ BUGS πŸ™ˆ

BIG warning bestie β€” 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. this is a bad API, and will be replaced by an explicit VOP. so like, it works, but it's giving beige flag. ⚠️


and that's the whole page, bestie! πŸ’…βœ¨

source vibes: Debian, dated December 23, 1999 β€” a true vintage icon. πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from