]> Git Repo - qemu.git/blame - hw/9pfs/cofs.c
hw/9pfs: Add yeild support for readlink
[qemu.git] / hw / 9pfs / cofs.c
CommitLineData
86e42d74
VJ
1
2/*
3 * Virtio 9p backend
4 *
5 * Copyright IBM, Corp. 2011
6 *
7 * Authors:
8 * Aneesh Kumar K.V <[email protected]>
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
20int v9fs_co_readlink(V9fsState *s, V9fsString *path, V9fsString *buf)
21{
22 int err;
23 ssize_t len;
24
25 buf->data = qemu_malloc(PATH_MAX);
26 v9fs_co_run_in_worker(
27 {
28 len = s->ops->readlink(&s->ctx, path->data,
29 buf->data, PATH_MAX - 1);
30 if (len > -1) {
31 buf->size = len;
32 buf->data[len] = 0;
33 err = 0;
34 } else {
35 err = -errno;
36 }
37 });
38 if (err) {
39 qemu_free(buf->data);
40 buf->data = NULL;
41 buf->size = 0;
42 }
43 return err;
44}
This page took 0.02735 seconds and 4 git commands to generate.