]>
git.proxmox.com Git - qemu.git/blob - hw/9pfs/codir.c
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_readdir_r(V9fsPDU
*pdu
, V9fsFidState
*fidp
, struct dirent
*dent
,
21 struct dirent
**result
)
24 V9fsState
*s
= pdu
->s
;
26 if (v9fs_request_cancelled(pdu
)) {
29 v9fs_co_run_in_worker(
32 err
= s
->ops
->readdir_r(&s
->ctx
, &fidp
->fs
, dent
, result
);
33 if (!*result
&& errno
) {
42 off_t
v9fs_co_telldir(V9fsPDU
*pdu
, V9fsFidState
*fidp
)
45 V9fsState
*s
= pdu
->s
;
47 if (v9fs_request_cancelled(pdu
)) {
50 v9fs_co_run_in_worker(
52 err
= s
->ops
->telldir(&s
->ctx
, &fidp
->fs
);
60 void v9fs_co_seekdir(V9fsPDU
*pdu
, V9fsFidState
*fidp
, off_t offset
)
62 V9fsState
*s
= pdu
->s
;
63 if (v9fs_request_cancelled(pdu
)) {
66 v9fs_co_run_in_worker(
68 s
->ops
->seekdir(&s
->ctx
, &fidp
->fs
, offset
);
72 void v9fs_co_rewinddir(V9fsPDU
*pdu
, V9fsFidState
*fidp
)
74 V9fsState
*s
= pdu
->s
;
75 if (v9fs_request_cancelled(pdu
)) {
78 v9fs_co_run_in_worker(
80 s
->ops
->rewinddir(&s
->ctx
, &fidp
->fs
);
84 int v9fs_co_mkdir(V9fsPDU
*pdu
, V9fsFidState
*fidp
, V9fsString
*name
,
85 mode_t mode
, uid_t uid
, gid_t gid
, struct stat
*stbuf
)
90 V9fsState
*s
= pdu
->s
;
92 if (v9fs_request_cancelled(pdu
)) {
99 v9fs_path_read_lock(s
);
100 v9fs_co_run_in_worker(
102 err
= s
->ops
->mkdir(&s
->ctx
, &fidp
->path
, name
->data
, &cred
);
106 v9fs_path_init(&path
);
107 err
= v9fs_name_to_path(s
, &fidp
->path
, name
->data
, &path
);
109 err
= s
->ops
->lstat(&s
->ctx
, &path
, stbuf
);
114 v9fs_path_free(&path
);
121 int v9fs_co_opendir(V9fsPDU
*pdu
, V9fsFidState
*fidp
)
124 V9fsState
*s
= pdu
->s
;
126 if (v9fs_request_cancelled(pdu
)) {
129 v9fs_path_read_lock(s
);
130 v9fs_co_run_in_worker(
132 err
= s
->ops
->opendir(&s
->ctx
, &fidp
->path
, &fidp
->fs
);
142 if (total_open_fd
> open_fd_hw
) {
143 v9fs_reclaim_fd(pdu
);
149 int v9fs_co_closedir(V9fsPDU
*pdu
, V9fsFidOpenState
*fs
)
152 V9fsState
*s
= pdu
->s
;
154 if (v9fs_request_cancelled(pdu
)) {
157 v9fs_co_run_in_worker(
159 err
= s
->ops
->closedir(&s
->ctx
, fs
);