]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Add missing 9p remove handler
authorSasha Levin <levinsasha928@gmail.com>
Mon, 7 Nov 2011 15:54:11 +0000 (17:54 +0200)
committerPekka Enberg <penberg@kernel.org>
Mon, 7 Nov 2011 19:40:15 +0000 (21:40 +0200)
This adds a remove handler which actually allows us to unlink files in the
guest.

Reported-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/virtio/9p.c

index 1569bb279e9f231c0d19dd80c2001a201a34ab5d..08b1be7db3ace8d28776aae61d6adf9057b5e85d 100644 (file)
@@ -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)