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_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 } 45 46 int v9fs_co_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf) 47 { 48 int err; 49 50 v9fs_co_run_in_worker( 51 { 52 err = s->ops->statfs(&s->ctx, path->data, stbuf); 53 if (err < 0) { 54 err = -errno; 55 } 56 }); 57 return err; 58 } 59