Re: Finding one parent for a vnode born under X
Re: Finding one parent for a vnode born under X
- Subject: Re: Finding one parent for a vnode born under X
- From: Umesh Vaishampayan <email@hidden>
- Date: Fri, 14 Feb 2003 11:35:02 -0800
On Friday, February 14, 2003, at 10:41 AM, Quinn wrote:
At 12:15 +0100 14/2/03, Stiphane Sudre wrote:
Would there be a way to find 1 vnode parent of a vnode (on any FS)?
Not reliably. [In presence of hard links on files, *which* parent would
you like to know about?
All of the following is based on my somewhat limited understanding of
VFS. Caveat emptor.
If the vnode references a directory, you can just VOP_LOOKUP "..".
This is, however, subject to vnode locking constraints.
Conceptually, yes. In practice, it's not that simple. Just doing a
VOP_LOOKUP() in a KEXT will give you a directory vnode, however you
will fail to detect escaping out of a chroot(2) [*security hole*]. And
you may fail to cross the mount points [which may or may not be what
you want].
For files, I don't think there's a file system independent way. For
Macintosh file systems (HFS, HFS Plus, AFP), you can probably doing
this by:
1. using VOP_GETATTRLIST with ATTR_CMN_PAROBJID to get the parent's
CNID and then
It has the same problem described above...
2. using volfs to get the vnode from the CNID.
<http://developer.apple.com/qa/qa2001/qa1113.html>
Grrrr..... *NO!*. Do not use volfs in a KEXT.
--Umesh
This second alternative is a significant binary compatibility
liability. It's *definitely* not appropriate to put it in a product
that you're going to ship to lots of users. OTOH, it's more
compatible than going poking around in v_data.
S+E
--
Quinn "The Eskimo!"
<http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications,
Hardware
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.
--
Umesh Vaishampayan
Mac OS X - Kernel
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.