VOP_IOCTL(9)

πŸ’… VOP_IOCTL(9) β€” device specific control πŸ’…

okay bestie, welcome to section 9 of the Kernel Developer's Manual (kernel devs only, this is the deep end of the pool πŸŠβ™€οΈ), where we talk about VOP_IOCTL β€” aka device specific control. yes it's giving "mysterious", no we're not scared, let's go πŸŽ€


✨ SYNOPSIS ✨

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

int
VOP_IOCTL(struct vnode *vp, u_long command, caddr_t data, int fflag,
    struct ucred *cred, struct thread *td);

literally just copy that verbatim, don't be cute with it, the compiler will NOT find it funny 😭


🌸 DESCRIPTION 🌸

so the whole vibe here is: manipulate a file in device dependent ways. that's it. that's the job. it's the kernel-level version of pressing buttons on a gadget and hoping it does something iconic ✨

its arguments are, one by one, no skipping:

  • vp β€” the vnode of the file (normally representing a device). yes bestie, normally a device, that's the whole point of this function πŸ’–
  • command β€” the device specific operation to perform. the little request, the ask, the "hey do this thing" πŸ‘‘
  • data β€” extra data for the specified operation. the lil care package that goes along with the command 🎁
  • fflag β€” Some flags ??? 🫠 (not me typing that, that's literally what the page says, no cap β€” the docs themselves are shrugging)
  • cred β€” the caller's credentials. who's asking, and are they allowed πŸͺͺ
  • td β€” the calling thread. the main character in question 🧚
⚠️ and here's the tea: most file systems do not implement this entry point. so if you're out here expecting every filesystem to answer the phone... they will not. it's giving "left on read" πŸ’€

πŸ”’ LOCKS πŸ”’

the file should not be locked on entry. like, don't come in holding the lock, that's rude, we're not doing that πŸ™ˆ


🌈 RETURN VALUES 🌈

  • if it's successful, zero is returned. slay. perfect. no notes πŸ’š
  • otherwise, an appropriate error code comes back at you 😀
  • and if the ioctl is not recognized or not handled, ENOTTY should be returned. that's the "idk what you're talking about bestie" error, and it is the correct response, don't fight it 🚫

πŸ‘€ SEE ALSO πŸ‘€

go read that one too, it's the supportive bestie to this page 🫢


✍️ AUTHORS ✍️

this manual page was written by Doug Rabson. thank you Doug, king behavior πŸ‘‘πŸ’–


and that's the whole page, babe! this little beauty lives on Debian and it's dated July 24, 1996 β€” yes, 1996, it's vintage, it's archival, it predates most of us and it still eats πŸ’…βœ¨ periodt.

πŸ“¦ where this page comes from