| From: |
| "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> |
| To: |
| hch@infradead.org, viro@zeniv.linux.org.uk |
| Subject: |
| [RFC PATCH] Generic name to handle and open by handle syscalls |
| Date: |
| Fri, 19 Feb 2010 11:12:26 +0530 |
| Cc: |
| linux-fsdevel@vger.kernel.org |
| Archive-link: |
| Article, Thread
|
The below set of patches implement open by handle support using exportfs
operations. This allows user space application to map a file name to file
handle and later open the file using handle. This should be usable
for userspace NFS and 9P server. XFS already support this with the ioctls
XFS_IOC_PATH_TO_HANDLE and XFS_IOC_OPEN_BY_HANDLE.
Example program:
-------------
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
struct file_handle {
int handle_size;
int handle_type;
void *f_handle;
};
int main(int argc, char *argv[])
{
int ret;
int fd;
char buf[100];
struct file_handle fh;
fh.handle_type = 0;
fh.handle = malloc(100);
fh.handle_size = 100/sizeof(int);
errno = 0;
ret = syscall(338, argv[1], &fh);
if (ret) {
perror("Error:");
exit(1);
}
printf("%d\n",fh.handle_size);
fd = syscall(339, &fh, O_RDONLY);
if (fd <= 0 ) {
perror("Error:");
exit(1);
}
printf("fd = %d\n", fd);
memset(buf, 0 , 100);
while (read(fd, buf, 100) > 0) {
printf("%s", buf);
memset(buf, 0 , 100);
}
return 0;
}
-aneesh
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html