[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 3/3] hw/9pfs: Add synth fs test
From: |
Aneesh Kumar K.V |
Subject: |
[Qemu-devel] [RFC PATCH 3/3] hw/9pfs: Add synth fs test |
Date: |
Fri, 9 Sep 2011 16:37:13 +0530 |
Signed-off-by: Aneesh Kumar K.V <address@hidden>
---
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