From patchwork Thu Aug 4 10:06:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harsh Prateek Bora X-Patchwork-Id: 108402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EC349B6F70 for ; Thu, 4 Aug 2011 20:06:44 +1000 (EST) Received: from localhost ([::1]:38367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qoup6-0008U6-Jo for incoming@patchwork.ozlabs.org; Thu, 04 Aug 2011 06:06:40 -0400 Received: from eggs.gnu.org ([140.186.70.92]:41050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qoup0-0008Tp-CN for qemu-devel@nongnu.org; Thu, 04 Aug 2011 06:06:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qouoz-0004cc-BO for qemu-devel@nongnu.org; Thu, 04 Aug 2011 06:06:34 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:45831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qouoy-0004au-Rg for qemu-devel@nongnu.org; Thu, 04 Aug 2011 06:06:33 -0400 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp02.au.ibm.com (8.14.4/8.13.1) with ESMTP id p74A02Lo025714 for ; Thu, 4 Aug 2011 20:00:02 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p74A5Qe31020088 for ; Thu, 4 Aug 2011 20:05:26 +1000 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 p74A6FGA000716 for ; Thu, 4 Aug 2011 20:06:15 +1000 Received: from harshbora.in.ibm.com ([9.124.46.158]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p74A6Cqv000643; Thu, 4 Aug 2011 20:06:14 +1000 From: Harsh Prateek Bora To: qemu-devel@nongnu.org Date: Thu, 4 Aug 2011 15:36:11 +0530 Message-Id: <1312452371-10375-3-git-send-email-harsh@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1.1 In-Reply-To: <1312452371-10375-1-git-send-email-harsh@linux.vnet.ibm.com> References: <1312452371-10375-1-git-send-email-harsh@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 202.81.31.144 Cc: aneesh.kumar@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 2/2] i_generation / st_gen support for handle based fs driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch provides support for st_gen for handle based fs type server. Currently the support is provided for ext4, btrfs, reiserfs and xfs. Signed-off-by: Harsh Prateek Bora --- hw/9pfs/virtio-9p-handle.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c index 548a841..8dff662 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,25 @@ 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; + + fd = handle_open(ctx, path, mode); + if(fd < 0) { + return fd; + } + return ioctl(fd, FS_IOC_GETVERSION, st_gen); + +} + +/* 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 +572,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) {