From patchwork Sun May 30 16:40:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 103140 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4UGb85b007460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 30 May 2010 16:37:44 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OIlVX-0000VO-Tr; Sun, 30 May 2010 16:37:03 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.124] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OIlVW-0000VI-Dz for v9fs-developer@lists.sourceforge.net; Sun, 30 May 2010 16:37:02 +0000 X-ACL-Warn: Received: from e39.co.us.ibm.com ([32.97.110.160]) by sfi-mx-4.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1OIlVT-0007H3-AH for v9fs-developer@lists.sourceforge.net; Sun, 30 May 2010 16:37:02 +0000 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e39.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o4UGRxV8005796 for ; Sun, 30 May 2010 10:27:59 -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 o4UGarSo151094 for ; Sun, 30 May 2010 10:36:53 -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 o4UGaqHp031032 for ; Sun, 30 May 2010 10:36:53 -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 o4UGaqMO031002; Sun, 30 May 2010 10:36:52 -0600 From: "Venkateswararao Jujjuri (JV)" To: qemu-devel@nongnu.org Date: Sun, 30 May 2010 09:40:38 -0700 Message-Id: <1275237638-13508-1-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.6 X-Spam-Score: -0.6 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.6 AWL AWL: From: address is in the auto white-list X-Headers-End: 1OIlVT-0007H3-AH Cc: v9fs-developer@lists.sourceforge.net, aliguori@us.ibm.com Subject: [V9fs-developer] [PATCH] [virtio-9p] Server side implementation for TLINK X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 30 May 2010 16:37:44 +0000 (UTC) diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h index b3a320c..6744d69 100644 --- a/hw/file-op-9p.h +++ b/hw/file-op-9p.h @@ -55,7 +55,7 @@ typedef struct FileOperations int (*utime)(FsContext *, const char *, const struct utimbuf *); int (*remove)(FsContext *, const char *); int (*symlink)(FsContext *, const char *, const char *, FsCred *); - int (*link)(FsContext *, const char *, const char *, FsCred *); + int (*link)(FsContext *, const char *, const char *); int (*setuid)(FsContext *, uid_t); int (*close)(FsContext *, int); int (*closedir)(FsContext *, DIR *); diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c index a82b771..a870b97 100644 --- a/hw/virtio-9p-debug.c +++ b/hw/virtio-9p-debug.c @@ -463,6 +463,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, ", name"); + pprint_str(pdu, 0, &offset, ", linkname"); + 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-local.c b/hw/virtio-9p-local.c index c5678ae..fa8d05c 100644 --- a/hw/virtio-9p-local.c +++ b/hw/virtio-9p-local.c @@ -375,7 +375,7 @@ err_end: } static int local_link(FsContext *fs_ctx, const char *oldpath, - const char *newpath, FsCred *credp) + const char *newpath) { char *tmp = qemu_strdup(rpath(fs_ctx, oldpath)); int err; diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 097dce8..d36d206 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -212,14 +212,9 @@ static int v9fs_do_symlink(V9fsState *s, V9fsCreateState *vs) &cred); } -static int v9fs_do_link(V9fsState *s, V9fsFidState *nfidp, V9fsCreateState *vs) +static int v9fs_do_link(V9fsState *s, char *oldpath, char *fullname) { - FsCred cred; - cred_init(&cred); - cred.fc_uid = nfidp->uid; - cred.fc_mode = vs->perm & 0777; - - return s->ops->link(&s->ctx, nfidp->path.data, vs->fullname.data, &cred); + return s->ops->link(&s->ctx, oldpath, fullname); } static int v9fs_do_truncate(V9fsState *s, V9fsString *path, off_t size) @@ -1919,7 +1914,7 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err) err = -errno; v9fs_post_create(s, vs, err); } - err = v9fs_do_link(s, nfidp, vs); + err = v9fs_do_link(s, nfidp->path.data, vs->fullname.data); v9fs_create_post_perms(s, vs, err); } else if (vs->perm & P9_STAT_MODE_DEVICE) { char ctype; @@ -1999,6 +1994,34 @@ out: qemu_free(vs); } +static void v9fs_link(V9fsState *s, V9fsPDU *pdu) +{ + int32_t dfid; + V9fsFidState *dfidp; + V9fsString name, fullname, oldname; + size_t offset = 7; + int err = 0; + + v9fs_string_init(&fullname); + + pdu_unmarshal(pdu, offset, "dss", &dfid, &oldname, &name); + + dfidp = lookup_fid(s, dfid); + if (dfidp == NULL) { + err = -errno; + goto out; + } + + v9fs_string_sprintf(&fullname, "%s/%s", dfidp->path.data, name.data); + err = v9fs_do_link(s, oldname.data, fullname.data); + v9fs_string_free(&fullname); + +out: + v9fs_string_free(&name); + v9fs_string_free(&oldname); + complete_pdu(s, pdu, err); +} + static void v9fs_flush(V9fsState *s, V9fsPDU *pdu) { /* A nop call with no return */ @@ -2354,6 +2377,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 9773659..6b3d4a4 100644 --- a/hw/virtio-9p.h +++ b/hw/virtio-9p.h @@ -17,6 +17,8 @@ enum { P9_RSTATFS, P9_TREADDIR = 40, P9_RREADDIR, + P9_TLINK = 70, + P9_RLINK, P9_TVERSION = 100, P9_RVERSION, P9_TAUTH = 102,