VFS_FHTOVP(9)

πŸ’– VFS_FHTOVP β€” the Kernel Developer's Manual era πŸ’–

okay bestie, gather round, we're doing kernel stuff today and honestly? it's giving iconic. this is the VFS_FHTOVP(9) page from the Kernel Developer's Manual, and by the end of this you're gonna know exactly how to turn an NFS filehandle into a vnode. no cap. πŸ¦‹


✨ NAME ✨

VFS_FHTOVP β€” turn an NFS filehandle into a vnode

like, the glow-up from "mystery filehandle" to "actual vnode" πŸ’…


🌸 SYNOPSIS 🌸

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

int
VFS_FHTOVP(struct mount *mp, struct fid *fhp, int flags,
    struct vnode **vpp);

πŸ‘‘ DESCRIPTION πŸ‘‘

so the VFS_FHTOVP() macro is what the NFS server uses to turn an NFS filehandle into a vnode. that's the whole vibe. the NFS server hands over a filehandle, and this thing is like "say less" and produces a vnode. πŸ”₯

the arguments it expects are, in order, bestie:

  • mp β€” the file system. your main character fs, literally.
  • fhp β€” the filehandle to convert. the one that needs the transformation.
  • flags β€” extra locking flags that get passed straight through to vget(9). important: file systems are allowed to just ignore flags and use LK_EXCLUSIVE instead. so don't be shocked if that happens, it's fully within their rights. 😌
  • vpp β€” the return parameter where the new locked vnode lands. your prize at the end of the quest. πŸŽ€

here's the tea about the filehandle itself: its contents are defined by the file system and are not examined by any other part of the system. so the fs is the only one who knows what's inside, and everyone else is like "not my business, not my problem". πŸ’€

what the filehandle should contain is enough info to:

  • uniquely identify a file within the file system, and
  • notice when a file has been removed and the file system resources have been reused for a brand new file.

for instance β€” and this is the classic example β€” the UFS file system stores the inode number and the inode generation counter in its filehandle. two pieces of info, one very clever system. slay. ✨

🫢 heads up bestie: a call to VFS_FHTOVP() should generally be preceded by a call to VFS_CHECKEXP(9), which checks whether the file is actually accessible to the client. like, do the vibe check first. check the exp. then convert.

🌈 RETURN VALUES 🌈

the locked vnode for the file gets returned in *vpp. that's it, that's the return value. locked and loaded. πŸ”’


πŸ¦‹ SEE ALSO πŸ¦‹

go read them, they're all part of the same friend group fr fr.


πŸ’œ AUTHORS πŸ’œ

this manual page was written by Doug Rabson. legend behaviour, honestly. πŸ‘‘


okay that's the whole page, bestie β€” you're officially caught up on VFS_FHTOVP. and just so you have the receipts: this one comes from the Debian crew and it's dated May 19, 2019. πŸŽ€ stay locked, stay iconic, and remember β€” check the exp before you convert. periodt. πŸ’…πŸŒΈ

πŸ“¦ where this page comes from