|
Justin M. Forbes |
45e84a |
From ed6857bf98e6c8b8080be208ffe15bb678591466 Mon Sep 17 00:00:00 2001
|
|
Justin M. Forbes |
45e84a |
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
|
|
Justin M. Forbes |
45e84a |
Date: Sun, 4 Dec 2011 22:35:28 +0530
|
|
Justin M. Forbes |
45e84a |
Subject: [PATCH 07/25] hw/9pfs: Use the correct file descriptor in Fsdriver
|
|
Justin M. Forbes |
45e84a |
Callback
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
Fsdriver callback that operate on file descriptor need to
|
|
Justin M. Forbes |
45e84a |
differentiate between directory fd and file fd.
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
Based on the original patch from Sassan Panahinejad <sassan@sassan.me.uk>
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
|
|
Justin M. Forbes |
45e84a |
---
|
|
Justin M. Forbes |
45e84a |
fsdev/file-op-9p.h | 4 ++--
|
|
Justin M. Forbes |
45e84a |
hw/9pfs/cofile.c | 4 ++--
|
|
Justin M. Forbes |
45e84a |
hw/9pfs/virtio-9p-handle.c | 28 ++++++++++++++++++++++------
|
|
Justin M. Forbes |
45e84a |
hw/9pfs/virtio-9p-local.c | 36 ++++++++++++++++++++++++++----------
|
|
Justin M. Forbes |
45e84a |
hw/9pfs/virtio-9p-synth.c | 5 +++--
|
|
Justin M. Forbes |
45e84a |
5 files changed, 55 insertions(+), 22 deletions(-)
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
|
|
Justin M. Forbes |
45e84a |
index 1928da2..a85ecd3 100644
|
|
Justin M. Forbes |
45e84a |
--- a/fsdev/file-op-9p.h
|
|
Justin M. Forbes |
45e84a |
+++ b/fsdev/file-op-9p.h
|
|
Justin M. Forbes |
45e84a |
@@ -112,10 +112,10 @@ typedef struct FileOperations
|
|
Justin M. Forbes |
45e84a |
ssize_t (*pwritev)(FsContext *, V9fsFidOpenState *,
|
|
Justin M. Forbes |
45e84a |
const struct iovec *, int, off_t);
|
|
Justin M. Forbes |
45e84a |
int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *);
|
|
Justin M. Forbes |
45e84a |
- int (*fstat)(FsContext *, V9fsFidOpenState *, struct stat *);
|
|
Justin M. Forbes |
45e84a |
+ int (*fstat)(FsContext *, int, V9fsFidOpenState *, struct stat *);
|
|
Justin M. Forbes |
45e84a |
int (*rename)(FsContext *, const char *, const char *);
|
|
Justin M. Forbes |
45e84a |
int (*truncate)(FsContext *, V9fsPath *, off_t);
|
|
Justin M. Forbes |
45e84a |
- int (*fsync)(FsContext *, V9fsFidOpenState *, int);
|
|
Justin M. Forbes |
45e84a |
+ int (*fsync)(FsContext *, int, V9fsFidOpenState *, int);
|
|
Justin M. Forbes |
45e84a |
int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf);
|
|
Justin M. Forbes |
45e84a |
ssize_t (*lgetxattr)(FsContext *, V9fsPath *,
|
|
Justin M. Forbes |
45e84a |
const char *, void *, size_t);
|
|
Justin M. Forbes |
45e84a |
diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c
|
|
Justin M. Forbes |
45e84a |
index 586b038..b15838c 100644
|
|
Justin M. Forbes |
45e84a |
--- a/hw/9pfs/cofile.c
|
|
Justin M. Forbes |
45e84a |
+++ b/hw/9pfs/cofile.c
|
|
Justin M. Forbes |
45e84a |
@@ -71,7 +71,7 @@ int v9fs_co_fstat(V9fsPDU *pdu, V9fsFidState *fidp, struct stat *stbuf)
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
v9fs_co_run_in_worker(
|
|
Justin M. Forbes |
45e84a |
{
|
|
Justin M. Forbes |
45e84a |
- err = s->ops->fstat(&s->ctx, &fidp->fs, stbuf);
|
|
Justin M. Forbes |
45e84a |
+ err = s->ops->fstat(&s->ctx, fidp->fid_type, &fidp->fs, stbuf);
|
|
Justin M. Forbes |
45e84a |
if (err < 0) {
|
|
Justin M. Forbes |
45e84a |
err = -errno;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
@@ -192,7 +192,7 @@ int v9fs_co_fsync(V9fsPDU *pdu, V9fsFidState *fidp, int datasync)
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
v9fs_co_run_in_worker(
|
|
Justin M. Forbes |
45e84a |
{
|
|
Justin M. Forbes |
45e84a |
- err = s->ops->fsync(&s->ctx, &fidp->fs, datasync);
|
|
Justin M. Forbes |
45e84a |
+ err = s->ops->fsync(&s->ctx, fidp->fid_type, &fidp->fs, datasync);
|
|
Justin M. Forbes |
45e84a |
if (err < 0) {
|
|
Justin M. Forbes |
45e84a |
err = -errno;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c
|
|
Justin M. Forbes |
45e84a |
index a62f690..f97d898 100644
|
|
Justin M. Forbes |
45e84a |
--- a/hw/9pfs/virtio-9p-handle.c
|
|
Justin M. Forbes |
45e84a |
+++ b/hw/9pfs/virtio-9p-handle.c
|
|
Justin M. Forbes |
45e84a |
@@ -255,10 +255,17 @@ static int handle_mkdir(FsContext *fs_ctx, V9fsPath *dir_path,
|
|
Justin M. Forbes |
45e84a |
return ret;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
-static int handle_fstat(FsContext *fs_ctx, V9fsFidOpenState *fs,
|
|
Justin M. Forbes |
45e84a |
- struct stat *stbuf)
|
|
Justin M. Forbes |
45e84a |
+static int handle_fstat(FsContext *fs_ctx, int fid_type,
|
|
Justin M. Forbes |
45e84a |
+ V9fsFidOpenState *fs, struct stat *stbuf)
|
|
Justin M. Forbes |
45e84a |
{
|
|
Justin M. Forbes |
45e84a |
- return fstat(fs->fd, stbuf);
|
|
Justin M. Forbes |
45e84a |
+ int fd;
|
|
Justin M. Forbes |
45e84a |
+
|
|
Justin M. Forbes |
45e84a |
+ if (fid_type == P9_FID_DIR) {
|
|
Justin M. Forbes |
45e84a |
+ fd = dirfd(fs->dir);
|
|
Justin M. Forbes |
45e84a |
+ } else {
|
|
Justin M. Forbes |
45e84a |
+ fd = fs->fd;
|
|
Justin M. Forbes |
45e84a |
+ }
|
|
Justin M. Forbes |
45e84a |
+ return fstat(fd, stbuf);
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
static int handle_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name,
|
|
Justin M. Forbes |
45e84a |
@@ -395,12 +402,21 @@ static int handle_remove(FsContext *ctx, const char *path)
|
|
Justin M. Forbes |
45e84a |
return -1;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
-static int handle_fsync(FsContext *ctx, V9fsFidOpenState *fs, int datasync)
|
|
Justin M. Forbes |
45e84a |
+static int handle_fsync(FsContext *ctx, int fid_type,
|
|
Justin M. Forbes |
45e84a |
+ V9fsFidOpenState *fs, int datasync)
|
|
Justin M. Forbes |
45e84a |
{
|
|
Justin M. Forbes |
45e84a |
+ int fd;
|
|
Justin M. Forbes |
45e84a |
+
|
|
Justin M. Forbes |
45e84a |
+ if (fid_type == P9_FID_DIR) {
|
|
Justin M. Forbes |
45e84a |
+ fd = dirfd(fs->dir);
|
|
Justin M. Forbes |
45e84a |
+ } else {
|
|
Justin M. Forbes |
45e84a |
+ fd = fs->fd;
|
|
Justin M. Forbes |
45e84a |
+ }
|
|
Justin M. Forbes |
45e84a |
+
|
|
Justin M. Forbes |
45e84a |
if (datasync) {
|
|
Justin M. Forbes |
45e84a |
- return qemu_fdatasync(fs->fd);
|
|
Justin M. Forbes |
45e84a |
+ return qemu_fdatasync(fd);
|
|
Justin M. Forbes |
45e84a |
} else {
|
|
Justin M. Forbes |
45e84a |
- return fsync(fs->fd);
|
|
Justin M. Forbes |
45e84a |
+ return fsync(fd);
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c
|
|
Justin M. Forbes |
45e84a |
index 99ef0cd..371a94d 100644
|
|
Justin M. Forbes |
45e84a |
--- a/hw/9pfs/virtio-9p-local.c
|
|
Justin M. Forbes |
45e84a |
+++ b/hw/9pfs/virtio-9p-local.c
|
|
Justin M. Forbes |
45e84a |
@@ -366,11 +366,18 @@ out:
|
|
Justin M. Forbes |
45e84a |
return err;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
-static int local_fstat(FsContext *fs_ctx,
|
|
Justin M. Forbes |
45e84a |
+static int local_fstat(FsContext *fs_ctx, int fid_type,
|
|
Justin M. Forbes |
45e84a |
V9fsFidOpenState *fs, struct stat *stbuf)
|
|
Justin M. Forbes |
45e84a |
{
|
|
Justin M. Forbes |
45e84a |
- int err;
|
|
Justin M. Forbes |
45e84a |
- err = fstat(fs->fd, stbuf);
|
|
Justin M. Forbes |
45e84a |
+ int err, fd;
|
|
Justin M. Forbes |
45e84a |
+
|
|
Justin M. Forbes |
45e84a |
+ if (fid_type == P9_FID_DIR) {
|
|
Justin M. Forbes |
45e84a |
+ fd = dirfd(fs->dir);
|
|
Justin M. Forbes |
45e84a |
+ } else {
|
|
Justin M. Forbes |
45e84a |
+ fd = fs->fd;
|
|
Justin M. Forbes |
45e84a |
+ }
|
|
Justin M. Forbes |
45e84a |
+
|
|
Justin M. Forbes |
45e84a |
+ err = fstat(fd, stbuf);
|
|
Justin M. Forbes |
45e84a |
if (err) {
|
|
Justin M. Forbes |
45e84a |
return err;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
@@ -381,19 +388,19 @@ static int local_fstat(FsContext *fs_ctx,
|
|
Justin M. Forbes |
45e84a |
mode_t tmp_mode;
|
|
Justin M. Forbes |
45e84a |
dev_t tmp_dev;
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
- if (fgetxattr(fs->fd, "user.virtfs.uid",
|
|
Justin M. Forbes |
45e84a |
+ if (fgetxattr(fd, "user.virtfs.uid",
|
|
Justin M. Forbes |
45e84a |
&tmp_uid, sizeof(uid_t)) > 0) {
|
|
Justin M. Forbes |
45e84a |
stbuf->st_uid = tmp_uid;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
- if (fgetxattr(fs->fd, "user.virtfs.gid",
|
|
Justin M. Forbes |
45e84a |
+ if (fgetxattr(fd, "user.virtfs.gid",
|
|
Justin M. Forbes |
45e84a |
&tmp_gid, sizeof(gid_t)) > 0) {
|
|
Justin M. Forbes |
45e84a |
stbuf->st_gid = tmp_gid;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
- if (fgetxattr(fs->fd, "user.virtfs.mode",
|
|
Justin M. Forbes |
45e84a |
+ if (fgetxattr(fd, "user.virtfs.mode",
|
|
Justin M. Forbes |
45e84a |
&tmp_mode, sizeof(mode_t)) > 0) {
|
|
Justin M. Forbes |
45e84a |
stbuf->st_mode = tmp_mode;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
- if (fgetxattr(fs->fd, "user.virtfs.rdev",
|
|
Justin M. Forbes |
45e84a |
+ if (fgetxattr(fd, "user.virtfs.rdev",
|
|
Justin M. Forbes |
45e84a |
&tmp_dev, sizeof(dev_t)) > 0) {
|
|
Justin M. Forbes |
45e84a |
stbuf->st_rdev = tmp_dev;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
@@ -592,12 +599,21 @@ static int local_remove(FsContext *ctx, const char *path)
|
|
Justin M. Forbes |
45e84a |
return remove(rpath(ctx, path, buffer));
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
-static int local_fsync(FsContext *ctx, V9fsFidOpenState *fs, int datasync)
|
|
Justin M. Forbes |
45e84a |
+static int local_fsync(FsContext *ctx, int fid_type,
|
|
Justin M. Forbes |
45e84a |
+ V9fsFidOpenState *fs, int datasync)
|
|
Justin M. Forbes |
45e84a |
{
|
|
Justin M. Forbes |
45e84a |
+ int fd;
|
|
Justin M. Forbes |
45e84a |
+
|
|
Justin M. Forbes |
45e84a |
+ if (fid_type == P9_FID_DIR) {
|
|
Justin M. Forbes |
45e84a |
+ fd = dirfd(fs->dir);
|
|
Justin M. Forbes |
45e84a |
+ } else {
|
|
Justin M. Forbes |
45e84a |
+ fd = fs->fd;
|
|
Justin M. Forbes |
45e84a |
+ }
|
|
Justin M. Forbes |
45e84a |
+
|
|
Justin M. Forbes |
45e84a |
if (datasync) {
|
|
Justin M. Forbes |
45e84a |
- return qemu_fdatasync(fs->fd);
|
|
Justin M. Forbes |
45e84a |
+ return qemu_fdatasync(fd);
|
|
Justin M. Forbes |
45e84a |
} else {
|
|
Justin M. Forbes |
45e84a |
- return fsync(fs->fd);
|
|
Justin M. Forbes |
45e84a |
+ return fsync(fd);
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
diff --git a/hw/9pfs/virtio-9p-synth.c b/hw/9pfs/virtio-9p-synth.c
|
|
Justin M. Forbes |
45e84a |
index f573616..92e0b09 100644
|
|
Justin M. Forbes |
45e84a |
--- a/hw/9pfs/virtio-9p-synth.c
|
|
Justin M. Forbes |
45e84a |
+++ b/hw/9pfs/virtio-9p-synth.c
|
|
Justin M. Forbes |
45e84a |
@@ -166,7 +166,7 @@ static int v9fs_synth_lstat(FsContext *fs_ctx,
|
|
Justin M. Forbes |
45e84a |
return 0;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
-static int v9fs_synth_fstat(FsContext *fs_ctx,
|
|
Justin M. Forbes |
45e84a |
+static int v9fs_synth_fstat(FsContext *fs_ctx, int fid_type,
|
|
Justin M. Forbes |
45e84a |
V9fsFidOpenState *fs, struct stat *stbuf)
|
|
Justin M. Forbes |
45e84a |
{
|
|
Justin M. Forbes |
45e84a |
V9fsSynthOpenState *synth_open = fs->private;
|
|
Justin M. Forbes |
45e84a |
@@ -414,7 +414,8 @@ static int v9fs_synth_remove(FsContext *ctx, const char *path)
|
|
Justin M. Forbes |
45e84a |
return -1;
|
|
Justin M. Forbes |
45e84a |
}
|
|
Justin M. Forbes |
45e84a |
|
|
Justin M. Forbes |
45e84a |
-static int v9fs_synth_fsync(FsContext *ctx, V9fsFidOpenState *fs, int datasync)
|
|
Justin M. Forbes |
45e84a |
+static int v9fs_synth_fsync(FsContext *ctx, int fid_type,
|
|
Justin M. Forbes |
45e84a |
+ V9fsFidOpenState *fs, int datasync)
|
|
Justin M. Forbes |
45e84a |
{
|
|
Justin M. Forbes |
45e84a |
errno = ENOSYS;
|
|
Justin M. Forbes |
45e84a |
return 0;
|
|
Justin M. Forbes |
45e84a |
--
|
|
Justin M. Forbes |
45e84a |
1.7.7.5
|
|
Justin M. Forbes |
45e84a |
|