From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDZmo-0002Kx-Lc for qemu-devel@nongnu.org; Tue, 11 Oct 2011 06:42:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDZmg-0001L6-7f for qemu-devel@nongnu.org; Tue, 11 Oct 2011 06:42:14 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:52652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDZmf-0001KD-5V for qemu-devel@nongnu.org; Tue, 11 Oct 2011 06:42:06 -0400 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245]) by e23smtp05.au.ibm.com (8.14.4/8.13.1) with ESMTP id p9BAZ7wd016459 for ; Tue, 11 Oct 2011 21:35:07 +1100 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9BAg1PT2568322 for ; Tue, 11 Oct 2011 21:42:01 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9BAg1FH022892 for ; Tue, 11 Oct 2011 21:42:01 +1100 From: "Aneesh Kumar K.V" Date: Tue, 11 Oct 2011 16:11:41 +0530 Message-Id: <1318329705-3179-10-git-send-email-aneesh.kumar@linux.vnet.ibm.com> In-Reply-To: <1318329705-3179-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1318329705-3179-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH -V2 09/13] hw/9pfs: Add 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: aliguori@us.ibm.com, Harsh Prateek Bora , "Aneesh Kumar K.V" From: Harsh Prateek Bora Signed-off-by: Harsh Prateek Bora Signed-off-by: Aneesh Kumar K.V --- hw/9pfs/virtio-9p-handle.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c index fbe3e62..525c91a 100644 --- a/hw/9pfs/virtio-9p-handle.c +++ b/hw/9pfs/virtio-9p-handle.c @@ -21,6 +21,24 @@ #include #include #include +#include +#ifdef CONFIG_LINUX_MAGIC_H +#include +#endif +#include + +#ifndef XFS_SUPER_MAGIC +#define XFS_SUPER_MAGIC 0x58465342 +#endif +#ifndef EXT2_SUPER_MAGIC +#define EXT2_SUPER_MAGIC 0xEF53 +#endif +#ifndef REISERFS_SUPER_MAGIC +#define REISERFS_SUPER_MAGIC 0x52654973 +#endif +#ifndef BTRFS_SUPER_MAGIC +#define BTRFS_SUPER_MAGIC 0x9123683E +#endif struct handle_data { int mountfd; @@ -550,9 +568,31 @@ static int handle_unlinkat(FsContext *ctx, V9fsPath *dir, return ret; } +static int handle_ioc_getversion(FsContext *ctx, V9fsPath *path, + mode_t st_mode, uint64_t *st_gen) +{ + int err, fd; + + /* + * Do not try to open special files like device nodes, fifos etc + * We can get fd for regular files and directories only + */ + if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) { + return 0; + } + fd = handle_open(ctx, path, O_RDONLY); + if (fd < 0) { + return fd; + } + err = ioctl(fd, FS_IOC_GETVERSION, st_gen); + handle_close(ctx, fd); + return err; +} + static int handle_init(FsContext *ctx) { int ret, mnt_id; + struct statfs stbuf; struct file_handle fh; struct handle_data *data = g_malloc(sizeof(struct handle_data)); @@ -561,6 +601,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 EXT2_SUPER_MAGIC: + 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.5.4