Signed-off-by: Venkateswararao Jujjuri "<jv...@linux.vnet.ibm.com> --- hw/9pfs/cofs.c | 20 ++++++++++++++++++++ hw/9pfs/virtio-9p-coth.h | 2 ++ hw/9pfs/virtio-9p.c | 31 ++++++++----------------------- 3 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/hw/9pfs/cofs.c b/hw/9pfs/cofs.c index 473ce53..60468bc 100644 --- a/hw/9pfs/cofs.c +++ b/hw/9pfs/cofs.c @@ -169,3 +169,23 @@ int v9fs_co_rename(V9fsState *s, V9fsString *oldpath, V9fsString *newpath) }); return err; } + +int v9fs_co_symlink(V9fsState *s, V9fsFidState *fidp, + const char *oldpath, const char *newpath, gid_t gid) +{ + int err; + FsCred cred; + + cred_init(&cred); + cred.fc_uid = fidp->uid; + cred.fc_gid = gid; + cred.fc_mode = 0777; + v9fs_co_run_in_worker( + { + err = s->ops->symlink(&s->ctx, oldpath, newpath, &cred); + if (err < 0) { + err = -errno; + } + }); + return err; +} diff --git a/hw/9pfs/virtio-9p-coth.h b/hw/9pfs/virtio-9p-coth.h index a3881f3..e394933 100644 --- a/hw/9pfs/virtio-9p-coth.h +++ b/hw/9pfs/virtio-9p-coth.h @@ -86,4 +86,6 @@ extern int v9fs_co_lremovexattr(V9fsState *, V9fsString *, V9fsString *); extern int v9fs_co_closedir(V9fsState *, V9fsFidState *); extern int v9fs_co_close(V9fsState *, V9fsFidState *); extern int v9fs_co_fsync(V9fsState *, V9fsFidState *, int); +extern int v9fs_co_symlink(V9fsState *, V9fsFidState *, const char *, + const char *, gid_t); #endif diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 1e6c2b8..cb11ee6 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -117,18 +117,6 @@ static int v9fs_do_chmod(V9fsState *s, V9fsString *path, mode_t mode) return s->ops->chmod(&s->ctx, path->data, &cred); } -static int v9fs_do_symlink(V9fsState *s, V9fsFidState *fidp, - const char *oldpath, const char *newpath, gid_t gid) -{ - FsCred cred; - cred_init(&cred); - cred.fc_uid = fidp->uid; - cred.fc_gid = gid; - cred.fc_mode = 0777; - - return s->ops->symlink(&s->ctx, oldpath, newpath, &cred); -} - static int v9fs_do_link(V9fsState *s, V9fsString *oldpath, V9fsString *newpath) { return s->ops->link(&s->ctx, oldpath->data, newpath->data); @@ -2030,10 +2018,9 @@ static void v9fs_create(void *opaque) } fidp->fid_type = P9_FID_DIR; } else if (perm & P9_STAT_MODE_SYMLINK) { - err = v9fs_do_symlink(pdu->s, fidp, extension.data, + err = v9fs_co_symlink(pdu->s, fidp, extension.data, fullname.data, -1); if (err < 0) { - err = -errno; goto out; } } else if (perm & P9_STAT_MODE_LINK) { @@ -2142,19 +2129,17 @@ static void v9fs_symlink(void *opaque) } v9fs_string_sprintf(&fullname, "%s/%s", dfidp->path.data, name.data); - err = v9fs_do_symlink(pdu->s, dfidp, symname.data, fullname.data, gid); + err = v9fs_co_symlink(pdu->s, dfidp, symname.data, fullname.data, gid); if (err < 0) { - err = -errno; goto out; } - err = v9fs_do_lstat(pdu->s, &fullname, &stbuf); - if (err == 0) { - stat_to_qid(&stbuf, &qid); - offset += pdu_marshal(pdu, offset, "Q", &qid); - err = offset; - } else { - err = -errno; + err = v9fs_co_lstat(pdu->s, &fullname, &stbuf); + if (err < 0) { + goto out; } + stat_to_qid(&stbuf, &qid); + offset += pdu_marshal(pdu, offset, "Q", &qid); + err = offset; out: complete_pdu(pdu->s, pdu, err); v9fs_string_free(&name); -- 1.7.1