Received: from eggs.gnu.org ([140.186.70.92]:40458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1yQP-0005ZE-Tx for qemu-devel@nongnu.org; Fri, 09 Sep 2011 06:35:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1yQO-0001i5-2F for qemu-devel@nongnu.org; Fri, 09 Sep 2011 06:35:09 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:38941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1yQC-0001aV-Pd for qemu-devel@nongnu.org; Fri, 09 Sep 2011 06:35:08 -0400 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by e28smtp01.in.ibm.com (8.14.4/8.13.1) with ESMTP id p89AYoFi023841 for ; Fri, 9 Sep 2011 16:04:50 +0530 Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p89AYodT3919900 for ; Fri, 9 Sep 2011 16:04:50 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p89AYnDE026212 for ; Fri, 9 Sep 2011 20:34:50 +1000 From: "Aneesh Kumar K.V" Date: Fri, 9 Sep 2011 16:03:27 +0530 Message-Id: <1315564407-11265-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> In-Reply-To: <1315564407-11265-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1315564407-11265-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH -V2 2/2] hw/9pfs: add 9P2000.L unlinkat operation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, "Aneesh Kumar K.V" unlinkat - Remove a directory entry size[4] Tunlinkat tag[2] dirfid[4] name[s] flag[4] size[4] Runlinkat tag[2] older Tremove have the below request format size[4] Tremove tag[2] fid[4] The remove message is used to remove a directory entry either file or directory The remove opreation is actually a directory opertation and should ideally have dirfid, if not we cannot represent the fid on server with anything other than name. We will have to derive the directory name from fid in the Tremove request. NOTE: The operation doesn't clunk the unlink fid. Signed-off-by: Aneesh Kumar K.V --- hw/9pfs/virtio-9p.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/9pfs/virtio-9p.h | 2 ++ 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 0293fe4..d28edb7 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -2338,6 +2338,45 @@ out_nofid: complete_pdu(pdu->s, pdu, err); } +static void v9fs_unlinkat(void *opaque) +{ + int err = 0; + V9fsString name; + int32_t dfid, flags; + size_t offset = 7; + V9fsFidState *dfidp; + V9fsPDU *pdu = opaque; + V9fsString full_name; + + pdu_unmarshal(pdu, offset, "dsd", &dfid, &name, &flags); + + dfidp = get_fid(pdu->s, dfid); + if (dfidp == NULL) { + err = -EINVAL; + goto out_nofid; + } + v9fs_string_init(&full_name); + v9fs_string_sprintf(&full_name, "%s/%s", dfidp->path.data, name.data); + /* + * IF the file is unlinked, we cannot reopen + * the file later. So don't reclaim fd + */ + err = v9fs_mark_fids_unreclaim(pdu->s, &full_name); + if (err < 0) { + goto out_err; + } + err = v9fs_co_remove(pdu->s, &full_name); + if (!err) { + err = offset; + } +out_err: + put_fid(pdu->s, dfidp); + v9fs_string_free(&full_name); +out_nofid: + complete_pdu(pdu->s, pdu, err); + v9fs_string_free(&name); +} + static int v9fs_complete_rename(V9fsState *s, V9fsFidState *fidp, int32_t newdirfid, V9fsString *name) { @@ -3040,6 +3079,7 @@ static CoroutineEntry *pdu_co_handlers[] = { [P9_TGETLOCK] = v9fs_getlock, [P9_TRENAMEAT] = v9fs_renameat, [P9_TREADLINK] = v9fs_readlink, + [P9_TUNLINKAT] = v9fs_unlinkat, [P9_TMKDIR] = v9fs_mkdir, [P9_TVERSION] = v9fs_version, [P9_TLOPEN] = v9fs_open, diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 4950782..17d44b4 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -52,6 +52,8 @@ enum { P9_RMKDIR, P9_TRENAMEAT = 74, P9_RRENAMEAT, + P9_TUNLINKAT = 76, + P9_RUNLINKAT, P9_TVERSION = 100, P9_RVERSION, P9_TAUTH = 102, -- 1.7.4.1