VOP_ATTRIB(9)

πŸ’– VOP_ATTRIB β€” it's giving "get and set attributes" energy ✨

okay bestie so this is from the Kernel Developer's Manual, section 9, and the page is called VOP_ATTRIB(9) πŸŽ€ buckle up because we're talking about VOP_GETATTR and VOP_SETATTR, the duo that gets and sets attributes on a file or directory. no cap. πŸ¦‹


✨ NAME ✨

VOP_GETATTR, VOP_SETATTR β€” get and set attributes on a file or directory πŸ’…


🌸 SYNOPSIS 🌸

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

int
VOP_GETATTR(struct vnode *vp, struct vattr *vap, struct ucred *cred);

int
VOP_SETATTR(struct vnode *vp, struct vattr *vap, struct ucred *cred);

like. look at those signatures. iconic. 🫢


πŸ’… DESCRIPTION πŸ’…

These entry points manipulate various attributes of a file or directory, and the list is lowkey long: file permissions, owner, group, size, access time and modification time. all of it. the whole glow-up kit. ✨

The arguments are:

  • vp β€” The vnode of the file. πŸŽ€
  • vap β€” The attributes of the file.
  • cred β€” The user credentials of the calling process.
okay this part matters so listen up fr fr πŸ‘‘

Attributes which are not being modified by VOP_SETATTR() should be set to the value VNOVAL. VATTR_NULL() may be used to clear all the values, and should generally be used to reset the contents of *vap prior to setting specific values.

so yes: VNOVAL for the stuff you're not touching, VATTR_NULL() to wipe *vap clean before you set the specific values you actually care about. reset first, then slay. πŸ§Όβž‘οΈπŸ’…


πŸ”’ LOCKS πŸ”’

VOP_GETATTR() expects the vnode to be locked on entry and will leave the vnode locked on return. The lock type can be either shared or exclusive. so flexible. we love options. πŸ’–

VOP_SETATTR() expects the vnode to be locked on entry and will leave the vnode locked on return. The lock type must be exclusive. no shared vibes allowed here bestie, it's exclusive-only main character energy. πŸ‘‘


🌈 RETURN VALUES 🌈

VOP_GETATTR() returns 0 if it was able to retrieve the attribute data via *vap, otherwise an appropriate error is returned.

VOP_SETATTR() returns zero if the attributes were changed successfully, otherwise an appropriate error is returned. periodt. πŸ’…


πŸ’€ ERRORS πŸ’€

  • [EPERM] β€” The file is immutable. like it said no and meant it. 🚫
  • [EACCES] β€” The caller does not have permission to modify the file or directory attributes. bestie you do not have the range. 😭
  • [EROFS] β€” The file system is read-only. nothing to see here, it's frozen. 🧊

πŸ‘€ SEE ALSO πŸ‘€

VFS(9), vnode(9), VOP_ACCESS(9) β€” go read those next, iykyk πŸ“šβœ¨


🫢 AUTHORS 🫢

This manual page was written by Doug Rabson. ty king for your service πŸ™πŸ‘‘


and that's the whole page bestie!! πŸŽ€ this version lives over on Debian, dated August 29, 2008, so like… vintage but still eating. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from