qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aneesh.kumar@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH 2/2] i_generation / st_gen support for handle based fs driver
Date: Thu,  4 Aug 2011 15:36:11 +0530	[thread overview]
Message-ID: <1312452371-10375-3-git-send-email-harsh@linux.vnet.ibm.com> (raw)
In-Reply-To: <1312452371-10375-1-git-send-email-harsh@linux.vnet.ibm.com>

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 <harsh@linux.vnet.ibm.com>
---
 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 <sys/socket.h>
 #include <sys/un.h>
 #include <attr/xattr.h>
+#include <linux/fs.h>
+#include <linux/magic.h>
+#include <sys/ioctl.h>
 
 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) {
-- 
1.7.1.1

  parent reply	other threads:[~2011-08-04 10:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-04 10:06 [Qemu-devel] [PATCH 0/2] Support for i_generation / st_gen in 9p server Harsh Prateek Bora
2011-08-04 10:06 ` [Qemu-devel] [PATCH 1/2] i_generation / st_gen support for local fs type Harsh Prateek Bora
2011-08-04 10:17   ` Stefan Hajnoczi
2011-08-04 10:06 ` Harsh Prateek Bora [this message]
2011-08-04 10:21   ` [Qemu-devel] [PATCH 2/2] i_generation / st_gen support for handle based fs driver Stefan Hajnoczi
2011-08-04 11:20     ` Aneesh Kumar K.V
2011-08-04 11:47       ` Stefan Hajnoczi
2011-08-04 12:03         ` Aneesh Kumar K.V
2011-08-04 14:31           ` Stefan Hajnoczi
2011-08-04 18:45             ` Aneesh Kumar K.V
2011-08-04 21:57               ` Stefan Hajnoczi
2011-08-05  6:40                 ` Aneesh Kumar K.V
2011-08-05  9:24                   ` Stefan Hajnoczi
2011-08-05 11:32                     ` Aneesh Kumar K.V
2011-08-05 12:53                       ` Stefan Hajnoczi
2011-08-10 15:17                         ` Stefan Hajnoczi
2011-08-10 15:17                           ` Stefan Hajnoczi
2011-08-10 17:33                           ` Aneesh Kumar K.V
2011-08-11  7:16                           ` Harsh Bora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1312452371-10375-3-git-send-email-harsh@linux.vnet.ibm.com \
    --to=harsh@linux.vnet.ibm.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).