vn_fullpath question.
Robert Watson
rwatson at FreeBSD.org
Tue Nov 28 12:29:45 UTC 2006
On Mon, 27 Nov 2006, Nikolay Pavlov wrote:
> Hi. I am trying to extend fstat utility, so that it can use name cache to
> recreate full path at least for text. I have found vn_fullpath function
> usefull in this case. I am newbe in C, so it could be stupid question, but
> could someone explaine what is "struct thread *td" in argument list of this
> function. Is this the thread which opened the vnode initially or it is the
> thread which searches for the vnode? i.e. fstat thread. In any case how i
> can get this *td structure?
vn_fullpath(9) is a kernel API, not a user API, so can only be invoked from
kernel space. There are unimplemented, undocumented prototypes in the system
call table for __getpath_fromfd() and __getpath_fromaddr(), which are
presumably intended (with adequate permissions) to allow converting file
descriptor indexes into paths, etc. I think Peter dropped them in, but I'm
not sure if he's posted patches.
It's worth also remembering that paths are slightly confusing things, that
really only exist at time-of-lookup. The path to an object may vary by
process (due to chroot, etc), for example, or objects may no longer have paths
(be unlinked). It's also the case that two objects might have the same "path"
due to synthetic objects like /proc/curproc, overlayed mountpoints, etc.
vn_fullpath(9) makes a "best effort" based on the contents of the name cache,
but can fail to produce meaningful or any results.
Robert N M Watson
Computer Laboratory
University of Cambridge
More information about the freebsd-hackers
mailing list