kvm tools: Add missing 9p remove handler
PATCH v2 1/2 kvm tools: Add missing 9p remove handler
This adds a remove handler which actually allows us to unlink files in the guest.
Reported-by Darren Hart <[email protected]>
Signed-off-by Sasha Levin <[email protected]>
--- tools/kvm/virtio/9p.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)
tools/kvm/virtio/9p.c +25 -0
@@ -677,6 +677,30 @@ err_out:return ; } +static void virtio_p9_remove (struct p9_dev *p9dev, +struct p9_pdu *pdu,u32 *outlen) +{ +int ret; +u32 fid_val; +struct p9_fid *fid; +char full_path[PATH_MAX ]; + +virtio_p9_pdu_readf (pdu,"d" , &fid_val); + fid = &p9dev->fids[fid_val]; + +sprintf (full_path,"%s" , fid->abs_path); + ret =remove (full_path); +if (ret <0 ) + goto err_out; + *outlen = pdu->write_offset; +virtio_p9_set_reply_header (pdu, *outlen); +return ; + +err_out: +virtio_p9_error_reply (p9dev, pdu, errno, outlen); +return ; +} +static void virtio_p9_readlink (struct p9_dev *p9dev,struct p9_pdu *pdu,u32 *outlen) {
@@ -1048,6 +1072,7 @@ static p9_handler *virtio_9p_dotl_handler [] = { [P9_TSYMLINK] = virtio_p9_symlink, [P9_TLCREATE] = virtio_p9_create, [P9_TWRITE] = virtio_p9_write, + [P9_TREMOVE] = virtio_p9_remove, };static struct p9_pdu *virtio_p9_pdu_init (struct kvm *kvm,struct virt_queue *vq)
Signature · 1 line
1.7.7.2
PATCH v2 2/2 kvm tools: Add missing 9p rename handler
This adds a rename handler which actually allows us to rename files in the guest.
Reported-by Darren Hart <[email protected]>
Signed-off-by Sasha Levin <[email protected]>
--- tools/kvm/virtio/9p.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
tools/kvm/virtio/9p.c +27 -0
@@ -700,6 +700,32 @@ err_out:virtio_p9_error_reply (p9dev, pdu, errno, outlen);return ; } + +static void virtio_p9_rename (struct p9_dev *p9dev, +struct p9_pdu *pdu,u32 *outlen) +{ +int ret; +u32 fid_val, new_fid_val; +struct p9_fid *fid, *new_fid; +char full_path[PATH_MAX ], *new_name; + +virtio_p9_pdu_readf (pdu,"dds" , &fid_val, &new_fid_val, &new_name); + fid = &p9dev->fids[fid_val]; + new_fid = &p9dev->fids[new_fid_val]; + +sprintf (full_path,"%s/%s" , new_fid->abs_path, new_name); + ret =rename (fid->abs_path, full_path); +if (ret <0 ) + goto err_out; +close_fid (p9dev, fid_val); + *outlen = pdu->write_offset; +virtio_p9_set_reply_header (pdu, *outlen); +return ; + +err_out: +virtio_p9_error_reply (p9dev, pdu, errno, outlen); +return ; +}static void virtio_p9_readlink (struct p9_dev *p9dev,struct p9_pdu *pdu,u32 *outlen)
@@ -1073,6 +1099,7 @@ static p9_handler *virtio_9p_dotl_handler [] = { [P9_TLCREATE] = virtio_p9_create, [P9_TWRITE] = virtio_p9_write, [P9_TREMOVE] = virtio_p9_remove, + [P9_TRENAME] = virtio_p9_rename, };static struct p9_pdu *virtio_p9_pdu_init (struct kvm *kvm,struct virt_queue *vq)
Signature · 1 line
1.7.7.2