aboutsummaryrefslogtreecommitdiff
path: root/hw/9pfs/codir.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/9pfs/codir.c')
-rw-r--r--hw/9pfs/codir.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c
index 28f2ad7320..3a257b9027 100644
--- a/hw/9pfs/codir.c
+++ b/hw/9pfs/codir.c
@@ -17,16 +17,16 @@
#include "qemu-coroutine.h"
#include "virtio-9p-coth.h"
-int v9fs_co_readdir(V9fsState *s, V9fsFidState *fidp, struct dirent **dent)
+int v9fs_co_readdir_r(V9fsState *s, V9fsFidState *fidp, struct dirent *dent,
+ struct dirent **result)
{
int err;
v9fs_co_run_in_worker(
{
errno = 0;
- /*FIXME!! need to switch to readdir_r */
- *dent = s->ops->readdir(&s->ctx, fidp->fs.dir);
- if (!*dent && errno) {
+ err = s->ops->readdir_r(&s->ctx, fidp->fs.dir, dent, result);
+ if (!*result && errno) {
err = -errno;
} else {
err = 0;
@@ -83,3 +83,35 @@ int v9fs_co_mkdir(V9fsState *s, char *name, mode_t mode, uid_t uid, gid_t gid)
});
return err;
}
+
+int v9fs_co_opendir(V9fsState *s, V9fsFidState *fidp)
+{
+ int err;
+
+ v9fs_co_run_in_worker(
+ {
+ fidp->fs.dir = s->ops->opendir(&s->ctx, fidp->path.data);
+ if (!fidp->fs.dir) {
+ err = -errno;
+ } else {
+ err = 0;
+ }
+ });
+ return err;
+}
+
+int v9fs_co_closedir(V9fsState *s, V9fsFidState *fidp)
+{
+ int err;
+ DIR *dir;
+
+ dir = fidp->fs.dir;
+ v9fs_co_run_in_worker(
+ {
+ err = s->ops->closedir(&s->ctx, dir);
+ if (err < 0) {
+ err = -errno;
+ }
+ });
+ return err;
+}