On Wed, Jul 16, 2008 at 04:02:21PM -0700, Adam Burkepile wrote: > Begin forwarded message: > > >From: Adam Burkepile <sadpoti%gmail.com@localhost> > >Date: July 16, 2008 2:30:54 PM PDT > >To: tech-kern%netbsd.org@localhost > >Subject: Re: inode open > > > >On Jul 16, 2008, at 1:34 PM, Jason Thorpe wrote: > > > >> > >>On Jul 16, 2008, at 7:47 AM, Matt Thomas wrote: > >> > >>>Besides the fhopen(2) previously mentioned, this isn't available > >>>because it would break the security used by unix. > >> > >> > >>Other Unix-like platforms (Mac OS X) can do this without breaking > >>the Unix security model. We should be able to, too. > >> > >>Of course, a good starting point for Adam is -- "What do you need > >>this for?" > >> > >>-- thorpej > >> > > > > > > > >Yes, I asked because was searching for the functions to do this and > >found a webpage that had this information: > > > >Under Mach there were the following system calls for this purpose: > > > >iopen(dev, inode) -- return a filehandle for file inode on device dev. > >icreate(dev) -- returns the inode number of a new file on device dev. > >istat(dev, inode, statb) -- fill in the statb structure. > >iinc(dev,inode) -- increase the disk link count of the file > >idec(dev, inode) -- decrease the disk link count (remove file when 0). > > > >and wanted to find an equivalent function(s) in NetBSD. > > > > > >I need this functionality because the way I was going to implement > >subfiles is have the basefile inode structure hold a new field, > >which is the inode number of the "subfile directory". This directory > >would hold the basefile's subfiles. > > > >So, what I really should of asked, "Is there a way of opening up a > >directory (not a regular file) based on the inode number, like a > >special opendir()". No, nor do you need one. You're violating layering abstractions here, and that's why you can't do what you are asking to do. You can however do what you really want to do. subfile_open() & friends will make a VOP call into the file system. You'll pass in the vnode of the file whose subfile you want to open, and a name of the component. Maybe also some flags: VOP_SUBOPEN(struct vnode *vp, struct vnode **vpp, const char *path, int flags) vpp points to where the file system will put the vnode for the subfile. VOP_SUBOPEN() (or whatever it gets named) for ffs will find the directory inode number you mention above, and have ffs instantiate a vnode for that directory. Look at how VFS_FHTOVP() works to see how to get a vnode for an inode #. You then look in this directory for the name you want, and instantiate a vnode just like any other lookup. Take care, Bill
Attachment:
pgpcxbX0ip3zy.pgp
Description: PGP signature