Statistics
| Branch: | Revision:

root / hw / 9pfs / codir.c @ 8db21ce7

History | View | Annotate | Download (1.4 kB)

1

    
2
/*
3
 * Virtio 9p backend
4
 *
5
 * Copyright IBM, Corp. 2011
6
 *
7
 * Authors:
8
 *  Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
9
 *
10
 * This work is licensed under the terms of the GNU GPL, version 2.  See
11
 * the COPYING file in the top-level directory.
12
 *
13
 */
14

    
15
#include "fsdev/qemu-fsdev.h"
16
#include "qemu-thread.h"
17
#include "qemu-coroutine.h"
18
#include "virtio-9p-coth.h"
19

    
20
int v9fs_co_readdir(V9fsState *s, V9fsFidState *fidp, struct dirent **dent)
21
{
22
    int err;
23

    
24
    v9fs_co_run_in_worker(
25
        {
26
            errno = 0;
27
            /*FIXME!! need to switch to readdir_r */
28
            *dent = s->ops->readdir(&s->ctx, fidp->fs.dir);
29
            if (!*dent && errno) {
30
                err = -errno;
31
            } else {
32
                err = 0;
33
            }
34
        });
35
    return err;
36
}
37

    
38
off_t v9fs_co_telldir(V9fsState *s, V9fsFidState *fidp)
39
{
40
    off_t err;
41

    
42
    v9fs_co_run_in_worker(
43
        {
44
            err = s->ops->telldir(&s->ctx, fidp->fs.dir);
45
            if (err < 0) {
46
                err = -errno;
47
            }
48
        });
49
    return err;
50
}
51

    
52
void v9fs_co_seekdir(V9fsState *s, V9fsFidState *fidp, off_t offset)
53
{
54
    v9fs_co_run_in_worker(
55
        {
56
            s->ops->seekdir(&s->ctx, fidp->fs.dir, offset);
57
        });
58
}
59

    
60
void v9fs_co_rewinddir(V9fsState *s, V9fsFidState *fidp)
61
{
62
    v9fs_co_run_in_worker(
63
        {
64
            s->ops->rewinddir(&s->ctx, fidp->fs.dir);
65
        });
66
}