1 /*
2 * 9p backend
3 *
4 * Copyright IBM, Corp. 2011
5 *
6 * Authors:
7 * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 */
13
14 /*
15 * Not so fast! You might want to read the 9p developer docs first:
16 * https://wiki.qemu.org/Documentation/9p
17 */
18
19 #include "qemu/osdep.h"
20 #include "fsdev/qemu-fsdev.h"
21 #include "qemu/thread.h"
22 #include "qemu/main-loop.h"
23 #include "coth.h"
24
v9fs_co_llistxattr(V9fsPDU * pdu,V9fsPath * path,void * value,size_t size)25 int coroutine_fn v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value,
26 size_t size)
27 {
28 int err;
29 V9fsState *s = pdu->s;
30
31 if (v9fs_request_cancelled(pdu)) {
32 return -EINTR;
33 }
34 v9fs_path_read_lock(s);
35 v9fs_co_run_in_worker(
36 {
37 err = s->ops->llistxattr(&s->ctx, path, value, size);
38 if (err < 0) {
39 err = -errno;
40 }
41 });
42 v9fs_path_unlock(s);
43 return err;
44 }
45
v9fs_co_lgetxattr(V9fsPDU * pdu,V9fsPath * path,V9fsString * xattr_name,void * value,size_t size)46 int coroutine_fn v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path,
47 V9fsString *xattr_name, void *value,
48 size_t size)
49 {
50 int err;
51 V9fsState *s = pdu->s;
52
53 if (v9fs_request_cancelled(pdu)) {
54 return -EINTR;
55 }
56 v9fs_path_read_lock(s);
57 v9fs_co_run_in_worker(
58 {
59 err = s->ops->lgetxattr(&s->ctx, path,
60 xattr_name->data,
61 value, size);
62 if (err < 0) {
63 err = -errno;
64 }
65 });
66 v9fs_path_unlock(s);
67 return err;
68 }
69
v9fs_co_lsetxattr(V9fsPDU * pdu,V9fsPath * path,V9fsString * xattr_name,void * value,size_t size,int flags)70 int coroutine_fn v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path,
71 V9fsString *xattr_name, void *value,
72 size_t size, int flags)
73 {
74 int err;
75 V9fsState *s = pdu->s;
76
77 if (v9fs_request_cancelled(pdu)) {
78 return -EINTR;
79 }
80 v9fs_path_read_lock(s);
81 v9fs_co_run_in_worker(
82 {
83 err = s->ops->lsetxattr(&s->ctx, path,
84 xattr_name->data, value,
85 size, flags);
86 if (err < 0) {
87 err = -errno;
88 }
89 });
90 v9fs_path_unlock(s);
91 return err;
92 }
93
v9fs_co_lremovexattr(V9fsPDU * pdu,V9fsPath * path,V9fsString * xattr_name)94 int coroutine_fn v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path,
95 V9fsString *xattr_name)
96 {
97 int err;
98 V9fsState *s = pdu->s;
99
100 if (v9fs_request_cancelled(pdu)) {
101 return -EINTR;
102 }
103 v9fs_path_read_lock(s);
104 v9fs_co_run_in_worker(
105 {
106 err = s->ops->lremovexattr(&s->ctx, path, xattr_name->data);
107 if (err < 0) {
108 err = -errno;
109 }
110 });
111 v9fs_path_unlock(s);
112 return err;
113 }
114