vn_fullpath question.

Matthew Dillon dillon at apollo.backplane.com
Tue Nov 28 19:53:13 UTC 2006


:Nikolay, you might want to have a look at the source code
:of the "lsof" utility (ports/sysutils/lsof).  It is able
:to display path names for file descriptors.  Maybe you can
:borrow an idea from it.
:
:It might also be worth mentioning that our friends from the
:DragonFly BSD project (derived from FreeBSD 4) have added
:the ability to display path names to their version of the
:fstat utility.  You can look at their cvsweb here:
:http://www.dragonflybsd.org/cvsweb/src/usr.bin/fstat/
:
:However, I suspect that they have also made modifications
:to the kernel interfaces in order to support the fstat
:utility, so their improvements to that utility might not
:be applicable to FreeBSD.
:
:Best regards
:   Oliver

    I'm afraid we did.  All file pointers now also store a fully referenced
    namecache pointer along with the vnode pointer.  In fact, it is now
    a triplet: Vnode, mount pointer, namecache pointer.

    In DragonFly the mount pointer is now mandatory for all access through
    a file descriptor.  The namecache pointer is mandatory for all 
    directory descriptors (all directory traversals are namecache-centric
    in DragonFly, not vnode-centric, so the ncp is needed in case a program
    does a fchdir() call).   Also, in DragonFly, the namecache is synchronized
    with file operations such as rename and delete, rather then globally
    invalidated.  The ncp is actually moved and renamed on rename.

    This had the happy side effect of making it possible for the fstat 
    utility to list the actual file path used to open the file or directory.

    I don't think any of it can be applied to FreeBSD, unless you want
    to spend two man-months (or more) redoing your namecache.  It was a
    horrendous amount of work.

					-Matt
					Matthew Dillon 
					<dillon at backplane.com>


More information about the freebsd-hackers mailing list