From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Aneesh Kumar K.V" Subject: [RFC PATCH] Generic name to handle and open by handle syscalls Date: Fri, 19 Feb 2010 11:12:26 +0530 Message-ID: <1266558149-11460-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Cc: linux-fsdevel@vger.kernel.org To: hch@infradead.org, viro@zeniv.linux.org.uk Return-path: Received: from e28smtp01.in.ibm.com ([122.248.162.1]:58024 "EHLO e28smtp01.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751993Ab0BSFmo (ORCPT ); Fri, 19 Feb 2010 00:42:44 -0500 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp01.in.ibm.com (8.14.3/8.13.1) with ESMTP id o1J5gefW002401 for ; Fri, 19 Feb 2010 11:12:40 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o1J5geI63022962 for ; Fri, 19 Feb 2010 11:12:40 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o1J5geOs023777 for ; Fri, 19 Feb 2010 16:42:40 +1100 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 #include #include #include #include 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