aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-08-02 11:35:54 +0530
committerAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-09-22 21:38:52 +0530
commit0174fe73e605311598d9e7f03e95be9705a3e0e7 (patch)
treef0336eb862e56d38b3081079f5407d61b15ba7a0
parent2289be19aecc290263ef1f3c1f4a0e9ea32aaad6 (diff)
hw/9pfs: Add init callback to fs driver
This call back can be used to do fs driver specific initialization. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
-rw-r--r--fsdev/file-op-9p.h2
-rw-r--r--hw/9pfs/virtio-9p-device.c7
-rw-r--r--hw/9pfs/virtio-9p-local.c7
3 files changed, 14 insertions, 2 deletions
diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
index 8a7dbdbea4..5221d6d798 100644
--- a/fsdev/file-op-9p.h
+++ b/fsdev/file-op-9p.h
@@ -19,6 +19,7 @@
#include <sys/stat.h>
#include <sys/uio.h>
#include <sys/vfs.h>
+
#define SM_LOCAL_MODE_BITS 0600
#define SM_LOCAL_DIR_MODE_BITS 0700
@@ -66,6 +67,7 @@ void cred_init(FsCred *);
typedef struct FileOperations
{
+ int (*init)(struct FsContext *);
int (*lstat)(FsContext *, V9fsPath *, struct stat *);
ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
int (*chmod)(FsContext *, V9fsPath *, FsCred *);
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index eea70cb1f3..1ffe95b83b 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -45,7 +45,7 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
}
VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
- {
+{
V9fsState *s;
int i, len;
struct stat stat;
@@ -133,6 +133,11 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
s->fid_list = NULL;
qemu_co_rwlock_init(&s->rename_lock);
+ if (s->ops->init(&s->ctx) < 0) {
+ fprintf(stderr, "Virtio-9p Failed to initialize fs-driver with id:%s"
+ " and export path:%s\n", conf->fsdev_id, s->ctx.fs_root);
+ exit(1);
+ }
if (v9fs_init_worker_threads() < 0) {
fprintf(stderr, "worker thread initialization failed\n");
exit(1);
diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c
index 55f62f9570..61954fefec 100644
--- a/hw/9pfs/virtio-9p-local.c
+++ b/hw/9pfs/virtio-9p-local.c
@@ -21,7 +21,6 @@
#include <sys/un.h>
#include <attr/xattr.h>
-
static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
{
int err;
@@ -646,7 +645,13 @@ static int local_unlinkat(FsContext *ctx, V9fsPath *dir,
return ret;
}
+static int local_init(FsContext *ctx)
+{
+ return 0;
+}
+
FileOperations local_ops = {
+ .init = local_init,
.lstat = local_lstat,
.readlink = local_readlink,
.close = local_close,