4 * Copyright IBM, Corp. 2011
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #include "qemu/osdep.h"
15 #include "fsdev/qemu-fsdev.h"
16 #include "qemu/thread.h"
17 #include "qemu/coroutine.h"
20 int coroutine_fn v9fs_co_readdir(V9fsPDU *pdu, V9fsFidState *fidp,
24 V9fsState *s = pdu->s;
26 if (v9fs_request_cancelled(pdu)) {
29 v9fs_co_run_in_worker(
34 entry = s->ops->readdir(&s->ctx, &fidp->fs);
35 if (!entry && errno) {
45 off_t v9fs_co_telldir(V9fsPDU *pdu, V9fsFidState *fidp)
48 V9fsState *s = pdu->s;
50 if (v9fs_request_cancelled(pdu)) {
53 v9fs_co_run_in_worker(
55 err = s->ops->telldir(&s->ctx, &fidp->fs);
63 void coroutine_fn v9fs_co_seekdir(V9fsPDU *pdu, V9fsFidState *fidp,
66 V9fsState *s = pdu->s;
67 if (v9fs_request_cancelled(pdu)) {
70 v9fs_co_run_in_worker(
72 s->ops->seekdir(&s->ctx, &fidp->fs, offset);
76 void coroutine_fn v9fs_co_rewinddir(V9fsPDU *pdu, V9fsFidState *fidp)
78 V9fsState *s = pdu->s;
79 if (v9fs_request_cancelled(pdu)) {
82 v9fs_co_run_in_worker(
84 s->ops->rewinddir(&s->ctx, &fidp->fs);
88 int coroutine_fn v9fs_co_mkdir(V9fsPDU *pdu, V9fsFidState *fidp,
89 V9fsString *name, mode_t mode, uid_t uid,
90 gid_t gid, struct stat *stbuf)
95 V9fsState *s = pdu->s;
97 if (v9fs_request_cancelled(pdu)) {
104 v9fs_path_read_lock(s);
105 v9fs_co_run_in_worker(
107 err = s->ops->mkdir(&s->ctx, &fidp->path, name->data, &cred);
111 v9fs_path_init(&path);
112 err = v9fs_name_to_path(s, &fidp->path, name->data, &path);
114 err = s->ops->lstat(&s->ctx, &path, stbuf);
119 v9fs_path_free(&path);
126 int coroutine_fn v9fs_co_opendir(V9fsPDU *pdu, V9fsFidState *fidp)
129 V9fsState *s = pdu->s;
131 if (v9fs_request_cancelled(pdu)) {
134 v9fs_path_read_lock(s);
135 v9fs_co_run_in_worker(
137 err = s->ops->opendir(&s->ctx, &fidp->path, &fidp->fs);
147 if (total_open_fd > open_fd_hw) {
148 v9fs_reclaim_fd(pdu);
154 int coroutine_fn v9fs_co_closedir(V9fsPDU *pdu, V9fsFidOpenState *fs)
157 V9fsState *s = pdu->s;
159 if (v9fs_request_cancelled(pdu)) {
162 v9fs_co_run_in_worker(
164 err = s->ops->closedir(&s->ctx, fs);