VOP_SETEXTATTR(9)

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

πŸ’… VOP_SETEXTATTR(9) β€” the vnode extended-attribute-setter manual page, bestie edition

okay so you're in the Kernel Developer's Manual section 9, and we're talking about VOP_SETEXTATTR β€” setting a named extended attribute for a vnode. yes, the kernel's little sticky-notes-on-files situation. let's get into it 🫢


✨ NAME ✨

VOP_SETEXTATTR β€” set named extended attribute for a vnode

🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/vnode.h>
#include <sys/extattr.h>

int
VOP_SETEXTATTR(struct vnode *vp, int attrnamespace, const char *name,
    struct uio *uio, struct ucred *cred, struct thread *td);

πŸ¦‹ DESCRIPTION πŸ¦‹

This vnode call is literally how you set a specific named extended attribute on a file or directory. main character energy for metadata, no cap.

Its arguments are, in order, because the order matters bestie:

  • vp β€” the vnode of the file or directory. the whole point, honestly.
  • attrnamespace β€” an integer constant indicating which extended attribute namespace the attribute name lives in. which little club is this attribute in πŸ’…
  • name β€” pointer to a null-terminated character string containing the attribute name.
  • uio β€” the location of the data to be read or written.
  • cred β€” the user credentials to use in authorizing the request.
  • td β€” the thread setting the extended attribute. hi thread πŸ‘‹

The uio structure is used in a manner similar to the argument of the same name in VOP_WRITE(9). However β€” and this is the important part β€” since extended attributes provide a strict "name=value" semantic, non-zero offsets will be rejected. so don't come in here with your little offsets, okay? it's giving invalid.

The uio pointer may be NULL to indicate that the specified extended attribute should be deleted. yes, deletion, through the set function. that's just how it is 😭

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 changes that the active process might not be permitted to make. (the kernel gets to skip the line sometimes, periodt.)

⚠️ Extended attribute semantics may vary by file system implementing the call. so your fave filesystem and your other fave filesystem might not agree on the details, and that's a real thing to keep in mind.

More information on extended attributes may be found in extattr(9). go read it, iykyk πŸ’–

πŸ”’ LOCKS πŸ”’

The vnode will be locked on entry and should remain locked on return. do not let go of the vnode. hold it. πŸ₯Ί

⭐ RETURN VALUES ⭐

If the extended attribute is successfully set, then zero is returned. otherwise, an appropriate error code is returned. zero = slay, anything else = vibe check failed.

πŸ’€ ERRORS πŸ’€

  • [EACCES] β€” The caller does not have the appropriate privilege.
  • [ENXIO] β€” The request was not valid in this file system for the specified vnode and attribute name.
  • [ENOMEM] β€” Insufficient memory available to fulfill the request.
  • [EFAULT] β€” The uio structure refers to an invalid userspace address.
  • [EINVAL] β€” The name, namespace, or uio argument is invalid.
  • [EOPNOTSUPP] β€” The file system does not support VOP_SETEXTATTR().
  • [ENOSPC] β€” The file system is out of space.
  • [EROFS] β€” The file system is read-only.

πŸ‘€ SEE ALSO πŸ‘€

extattr(9), vnode(9), VOP_GETEXTATTR(9), VOP_LISTEXTATTR(9)

the whole extended-attribute friend group, fr fr 🌈

πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Robert Watson. thank you Robert, icon behavior πŸŽ€


and that's the whole page bestie, every flag, every error, every pointer β€” nothing dropped, we ate and left no crumbs πŸ’œ

this edition came from Debian, dated December 23, 1999 β€” yeah, it's vintage vintage, but the lore still hits ✨

πŸ“¦ where this page comes from