]> git.proxmox.com Git - mirror_qemu.git/blob - hw/9pfs/coxattr.c
hw/9pfs: Use read-write lock for protecting fid path.
[mirror_qemu.git] / hw / 9pfs / coxattr.c
1
2 /*
3 * Virtio 9p backend
4 *
5 * Copyright IBM, Corp. 2011
6 *
7 * Authors:
8 * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
9 *
10 * This work is licensed under the terms of the GNU GPL, version 2. See
11 * the COPYING file in the top-level directory.
12 *
13 */
14
15 #include "fsdev/qemu-fsdev.h"
16 #include "qemu-thread.h"
17 #include "qemu-coroutine.h"
18 #include "virtio-9p-coth.h"
19
20 int v9fs_co_llistxattr(V9fsState *s, V9fsString *path, void *value, size_t size)
21 {
22 int err;
23
24 qemu_co_rwlock_rdlock(&s->rename_lock);
25 v9fs_co_run_in_worker(
26 {
27 err = s->ops->llistxattr(&s->ctx, path->data, value, size);
28 if (err < 0) {
29 err = -errno;
30 }
31 });
32 qemu_co_rwlock_unlock(&s->rename_lock);
33 return err;
34 }
35
36 int v9fs_co_lgetxattr(V9fsState *s, V9fsString *path,
37 V9fsString *xattr_name,
38 void *value, size_t size)
39 {
40 int err;
41
42 qemu_co_rwlock_rdlock(&s->rename_lock);
43 v9fs_co_run_in_worker(
44 {
45 err = s->ops->lgetxattr(&s->ctx, path->data,
46 xattr_name->data,
47 value, size);
48 if (err < 0) {
49 err = -errno;
50 }
51 });
52 qemu_co_rwlock_unlock(&s->rename_lock);
53 return err;
54 }
55
56 int v9fs_co_lsetxattr(V9fsState *s, V9fsString *path,
57 V9fsString *xattr_name, void *value,
58 size_t size, int flags)
59 {
60 int err;
61
62 qemu_co_rwlock_rdlock(&s->rename_lock);
63 v9fs_co_run_in_worker(
64 {
65 err = s->ops->lsetxattr(&s->ctx, path->data,
66 xattr_name->data, value,
67 size, flags);
68 if (err < 0) {
69 err = -errno;
70 }
71 });
72 qemu_co_rwlock_unlock(&s->rename_lock);
73 return err;
74 }
75
76 int v9fs_co_lremovexattr(V9fsState *s, V9fsString *path,
77 V9fsString *xattr_name)
78 {
79 int err;
80
81 qemu_co_rwlock_rdlock(&s->rename_lock);
82 v9fs_co_run_in_worker(
83 {
84 err = s->ops->lremovexattr(&s->ctx, path->data,
85 xattr_name->data);
86 if (err < 0) {
87 err = -errno;
88 }
89 });
90 qemu_co_rwlock_unlock(&s->rename_lock);
91 return err;
92 }