5 * Copyright IBM, Corp. 2011
8 * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
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 "fsdev/qemu-fsdev.h"
16 #include "qemu-thread.h"
17 #include "qemu-coroutine.h"
18 #include "virtio-9p-coth.h"
20 int v9fs_co_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf)
24 v9fs_co_run_in_worker(
26 err = s->ops->lstat(&s->ctx, path->data, stbuf);
34 int v9fs_co_fstat(V9fsState *s, int fd, struct stat *stbuf)
38 v9fs_co_run_in_worker(
40 err = s->ops->fstat(&s->ctx, fd, stbuf);
48 int v9fs_co_open(V9fsState *s, V9fsFidState *fidp, int flags)
52 v9fs_co_run_in_worker(
54 fidp->fs.fd = s->ops->open(&s->ctx, fidp->path.data, flags);
55 if (fidp->fs.fd == -1) {
63 if (total_open_fd > open_fd_hw) {
70 int v9fs_co_open2(V9fsState *s, V9fsFidState *fidp, char *fullname, gid_t gid,
77 cred.fc_mode = mode & 07777;
78 cred.fc_uid = fidp->uid;
80 v9fs_co_run_in_worker(
82 fidp->fs.fd = s->ops->open2(&s->ctx, fullname, flags, &cred);
84 if (fidp->fs.fd == -1) {
90 if (total_open_fd > open_fd_hw) {
97 int v9fs_co_close(V9fsState *s, int fd)
101 v9fs_co_run_in_worker(
103 err = s->ops->close(&s->ctx, fd);
114 int v9fs_co_fsync(V9fsState *s, V9fsFidState *fidp, int datasync)
120 v9fs_co_run_in_worker(
122 err = s->ops->fsync(&s->ctx, fd, datasync);
130 int v9fs_co_link(V9fsState *s, V9fsString *oldpath, V9fsString *newpath)
134 v9fs_co_run_in_worker(
136 err = s->ops->link(&s->ctx, oldpath->data, newpath->data);
144 int v9fs_co_pwritev(V9fsState *s, V9fsFidState *fidp,
145 struct iovec *iov, int iovcnt, int64_t offset)
151 v9fs_co_run_in_worker(
153 err = s->ops->pwritev(&s->ctx, fd, iov, iovcnt, offset);
161 int v9fs_co_preadv(V9fsState *s, V9fsFidState *fidp,
162 struct iovec *iov, int iovcnt, int64_t offset)
168 v9fs_co_run_in_worker(
170 err = s->ops->preadv(&s->ctx, fd, iov, iovcnt, offset);