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