title: How do I take an NFS file handle, and derive its fully-qualified path and extract the attributes of the file?
body: <p>This started as <a href="https://www.reddit.com/r/linux_programming/comments/hqeo5u/does_a_fscache_utility_already_exist_that_decodes/" rel="nofollow noreferrer">a more general question in r/linux_programming</a>, but seeing no responses there I want to ask a more basic question.</p>
  <p>Once I have an NFS file handle (for the sake of discussion say I've worked out even under volatile file handles in NFSv4 it is a valid file handle), is there a sequence of library calls to derive its fully-qualified path? The <a href="https://www.kernel.org/doc/html/latest/filesystems/path-lookup.html" rel="nofollow noreferrer">kernel documentation on just local filesystem path lookup</a>, and <a href="https://pdfs.semanticscholar.org/4511/4ae3c9263c2ad9e042d66b224e5de3e649d4.pdf" rel="nofollow noreferrer">an old paper on a proposed NFS path lookup scheme change</a>, convinces me this is not code I want to roll my own.</p>
  <p>Going through documentation and source code, so far I suspect the code has to be sitting in between either or both the VFS and NFS filesystem device driver code bases. But I must not be understanding the interrelationships between VFS, NFS and the kernel because I've been unable to find out how to bridge the gap between the NFS file handle and the path we are used to seeing in the shell. There is discussion about the open(2) call in userspace translating to a vnode in VFS, and from there to an NFS file handle, but I'm trying to go in the reverse direction (because FS-Cache stores the NFS file handle as near as I can tell from reading the NFS source, not a path value that could be passed to open(2)).</p>
  <p>Related to this is how to get the file attributes like ownership, permissions, dates, etc., if I have an NFS file handle, and the file is cached within FS-Cache. I think I can get the inode and then get the attributes that way, but I'm trying to avoid having to hit NFS and stay in FS-Cache, and especially avoid performing a find(1) for the inode.</p>