On Sep 30, 2009, at 6:25 AM, mominabrar < email@hidden> wrote: On Tue, Sep 29, 2009 at 10:33 PM, Terry Lambert <email@hidden> wrote:
If you are implementing an "ls", you are doing it un user space so what KPI is visible in the kernel should not be an issue for you.
For most things the correct API is getattrlist. For private communication between your "ls" and a specific FS implementation (presumably your own), fsctl/ioctl/fcntl are the interfaces to use. If
Right the ioctl interface is what i am using.and traditionally namei and family of functions could be used to get this done.
Traditionally, you would iterate the directory contents from user space, and then use an ioctl() from user space on the directory fd you used to iterate the contents and pass down sufficient information in the ioctl(), such as the st_ino field obtained through the normal iteration, to not need to do a namei().
The only namei() occurs internally to get the fd for the directory back to user space; the fd on the directory in user space is the rendezvous to get the ioctl() back into the fs implementation, and the st_ino is the rendezvous from the ioctl() to get from the fs-specific ioctl() code to a particular file to retrieve the additional fs-specific information that doesn't fit into the getattrlist() paradigm.
So I'm not seeing why you think you need to do a namei() in your ioctl() code.
With xnu-1228.9.75 these set of APIs are no longer available.
Correct. People were abusing them to do file I/O from the kernel, and getting the UIO_SYSSPACE wrong, resulting in crashes. File I/O belongs in user space; if you were doing it to load firmware for a driver, as opposed to doing something innocent like using it to write an extended ls command, we'd tell you to use a user space helper program.
Also vnode_lookup internally uses these.( xnu-1228.9.59 atleast )
What i want to know what replaces these set of APIs (or their functionality ) in the new kernel.
vnode_lookup().
The SnowLeopard sources were posted a couple weeks ago, so you need to look again.
NOTE: as Anubhav rightly pointed out i can use vnode_lookup, but that needs a copyin of user name buffer to pass it to vnode_lookup .
Yes. It requires that the file path name lookup be initiated with a path name originating in user space. Your ls program should have this information available to it already, although as I pointed out above, a lookup operation should not be needed (and indeed will likely be useless overhead).
-- Terry
|