From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qr1T6-0005FN-4b for qemu-devel@nongnu.org; Wed, 10 Aug 2011 01:36:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qr1T1-0001x0-I2 for qemu-devel@nongnu.org; Wed, 10 Aug 2011 01:36:40 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:44449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qr1T0-0001tg-G4 for qemu-devel@nongnu.org; Wed, 10 Aug 2011 01:36:35 -0400 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by e28smtp07.in.ibm.com (8.14.4/8.13.1) with ESMTP id p7A5a3U9012276 for ; Wed, 10 Aug 2011 11:06:03 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p7A5a2LJ3125438 for ; Wed, 10 Aug 2011 11:06:02 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p7A5a2Eg012071 for ; Wed, 10 Aug 2011 15:36:02 +1000 From: Harsh Prateek Bora Date: Wed, 10 Aug 2011 11:06:02 +0530 Message-Id: <1312954562-17540-3-git-send-email-harsh@linux.vnet.ibm.com> In-Reply-To: <1312954562-17540-1-git-send-email-harsh@linux.vnet.ibm.com> References: <1312954562-17540-1-git-send-email-harsh@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2 2/2] i_generation / st_gen support for handle based fs driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aneesh.kumar@linux.vnet.ibm.com v2: - close fd after use in handle_ioc_getversion Signed-off-by: Harsh Prateek Bora --- hw/9pfs/virtio-9p-handle.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c index 548a841..98178e9 100644 --- a/hw/9pfs/virtio-9p-handle.c +++ b/hw/9pfs/virtio-9p-handle.c @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include struct handle_data { int mountfd; @@ -543,9 +546,26 @@ static int handle_unlinkat(FsContext *ctx, V9fsPath *dir, return ret; } +static int handle_ioc_getversion(FsContext *ctx, V9fsPath *path, uint64_t *st_gen) +{ + int mode = 0600; + int fd, err; + + fd = handle_open(ctx, path, mode); + if(fd < 0) { + return fd; + } + err = ioctl(fd, FS_IOC_GETVERSION, st_gen); + handle_close(ctx, fd); + return err; +} + +/* XFS_SUPER_MAGIC not available in linux/fs.h */ +#define XFS_SUPER_MAGIC 0x58465342 static int handle_init(FsContext *ctx) { int ret, mnt_id; + struct statfs stbuf; struct file_handle fh; struct handle_data *data = qemu_malloc(sizeof(struct handle_data)); data->mountfd = open(ctx->fs_root, O_DIRECTORY); @@ -553,6 +573,17 @@ static int handle_init(FsContext *ctx) ret = data->mountfd; goto err_out; } + ret = statfs(ctx->fs_root, &stbuf); + if(!ret) { + switch (stbuf.f_type) { + case EXT4_SUPER_MAGIC: /* same magic val for ext2/3 */ + case BTRFS_SUPER_MAGIC: + case REISERFS_SUPER_MAGIC: + case XFS_SUPER_MAGIC: + ctx->exops.get_st_gen = handle_ioc_getversion; + break; + } + } memset(&fh, 0, sizeof(struct file_handle)); ret = name_to_handle(data->mountfd, ".", &fh, &mnt_id, 0); if (ret && errno == EOVERFLOW) { -- 1.7.1.1