aboutsummaryrefslogtreecommitdiffstats
path: root/hw/9pfs/virtio-9p.c
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
commit532decb715acb2e03bbe373c9bd914a8499896ee (patch)
tree9a0592b04564b0d2d2f61b2ef9dd2600c218c6eb /hw/9pfs/virtio-9p.c
parent0174fe73e605311598d9e7f03e95be9705a3e0e7 (diff)
hw/9pfs: Add fs driver specific details to fscontext
Add a new context flag PATHNAME_FSCONTEXT and indicate whether the fs driver track fid using path names. Also add a private pointer that help us to track fs driver specific values in there Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Diffstat (limited to 'hw/9pfs/virtio-9p.c')
-rw-r--r--hw/9pfs/virtio-9p.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 82f1db570..2a6895396 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -2332,6 +2332,7 @@ out_nofid:
complete_pdu(s, pdu, err);
}
+/* Only works with path name based fid */
static void v9fs_remove(void *opaque)
{
int32_t fid;
@@ -2347,6 +2348,11 @@ static void v9fs_remove(void *opaque)
err = -EINVAL;
goto out_nofid;
}
+ /* if fs driver is not path based, return EOPNOTSUPP */
+ if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {
+ err = -EOPNOTSUPP;
+ goto out_err;
+ }
/*
* IF the file is unlinked, we cannot reopen
* the file later. So don't reclaim fd
@@ -2467,6 +2473,7 @@ out_nofid:
return err;
}
+/* Only works with path name based fid */
static void v9fs_rename(void *opaque)
{
int32_t fid;
@@ -2486,13 +2493,18 @@ static void v9fs_rename(void *opaque)
goto out_nofid;
}
BUG_ON(fidp->fid_type != P9_FID_NONE);
-
- qemu_co_rwlock_wrlock(&s->rename_lock);
+ /* if fs driver is not path based, return EOPNOTSUPP */
+ if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {
+ err = -EOPNOTSUPP;
+ goto out;
+ }
+ v9fs_path_write_lock(s);
err = v9fs_complete_rename(s, fidp, newdirfid, &name);
- qemu_co_rwlock_unlock(&s->rename_lock);
+ v9fs_path_unlock(s);
if (!err) {
err = offset;
}
+out:
put_fid(s, fidp);
out_nofid:
complete_pdu(s, pdu, err);
@@ -2553,9 +2565,11 @@ static int v9fs_complete_renameat(V9fsState *s, int32_t olddirfid,
if (err < 0) {
goto out;
}
- /* Only for path based fid we need to do the below fixup */
- v9fs_fix_fid_paths(s, &olddirfidp->path, old_name,
- &newdirfidp->path, new_name);
+ if (s->ctx.flags & PATHNAME_FSCONTEXT) {
+ /* Only for path based fid we need to do the below fixup */
+ v9fs_fix_fid_paths(s, &olddirfidp->path, old_name,
+ &newdirfidp->path, new_name);
+ }
out:
if (olddirfidp) {
put_fid(s, olddirfidp);
@@ -2578,9 +2592,9 @@ static void v9fs_renameat(void *opaque)
pdu_unmarshal(pdu, offset, "dsds", &olddirfid,
&old_name, &newdirfid, &new_name);
- qemu_co_rwlock_wrlock(&s->rename_lock);
+ v9fs_path_write_lock(s);
err = v9fs_complete_renameat(s, olddirfid, &old_name, newdirfid, &new_name);
- qemu_co_rwlock_unlock(&s->rename_lock);
+ v9fs_path_unlock(s);
if (!err) {
err = offset;
}