From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [Qemu-devel] [RFC PATCH 3/3] hw/9pfs: Add synth fs test
Date: Fri, 9 Sep 2011 16:37:13 +0530 [thread overview]
Message-ID: <1315566433-16202-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1315566433-16202-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
hw/9pfs/virtio-9p-synth.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/hw/9pfs/virtio-9p-synth.c b/hw/9pfs/virtio-9p-synth.c
index 72a916c..cbf74e4 100644
--- a/hw/9pfs/virtio-9p-synth.c
+++ b/hw/9pfs/virtio-9p-synth.c
@@ -517,8 +517,21 @@ static int v9fs_synth_unlinkat(FsContext *ctx, V9fsPath *dir,
return -1;
}
+static ssize_t my_test_read(void *in_buf, int len, off_t offset, void *arg)
+{
+ int copy_len;
+ char buff[] = "Hello World\n";
+ if (offset >= sizeof(buff)) {
+ return 0;
+ }
+ copy_len = MIN(len, sizeof(buff));
+ memcpy(in_buf, buff + offset, copy_len);
+ return copy_len;
+}
+
static int v9fs_synth_init(FsContext *ctx)
{
+ V9fsSynthNode *node;
pthread_rwlockattr_t rwlockattr;
QLIST_INIT(&v9fs_synth_root.child);
@@ -533,6 +546,12 @@ static int v9fs_synth_init(FsContext *ctx)
/* Mark the subsystem is ready for use */
v9fs_synth_fs = 1;
+
+ /** create some new files as test */
+ qemu_v9fs_synth_mkdir(NULL, 0777, "test", &node);
+ qemu_v9fs_synth_mkdir(&v9fs_synth_root, 0777, "test2", &node);
+ qemu_v9fs_synth_add_file(node, 0777, "testfile",
+ my_test_read, NULL, NULL);
return 0;
}
--
1.7.4.1
prev parent reply other threads:[~2011-09-09 11:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-09 11:07 [Qemu-devel] [RFC PATCH] Implement synthetic file system support in qemu using 9p Aneesh Kumar K.V
2011-09-09 11:07 ` [Qemu-devel] [RFC PATCH 1/3] hw/9pfs: Abstract open state of fid to V9fsFidOpenState Aneesh Kumar K.V
2011-09-09 11:07 ` [Qemu-devel] [RFC PATCH 2/3] hw/9pfs: Add synthetic file system support using 9p Aneesh Kumar K.V
2011-09-09 11:07 ` Aneesh Kumar K.V [this message]
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=1315566433-16202-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=aliguori@us.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).