aboutsummaryrefslogtreecommitdiff
path: root/hw/9pfs/coxattr.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-05-24 15:10:56 +0530
committerAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-09-22 21:38:52 +0530
commit02cb7f3a256517cbf3136caff2863fbafc57b540 (patch)
tree1d741e85dfe584b35a4a5e69a086d7b19fafd0ad /hw/9pfs/coxattr.c
parent70c18fc08bcc9e9bbd8c00ca5e694e07890687e5 (diff)
hw/9pfs: Use read-write lock for protecting fid path.
On rename we take the write lock and this ensure path doesn't change as we operate on them. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Diffstat (limited to 'hw/9pfs/coxattr.c')
-rw-r--r--hw/9pfs/coxattr.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/hw/9pfs/coxattr.c b/hw/9pfs/coxattr.c
index a289389e49..7b93c8f478 100644
--- a/hw/9pfs/coxattr.c
+++ b/hw/9pfs/coxattr.c
@@ -21,6 +21,7 @@ int v9fs_co_llistxattr(V9fsState *s, V9fsString *path, void *value, size_t size)
{
int err;
+ qemu_co_rwlock_rdlock(&s->rename_lock);
v9fs_co_run_in_worker(
{
err = s->ops->llistxattr(&s->ctx, path->data, value, size);
@@ -28,6 +29,7 @@ int v9fs_co_llistxattr(V9fsState *s, V9fsString *path, void *value, size_t size)
err = -errno;
}
});
+ qemu_co_rwlock_unlock(&s->rename_lock);
return err;
}
@@ -37,6 +39,7 @@ int v9fs_co_lgetxattr(V9fsState *s, V9fsString *path,
{
int err;
+ qemu_co_rwlock_rdlock(&s->rename_lock);
v9fs_co_run_in_worker(
{
err = s->ops->lgetxattr(&s->ctx, path->data,
@@ -46,6 +49,7 @@ int v9fs_co_lgetxattr(V9fsState *s, V9fsString *path,
err = -errno;
}
});
+ qemu_co_rwlock_unlock(&s->rename_lock);
return err;
}
@@ -55,6 +59,7 @@ int v9fs_co_lsetxattr(V9fsState *s, V9fsString *path,
{
int err;
+ qemu_co_rwlock_rdlock(&s->rename_lock);
v9fs_co_run_in_worker(
{
err = s->ops->lsetxattr(&s->ctx, path->data,
@@ -64,6 +69,7 @@ int v9fs_co_lsetxattr(V9fsState *s, V9fsString *path,
err = -errno;
}
});
+ qemu_co_rwlock_unlock(&s->rename_lock);
return err;
}
@@ -72,6 +78,7 @@ int v9fs_co_lremovexattr(V9fsState *s, V9fsString *path,
{
int err;
+ qemu_co_rwlock_rdlock(&s->rename_lock);
v9fs_co_run_in_worker(
{
err = s->ops->lremovexattr(&s->ctx, path->data,
@@ -80,5 +87,6 @@ int v9fs_co_lremovexattr(V9fsState *s, V9fsString *path,
err = -errno;
}
});
+ qemu_co_rwlock_unlock(&s->rename_lock);
return err;
}