Open by handle
Aneesh Kumar is trying to change that situation with a short patch series adding two new system calls:
int name_to_handle(const char *name, struct file_handle *handle);
int open_by_handle(struct file_handle *handle, int flags);
The first takes the given name and looks up the associated file handle, which is returned in the handle structure. That handle can then be passed to open_by_handle() to get an open file descriptor for the file. Only privileged users can call open_by_handle(); otherwise it could be possible for a malicious local user to bypass the normal permission checks on the directories in the path to a specific file.
Why would an application developer want to open a file in two steps instead of just calling open()? It comes down to the ability to write filesystem servers that run in user space. Such a server could use name_to_handle() to generate handles for files on the underlying filesystem; those handles are then passed to the filesystem's clients. At some future time, the client can pass the handle back to actually open the file. This type of feature is also already used with the XFS filesystem for backup and restore operations and with a hierarchical storage management system.
Discussion of these system calls has been minimal, thus far. It does seem
that some work will be needed still to better describe what a file handle
really is, and, in particular, what its expected lifetime will be. Without
some clarity in that area, it will be hard to write applications which can
make proper use of file handles.
| Index entries for this article | |
|---|---|
| Kernel | File handle |
| Kernel | Filesystems/Network |
(Log in to post comments)
Open by handle
Posted Feb 25, 2010 11:36 UTC (Thu) by nix (subscriber, #2304) [Link]
I suppose that the handle being an opaque structure adds enough freedom that filesystems won't be locked into a seekdir()-style nightmare... if need be you could simply wrap the filename into a structure and return that :)
Open by handle
Posted Feb 25, 2010 17:27 UTC (Thu) by kvaneesh (subscriber, #45646) [Link]
Open by handle
Posted Feb 25, 2010 17:36 UTC (Thu) by nix (subscriber, #2304) [Link]
It'll work even less well with unlink(). In fact, if we don't have a close_handle(), this gives rise to exactly the same resource usage and when-can-we-recycle-handles problems that telldir() has got. Whatever goes into a handle, it essentially has to be correlated with the inode number, and thus physically present on and persistent in the FS, and won't work well with FAT. Unsurprisingly these are the same constraints imposed by NFS
server support. )
I hope open_by_handle() is allowed to return -ESTALE...
Open by handle
Posted Feb 25, 2010 17:47 UTC (Thu) by kvaneesh (subscriber, #45646) [Link]
Open by handle
Posted Feb 25, 2010 20:50 UTC (Thu) by nix (subscriber, #2304) [Link]
that. Apologies.
Open by handle
Posted Mar 9, 2010 13:07 UTC (Tue) by philippe.deniel (guest, #64210) [Link]
