Signed-off-by: Venkateswararao Jujjuri "<jv...@linux.vnet.ibm.com> --- hw/9pfs/virtio-9p.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index e0e7eed..cc22a1f 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -82,19 +82,21 @@ static int v9fs_do_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf) return s->ops->lstat(&s->ctx, path->data, stbuf); } -static ssize_t v9fs_do_readlink(V9fsState *s, V9fsString *path, V9fsString *buf) +static int v9fs_do_readlink(V9fsState *s, V9fsString *path, V9fsString *buf, + ssize_t *len) { - ssize_t len; - + int err; buf->data = qemu_malloc(1024); - len = s->ops->readlink(&s->ctx, path->data, buf->data, 1024 - 1); - if (len > -1) { - buf->size = len; - buf->data[len] = 0; + *len = s->ops->readlink(&s->ctx, path->data, buf->data, 1024 - 1); + if (*len > -1) { + buf->size = *len; + buf->data[*len] = 0; + err = 0; + } else { + err = -errno; } - - return len; + return err; } static int v9fs_do_close(V9fsState *s, int fd) @@ -1055,13 +1057,11 @@ static int stat_to_v9stat(V9fsState *s, V9fsString *name, v9fs_string_null(&v9stat->extension); if (v9stat->mode & P9_STAT_MODE_SYMLINK) { - err = v9fs_do_readlink(s, name, &v9stat->extension); - if (err == -1) { - err = -errno; + ssize_t symlink_len; + err = v9fs_do_readlink(s, name, &v9stat->extension, &symlink_len); + if (err < 0) { return err; } - v9stat->extension.data[err] = 0; - v9stat->extension.size = err; } else if (v9stat->mode & P9_STAT_MODE_DEVICE) { v9fs_string_sprintf(&v9stat->extension, "%c %u %u", S_ISCHR(stbuf->st_mode) ? 'c' : 'b', @@ -3591,6 +3591,7 @@ static void v9fs_readlink(void *opaque) int32_t fid; int err = 0; V9fsFidState *fidp; + ssize_t symlink_len; pdu_unmarshal(pdu, offset, "d", &fid); fidp = lookup_fid(pdu->s, fid); @@ -3600,9 +3601,8 @@ static void v9fs_readlink(void *opaque) } v9fs_string_init(&target); - err = v9fs_do_readlink(pdu->s, &fidp->path, &target); + err = v9fs_do_readlink(pdu->s, &fidp->path, &target, &symlink_len); if (err < 0) { - err = -errno; goto out; } offset += pdu_marshal(pdu, offset, "s", &target); -- 1.7.1