From: "Venkateswararao Jujjuri (JV)" <jvrao@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Sripathi Kodi <sripathik@in.ibm.com>,
aliguori@us.ibm.com, "M. Mohan Kumar" <mohan@in.ibm.com>,
Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH-V3 02/24] qemu: virtio-9p: Implement statfs support in server
Date: Thu, 22 Jul 2010 08:57:49 -0700 [thread overview]
Message-ID: <1279814291-8301-3-git-send-email-jvrao@linux.vnet.ibm.com> (raw)
In-Reply-To: <1279814291-8301-1-git-send-email-jvrao@linux.vnet.ibm.com>
From: M. Mohan Kumar <mohan@in.ibm.com>
Implement statfs support in qemu server based on Sripathi's
initial statfs patch.
Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
hw/file-op-9p.h | 1 +
hw/virtio-9p-local.c | 6 ++++
hw/virtio-9p.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
hw/virtio-9p.h | 24 +++++++++++++++++++
4 files changed, 94 insertions(+), 0 deletions(-)
diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h
index a741c93..dd82ac7 100644
--- a/hw/file-op-9p.h
+++ b/hw/file-op-9p.h
@@ -74,6 +74,7 @@ typedef struct FileOperations
int (*rename)(FsContext *, const char *, const char *);
int (*truncate)(FsContext *, const char *, off_t);
int (*fsync)(FsContext *, int);
+ int (*statfs)(FsContext *s, const char *path, struct statfs *stbuf);
void *opaque;
} FileOperations;
#endif
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 04f7f6f..8ae5b07 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -469,6 +469,11 @@ static int local_fsync(FsContext *ctx, int fd)
return fsync(fd);
}
+static int local_statfs(FsContext *s, const char *path, struct statfs *stbuf)
+{
+ return statfs(rpath(s, path), stbuf);
+}
+
FileOperations local_ops = {
.lstat = local_lstat,
.readlink = local_readlink,
@@ -496,4 +501,5 @@ FileOperations local_ops = {
.utime = local_utime,
.remove = local_remove,
.fsync = local_fsync,
+ .statfs = local_statfs,
};
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index e41c51e..20560e5 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -2145,9 +2145,72 @@ out:
qemu_free(vs);
}
+static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
+{
+ return s->ops->statfs(&s->ctx, path->data, stbuf);
+}
+
+static void v9fs_statfs_post_statfs(V9fsState *s, V9fsStatfsState *vs, int err)
+{
+ if (err) {
+ err = -errno;
+ goto out;
+ }
+
+ vs->v9statfs.f_type = vs->stbuf.f_type;
+ vs->v9statfs.f_bsize = vs->stbuf.f_bsize;
+ vs->v9statfs.f_blocks = vs->stbuf.f_blocks;
+ vs->v9statfs.f_bfree = vs->stbuf.f_bfree;
+ vs->v9statfs.f_bavail = vs->stbuf.f_bavail;
+ vs->v9statfs.f_files = vs->stbuf.f_files;
+ vs->v9statfs.f_ffree = vs->stbuf.f_ffree;
+ vs->v9statfs.fsid_val = (unsigned int) vs->stbuf.f_fsid.__val[0] |
+ (unsigned long long)vs->stbuf.f_fsid.__val[1] << 32;
+ vs->v9statfs.f_namelen = vs->stbuf.f_namelen;
+
+ vs->offset += pdu_marshal(vs->pdu, vs->offset, "ddqqqqqqd",
+ vs->v9statfs.f_type, vs->v9statfs.f_bsize, vs->v9statfs.f_blocks,
+ vs->v9statfs.f_bfree, vs->v9statfs.f_bavail, vs->v9statfs.f_files,
+ vs->v9statfs.f_ffree, vs->v9statfs.fsid_val,
+ vs->v9statfs.f_namelen);
+
+out:
+ complete_pdu(s, vs->pdu, vs->offset);
+ qemu_free(vs);
+}
+
+static void v9fs_statfs(V9fsState *s, V9fsPDU *pdu)
+{
+ V9fsStatfsState *vs;
+ ssize_t err = 0;
+
+ vs = qemu_malloc(sizeof(*vs));
+ vs->pdu = pdu;
+ vs->offset = 7;
+
+ memset(&vs->v9statfs, 0, sizeof(vs->v9statfs));
+
+ pdu_unmarshal(vs->pdu, vs->offset, "d", &vs->fid);
+
+ vs->fidp = lookup_fid(s, vs->fid);
+ if (vs->fidp == NULL) {
+ err = -ENOENT;
+ goto out;
+ }
+
+ err = v9fs_do_statfs(s, &vs->fidp->path, &vs->stbuf);
+ v9fs_statfs_post_statfs(s, vs, err);
+ return;
+
+out:
+ complete_pdu(s, vs->pdu, err);
+ qemu_free(vs);
+}
+
typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
static pdu_handler_t *pdu_handlers[] = {
+ [P9_TSTATFS] = v9fs_statfs,
[P9_TVERSION] = v9fs_version,
[P9_TATTACH] = v9fs_attach,
[P9_TSTAT] = v9fs_stat,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 9286f59..992c765 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -13,6 +13,8 @@
#define VIRTIO_9P_MOUNT_TAG 0
enum {
+ P9_TSTATFS = 8,
+ P9_RSTATFS,
P9_TVERSION = 100,
P9_RVERSION,
P9_TAUTH = 102,
@@ -252,6 +254,28 @@ struct virtio_9p_config
uint8_t tag[0];
} __attribute__((packed));
+typedef struct V9fsStatfs
+{
+ uint32_t f_type;
+ uint32_t f_bsize;
+ uint64_t f_blocks;
+ uint64_t f_bfree;
+ uint64_t f_bavail;
+ uint64_t f_files;
+ uint64_t f_ffree;
+ uint64_t fsid_val;
+ uint32_t f_namelen;
+} V9fsStatfs;
+
+typedef struct V9fsStatfsState {
+ V9fsPDU *pdu;
+ size_t offset;
+ int32_t fid;
+ V9fsStatfs v9statfs;
+ V9fsFidState *fidp;
+ struct statfs stbuf;
+} V9fsStatfsState;
+
extern size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
size_t offset, size_t size, int pack);
--
1.6.5.2
next prev parent reply other threads:[~2010-07-22 15:55 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-22 15:57 [Qemu-devel] [PATCH-V3 00/24] Consolidated VirtFS work Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 01/24] qemu: virtio-9p: Recognize 9P2000.L protocol Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` Venkateswararao Jujjuri (JV) [this message]
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 03/24] virtio-9p: Return correct error from v9fs_remove Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 04/24] [V4] virtio-9p: readdir implementation for 9p2000.L Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 05/24] virtio-9p: Compute iounit based on host filesystem block size Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 06/24] virtio-9p: getattr server implementation for 9P2000.L protocol Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 07/24] virtio-9p: Do not reset atime Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 08/24] [virtio-9p] Make v9fs_do_utimensat accept timespec structures instead of v9stat Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 09/24] virtio-9p: Implement server side of setattr for 9P2000.L protocol Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 10/24] [virtio-9p] Implement TLINK for 9P2000.L Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 11/24] [virtio-9p] Define and implement TSYMLINK " Venkateswararao Jujjuri (JV)
2010-07-22 15:57 ` [Qemu-devel] [PATCH-V3 12/24] [virtio-9p] This patch implements TLCREATE for 9p2000.L protocol Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 13/24] qemu: virtio-9p: Implement TMKNOD Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 14/24] qemu: virtio-9p: Implement TMKDIR Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 15/24] rename - change name of file or directory Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 16/24] qemu: virtio-9p: Implement LOPEN Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 17/24] virtio-9p: Add fidtype so that we can do type specific operation Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 18/24] virtio-9p: Implement TXATTRWALK Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 19/24] virtio-9p: Implement TXATTRCREATE Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 20/24] virtio-9p: Hide user.virtfs xattr in case of mapped security Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 21/24] virtio-9p: Add SM_NONE security model Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 22/24] virtio-9p: Use lchown which won't follow symlink Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 23/24] virtio-9p: Fix the memset usage Venkateswararao Jujjuri (JV)
2010-07-22 15:58 ` [Qemu-devel] [PATCH-V3 24/24] virtio-9p: Fix formatting issues in v9fs_wstat_post_chown() Venkateswararao Jujjuri (JV)
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=1279814291-8301-3-git-send-email-jvrao@linux.vnet.ibm.com \
--to=jvrao@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=mohan@in.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=sripathik@in.ibm.com \
/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).