VOP_READDIR(9)

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

✨ VOP_READDIR(9) ✨

okay bestie, this is the VOP_READDIR(9) page from the Kernel Developer's Manual, and it's all about reading the contents of a directory. lowkey essential, highkey iconic πŸ’…


🌸 NAME 🌸

VOP_READDIR β€” read contents of a directory πŸŽ€


✨ SYNOPSIS ✨

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

int
VOP_READDIR(struct vnode *vp, struct uio *uio, struct ucred *cred,
    int *eofflag, int *ncookies, uint64_t **cookies);

πŸ’– DESCRIPTION πŸ’–

so like… this reads directory entries, bestie. that's the whole vibe. 🌈

  • vp β€” the vnode of the directory πŸ‘‘
  • uio β€” where to read the directory contents πŸ¦‹
  • cred β€” the caller's credentials πŸ”
  • eofflag β€” return end of file status (NULL if not wanted) 🌸
  • ncookies β€” number of directory cookies generated for NFS (NULL if not wanted) πŸ“
  • cookies β€” directory seek cookies generated for NFS (NULL if not wanted) πŸŽ€

The directory contents are read into struct dirent structures. If the on-disc data structures differ from this, then they should be translated. no cap, that part matters πŸ’―


πŸ”’ LOCKS πŸ”’

The directory should be locked on entry and will still be locked on exit. like, it stays locked the whole time, bestie β€” don't forget 😭


πŸŽ€ RETURN VALUES πŸŽ€

Zero is returned on success, otherwise an error code is returned. periodt. ✨

If this is called from the NFS server, the extra arguments eofflag, ncookies and cookies are given. The value of *eofflag should be set to TRUE if the end of the directory is reached while reading. πŸ‘‘

The directory seek cookies are returned to the NFS client and may be used later to restart a directory read part way through the directory. There should be one cookie returned per directory entry. The value of the cookie should be the offset within the directory where the on-disc version of the appropriate directory entry starts. iykyk 🧚

Memory for the cookies should be allocated using:

...;
*ncookies = number of entries read;
*cookies = malloc(*ncookies * sizeof(**cookies), M_TEMP, M_WAITOK);

🚨 ERRORS 🚨

  • [EINVAL] β€” An attempt was made to read from an illegal offset in the directory. rude, but okay πŸ’€
  • [EIO] β€” A read error occurred while reading the directory. 😭
  • [EINTEGRITY] β€” Corrupted data was detected while reading the directory. not the vibe bestie 🫠

πŸ‘€ SEE ALSO πŸ‘€

vnode(9) β€” go check it out, fr fr πŸ¦‹


πŸ’… AUTHORS πŸ’…

This manual page was written by Doug Rabson. iconic behavior, honestly πŸ‘‘


that's the whole page, bestie β€” signing off from the Debian edition, dated December 13, 2021, for VOP_READDIR(9) πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from