5 * Copyright IBM, Corp. 2011
10 * This work is licensed under the terms of the GNU GPL, version 2. See
11 * the COPYING file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include "fsdev/qemu-fsdev.h"
17 #include "qemu/thread.h"
18 #include "qemu/coroutine.h"
21 int v9fs_co_readdir_r(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent *dent,
22 struct dirent **result)
25 V9fsState *s = pdu->s;
27 if (v9fs_request_cancelled(pdu)) {
30 v9fs_co_run_in_worker(
33 err = s->ops->readdir_r(&s->ctx, &fidp->fs, dent, result);
34 if (!*result && errno) {
43 off_t v9fs_co_telldir(V9fsPDU *pdu, V9fsFidState *fidp)
46 V9fsState *s = pdu->s;
48 if (v9fs_request_cancelled(pdu)) {
51 v9fs_co_run_in_worker(
53 err = s->ops->telldir(&s->ctx, &fidp->fs);
61 void v9fs_co_seekdir(V9fsPDU *pdu, V9fsFidState *fidp, off_t offset)
63 V9fsState *s = pdu->s;
64 if (v9fs_request_cancelled(pdu)) {
67 v9fs_co_run_in_worker(
69 s->ops->seekdir(&s->ctx, &fidp->fs, offset);
73 void v9fs_co_rewinddir(V9fsPDU *pdu, V9fsFidState *fidp)
75 V9fsState *s = pdu->s;
76 if (v9fs_request_cancelled(pdu)) {
79 v9fs_co_run_in_worker(
81 s->ops->rewinddir(&s->ctx, &fidp->fs);
85 int v9fs_co_mkdir(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name,
86 mode_t mode, uid_t uid, gid_t gid, struct stat *stbuf)
91 V9fsState *s = pdu->s;
93 if (v9fs_request_cancelled(pdu)) {
100 v9fs_path_read_lock(s);
101 v9fs_co_run_in_worker(
103 err = s->ops->mkdir(&s->ctx, &fidp->path, name->data, &cred);
107 v9fs_path_init(&path);
108 err = v9fs_name_to_path(s, &fidp->path, name->data, &path);
110 err = s->ops->lstat(&s->ctx, &path, stbuf);
115 v9fs_path_free(&path);
122 int v9fs_co_opendir(V9fsPDU *pdu, V9fsFidState *fidp)
125 V9fsState *s = pdu->s;
127 if (v9fs_request_cancelled(pdu)) {
130 v9fs_path_read_lock(s);
131 v9fs_co_run_in_worker(
133 err = s->ops->opendir(&s->ctx, &fidp->path, &fidp->fs);
143 if (total_open_fd > open_fd_hw) {
144 v9fs_reclaim_fd(pdu);
150 int v9fs_co_closedir(V9fsPDU *pdu, V9fsFidOpenState *fs)
153 V9fsState *s = pdu->s;
155 if (v9fs_request_cancelled(pdu)) {
158 v9fs_co_run_in_worker(
160 err = s->ops->closedir(&s->ctx, fs);