]>
Commit | Line | Data |
---|---|---|
1ceffa54 | 1 | /* |
af8b38b0 | 2 | * 9p backend |
1ceffa54 AK |
3 | * |
4 | * Copyright IBM, Corp. 2011 | |
5 | * | |
6 | * Authors: | |
7 | * Aneesh Kumar K.V <[email protected]> | |
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 | ||
6f569084 CS |
14 | /* |
15 | * Not so fast! You might want to read the 9p developer docs first: | |
16 | * https://wiki.qemu.org/Documentation/9p | |
17 | */ | |
18 | ||
fbc04127 | 19 | #include "qemu/osdep.h" |
1ceffa54 | 20 | #include "fsdev/qemu-fsdev.h" |
1de7afc9 | 21 | #include "qemu/thread.h" |
10817bf0 | 22 | #include "qemu/coroutine.h" |
db725815 | 23 | #include "qemu/main-loop.h" |
fe52840c | 24 | #include "coth.h" |
1ceffa54 | 25 | |
5bdade66 GK |
26 | int coroutine_fn v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value, |
27 | size_t size) | |
1ceffa54 AK |
28 | { |
29 | int err; | |
bccacf6c | 30 | V9fsState *s = pdu->s; |
1ceffa54 | 31 | |
bccacf6c AK |
32 | if (v9fs_request_cancelled(pdu)) { |
33 | return -EINTR; | |
34 | } | |
532decb7 | 35 | v9fs_path_read_lock(s); |
1ceffa54 AK |
36 | v9fs_co_run_in_worker( |
37 | { | |
2289be19 | 38 | err = s->ops->llistxattr(&s->ctx, path, value, size); |
1ceffa54 AK |
39 | if (err < 0) { |
40 | err = -errno; | |
41 | } | |
42 | }); | |
532decb7 | 43 | v9fs_path_unlock(s); |
1ceffa54 AK |
44 | return err; |
45 | } | |
46 | ||
5bdade66 GK |
47 | int coroutine_fn v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path, |
48 | V9fsString *xattr_name, void *value, | |
49 | size_t size) | |
1ceffa54 AK |
50 | { |
51 | int err; | |
bccacf6c | 52 | V9fsState *s = pdu->s; |
1ceffa54 | 53 | |
bccacf6c AK |
54 | if (v9fs_request_cancelled(pdu)) { |
55 | return -EINTR; | |
56 | } | |
532decb7 | 57 | v9fs_path_read_lock(s); |
1ceffa54 AK |
58 | v9fs_co_run_in_worker( |
59 | { | |
2289be19 | 60 | err = s->ops->lgetxattr(&s->ctx, path, |
1ceffa54 AK |
61 | xattr_name->data, |
62 | value, size); | |
63 | if (err < 0) { | |
64 | err = -errno; | |
65 | } | |
66 | }); | |
532decb7 | 67 | v9fs_path_unlock(s); |
1ceffa54 AK |
68 | return err; |
69 | } | |
bed4352c | 70 | |
5bdade66 GK |
71 | int coroutine_fn v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path, |
72 | V9fsString *xattr_name, void *value, | |
73 | size_t size, int flags) | |
bed4352c AK |
74 | { |
75 | int err; | |
bccacf6c | 76 | V9fsState *s = pdu->s; |
bed4352c | 77 | |
bccacf6c AK |
78 | if (v9fs_request_cancelled(pdu)) { |
79 | return -EINTR; | |
80 | } | |
532decb7 | 81 | v9fs_path_read_lock(s); |
bed4352c AK |
82 | v9fs_co_run_in_worker( |
83 | { | |
2289be19 | 84 | err = s->ops->lsetxattr(&s->ctx, path, |
bed4352c AK |
85 | xattr_name->data, value, |
86 | size, flags); | |
87 | if (err < 0) { | |
88 | err = -errno; | |
89 | } | |
90 | }); | |
532decb7 | 91 | v9fs_path_unlock(s); |
bed4352c AK |
92 | return err; |
93 | } | |
94 | ||
5bdade66 GK |
95 | int coroutine_fn v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path, |
96 | V9fsString *xattr_name) | |
bed4352c AK |
97 | { |
98 | int err; | |
bccacf6c | 99 | V9fsState *s = pdu->s; |
bed4352c | 100 | |
bccacf6c AK |
101 | if (v9fs_request_cancelled(pdu)) { |
102 | return -EINTR; | |
103 | } | |
532decb7 | 104 | v9fs_path_read_lock(s); |
bed4352c AK |
105 | v9fs_co_run_in_worker( |
106 | { | |
2289be19 | 107 | err = s->ops->lremovexattr(&s->ctx, path, xattr_name->data); |
bed4352c AK |
108 | if (err < 0) { |
109 | err = -errno; | |
110 | } | |
111 | }); | |
532decb7 | 112 | v9fs_path_unlock(s); |
bed4352c AK |
113 | return err; |
114 | } |