Re: vn_fullpath question.
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 ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: vn_fullpath question.
Robert Watson wrote: 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. 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 -- Oliver Fromme, secnetix GmbH Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. That's what I love about GUIs: They make simple tasks easier, and complex tasks impossible. -- John William Chambless ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: vn_fullpath question.
On Tuesday, 28 November 2006 at 16:46:20 +0100, Oliver Fromme wrote: Robert Watson wrote: 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. 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. That's iteresting. The lsof utility is able to display original file path for me even for text vnodes. 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. Yes. They namecache API was totaly rewritten. Best regards Oliver -- Oliver Fromme, secnetix GmbH Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. That's what I love about GUIs: They make simple tasks easier, and complex tasks impossible. -- John William Chambless -- == - Best regards, Nikolay Pavlov. --- == ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: vn_fullpath question.
: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 [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
vn_fullpath question.
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? -- == - Best regards, Nikolay Pavlov. --- == ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: vn_fullpath question.
On Mon, Nov 27, 2006 at 02:07:40PM +0200, 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? There's a vn_fullpath(9) manpage which should answer this. Cheers, -- Ruslan Ermilov [EMAIL PROTECTED] FreeBSD committer pgpb1ni6jnw8i.pgp Description: PGP signature
Re: vn_fullpath question.
On Monday, 27 November 2006 at 18:20:03 +0300, Ruslan Ermilov wrote: On Mon, Nov 27, 2006 at 02:07:40PM +0200, 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? There's a vn_fullpath(9) manpage which should answer this. Yes i know about this man, but still not sure how to get *td structure. Cheers, -- Ruslan Ermilov [EMAIL PROTECTED] FreeBSD committer -- == - Best regards, Nikolay Pavlov. --- == ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: vn_fullpath question.
On Mon, Nov 27, 2006 at 05:37:12PM +0200, Nikolay Pavlov wrote: On Monday, 27 November 2006 at 18:20:03 +0300, Ruslan Ermilov wrote: On Mon, Nov 27, 2006 at 02:07:40PM +0200, 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? There's a vn_fullpath(9) manpage which should answer this. Yes i know about this man, but still not sure how to get *td structure. Depends on context. curthread perhaps. Cheers, -- Ruslan Ermilov [EMAIL PROTECTED] FreeBSD committer pgpuKoZzaKww3.pgp Description: PGP signature
Re: vn_fullpath question.
Nikolay Pavlov wrote: Yes i know about this man, but still not sure how to get *td structure. In kernel? There's a global variable curthread AFAIK. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: vn_fullpath question.
On Monday, 27 November 2006 at 17:12:44 +0100, Ivan Voras wrote: Nikolay Pavlov wrote: Yes i know about this man, but still not sure how to get *td structure. In kernel? There's a global variable curthread AFAIK. I am not sure. If i understand the fstat code right, it uses kvm interface to extract kinfo_proc structures from kernel space. textvp vnode pointer could be found in this structureis, but to perform vn_fullpath lookup according to man 9 vn_fullpath i need also thread pointer. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED] -- == - Best regards, Nikolay Pavlov. --- == ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]