From patchwork Mon Jun 28 21:55:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 57208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6C319B6EE8 for ; Tue, 29 Jun 2010 08:11:17 +1000 (EST) Received: from localhost ([127.0.0.1]:46894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTMXq-0000w4-Kn for incoming@patchwork.ozlabs.org; Mon, 28 Jun 2010 18:11:14 -0400 Received: from [140.186.70.92] (port=59060 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTMF5-00056e-PN for qemu-devel@nongnu.org; Mon, 28 Jun 2010 17:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTMF3-0006pb-8r for qemu-devel@nongnu.org; Mon, 28 Jun 2010 17:51:51 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:39926) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTMF3-0006pL-3c for qemu-devel@nongnu.org; Mon, 28 Jun 2010 17:51:49 -0400 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e34.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o5SLhg6q013663 for ; Mon, 28 Jun 2010 15:43:42 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5SLpf6j117766 for ; Mon, 28 Jun 2010 15:51:42 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o5SLpe1i026618 for ; Mon, 28 Jun 2010 15:51:41 -0600 Received: from localhost.localdomain (elm9m80.beaverton.ibm.com [9.47.81.80]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o5SLpX86026203; Mon, 28 Jun 2010 15:51:40 -0600 From: "Venkateswararao Jujjuri (JV)" To: qemu-devel@nongnu.org Date: Mon, 28 Jun 2010 14:55:07 -0700 Message-Id: <1277762117-11212-10-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1277762117-11212-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1277762117-11212-1-git-send-email-jvrao@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: aliguori@us.ibm.com, "Venkateswararao Jujjuri \(JV\)" Subject: [Qemu-devel] [PATCH 10/20] [virtio-9p] Implement TLINK for 9P2000.L X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Create a Hardlink. SYNOPSIS size[4] Tlink tag[2] dfid[4] oldfid[4] newpath[s] size[4] Rlink tag[2] DESCRIPTION Create a link 'newpath' in directory pointed by dfid linking to oldfid path. Signed-off-by: Venkateswararao Jujjuri --- hw/virtio-9p-debug.c | 9 +++++++++ hw/virtio-9p.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/virtio-9p.h | 2 ++ 3 files changed, 49 insertions(+), 0 deletions(-) diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c index 6072491..18ef485 100644 --- a/hw/virtio-9p-debug.c +++ b/hw/virtio-9p-debug.c @@ -495,6 +495,15 @@ void pprint_pdu(V9fsPDU *pdu) case P9_RCLUNK: fprintf(llogfile, "RCLUNK: ("); break; + case P9_TLINK: + fprintf(llogfile, "TLINK: ("); + pprint_int32(pdu, 0, &offset, "fid"); + pprint_str(pdu, 0, &offset, ", oldpath"); + pprint_str(pdu, 0, &offset, ", newpath"); + break; + case P9_RLINK: + fprintf(llogfile, "RLINK: ("); + break; case P9_TREMOVE: fprintf(llogfile, "TREMOVE: ("); pprint_int32(pdu, 0, &offset, "fid"); diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index b1b3cb5..dc7ef10 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -2277,6 +2277,43 @@ static void v9fs_flush(V9fsState *s, V9fsPDU *pdu) complete_pdu(s, pdu, 7); } +static void v9fs_link(V9fsState *s, V9fsPDU *pdu) +{ + int32_t dfid, oldfid; + V9fsFidState *dfidp, *oldfidp; + V9fsString name, fullname; + size_t offset = 7; + int err = 0; + + v9fs_string_init(&fullname); + + pdu_unmarshal(pdu, offset, "dds", &dfid, &oldfid, &name); + + dfidp = lookup_fid(s, dfid); + if (dfidp == NULL) { + err = -errno; + goto out; + } + + oldfidp = lookup_fid(s, oldfid); + if (oldfidp == NULL) { + err = -errno; + goto out; + } + + v9fs_string_sprintf(&fullname, "%s/%s", dfidp->path.data, name.data); + err = offset; + err = v9fs_do_link(s, &oldfidp->path, &fullname); + if (err) { + err = -errno; + } + v9fs_string_free(&fullname); + +out: + v9fs_string_free(&name); + complete_pdu(s, pdu, err); +} + static void v9fs_remove_post_remove(V9fsState *s, V9fsRemoveState *vs, int err) { @@ -2651,6 +2688,7 @@ static pdu_handler_t *pdu_handlers[] = { [P9_TAUTH] = v9fs_auth, #endif [P9_TFLUSH] = v9fs_flush, + [P9_TLINK] = v9fs_link, [P9_TCREATE] = v9fs_create, [P9_TWRITE] = v9fs_write, [P9_TWSTAT] = v9fs_wstat, diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h index a0ee7d3..a31d5ff 100644 --- a/hw/virtio-9p.h +++ b/hw/virtio-9p.h @@ -21,6 +21,8 @@ enum { P9_RSETATTR, P9_TREADDIR = 40, P9_RREADDIR, + P9_TLINK = 70, + P9_RLINK, P9_TVERSION = 100, P9_RVERSION, P9_TAUTH = 102,