]>
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 | ||
fbc04127 | 14 | #include "qemu/osdep.h" |
1ceffa54 | 15 | #include "fsdev/qemu-fsdev.h" |
1de7afc9 | 16 | #include "qemu/thread.h" |
10817bf0 | 17 | #include "qemu/coroutine.h" |
db725815 | 18 | #include "qemu/main-loop.h" |
fe52840c | 19 | #include "coth.h" |
1ceffa54 | 20 | |
5bdade66 GK |
21 | int coroutine_fn v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value, |
22 | size_t size) | |
1ceffa54 AK |
23 | { |
24 | int err; | |
bccacf6c | 25 | V9fsState *s = pdu->s; |
1ceffa54 | 26 | |
bccacf6c AK |
27 | if (v9fs_request_cancelled(pdu)) { |
28 | return -EINTR; | |
29 | } | |
532decb7 | 30 | v9fs_path_read_lock(s); |
1ceffa54 AK |
31 | v9fs_co_run_in_worker( |
32 | { | |
2289be19 | 33 | err = s->ops->llistxattr(&s->ctx, path, value, size); |
1ceffa54 AK |
34 | if (err < 0) { |
35 | err = -errno; | |
36 | } | |
37 | }); | |
532decb7 | 38 | v9fs_path_unlock(s); |
1ceffa54 AK |
39 | return err; |
40 | } | |
41 | ||
5bdade66 GK |
42 | int coroutine_fn v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path, |
43 | V9fsString *xattr_name, void *value, | |
44 | size_t size) | |
1ceffa54 AK |
45 | { |
46 | int err; | |
bccacf6c | 47 | V9fsState *s = pdu->s; |
1ceffa54 | 48 | |
bccacf6c AK |
49 | if (v9fs_request_cancelled(pdu)) { |
50 | return -EINTR; | |
51 | } | |
532decb7 | 52 | v9fs_path_read_lock(s); |
1ceffa54 AK |
53 | v9fs_co_run_in_worker( |
54 | { | |
2289be19 | 55 | err = s->ops->lgetxattr(&s->ctx, path, |
1ceffa54 AK |
56 | xattr_name->data, |
57 | value, size); | |
58 | if (err < 0) { | |
59 | err = -errno; | |
60 | } | |
61 | }); | |
532decb7 | 62 | v9fs_path_unlock(s); |
1ceffa54 AK |
63 | return err; |
64 | } | |
bed4352c | 65 | |
5bdade66 GK |
66 | int coroutine_fn v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path, |
67 | V9fsString *xattr_name, void *value, | |
68 | size_t size, int flags) | |
bed4352c AK |
69 | { |
70 | int err; | |
bccacf6c | 71 | V9fsState *s = pdu->s; |
bed4352c | 72 | |
bccacf6c AK |
73 | if (v9fs_request_cancelled(pdu)) { |
74 | return -EINTR; | |
75 | } | |
532decb7 | 76 | v9fs_path_read_lock(s); |
bed4352c AK |
77 | v9fs_co_run_in_worker( |
78 | { | |
2289be19 | 79 | err = s->ops->lsetxattr(&s->ctx, path, |
bed4352c AK |
80 | xattr_name->data, value, |
81 | size, flags); | |
82 | if (err < 0) { | |
83 | err = -errno; | |
84 | } | |
85 | }); | |
532decb7 | 86 | v9fs_path_unlock(s); |
bed4352c AK |
87 | return err; |
88 | } | |
89 | ||
5bdade66 GK |
90 | int coroutine_fn v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path, |
91 | V9fsString *xattr_name) | |
bed4352c AK |
92 | { |
93 | int err; | |
bccacf6c | 94 | V9fsState *s = pdu->s; |
bed4352c | 95 | |
bccacf6c AK |
96 | if (v9fs_request_cancelled(pdu)) { |
97 | return -EINTR; | |
98 | } | |
532decb7 | 99 | v9fs_path_read_lock(s); |
bed4352c AK |
100 | v9fs_co_run_in_worker( |
101 | { | |
2289be19 | 102 | err = s->ops->lremovexattr(&s->ctx, path, xattr_name->data); |
bed4352c AK |
103 | if (err < 0) { |
104 | err = -errno; | |
105 | } | |
106 | }); | |
532decb7 | 107 | v9fs_path_unlock(s); |
bed4352c AK |
108 | return err; |
109 | } |