From patchwork Mon May 31 18:16:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 103309 X-Patchwork-Delegate: ericvh@gmail.com 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 o4VIDL5B023311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 31 May 2010 18:13:57 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OJ9U8-0003cO-VI; Mon, 31 May 2010 18:13:12 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.123] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OJ9U8-0003cH-Bf for v9fs-developer@lists.sourceforge.net; Mon, 31 May 2010 18:13:12 +0000 X-ACL-Warn: Received: from e36.co.us.ibm.com ([32.97.110.154]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1OJ9U7-000391-8y for v9fs-developer@lists.sourceforge.net; Mon, 31 May 2010 18:13:12 +0000 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e36.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o4VI9lSJ022761 for ; Mon, 31 May 2010 12:09:47 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o4VID0gO129546 for ; Mon, 31 May 2010 12:13:00 -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 o4VICxtm022651 for ; Mon, 31 May 2010 12:12:59 -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 o4VICxBs021902; Mon, 31 May 2010 12:12:59 -0600 From: "Venkateswararao Jujjuri (JV)" To: v9fs-developer@lists.sourceforge.net Date: Mon, 31 May 2010 11:16:27 -0700 Message-Id: <1275329787-27559-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: 1OJ9U7-000391-8y Subject: [V9fs-developer] [PATCH] [9p] [V2] Define and implement TLINK for 9P2000.L 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]); Mon, 31 May 2010 18:13:57 +0000 (UTC) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 1e13b5e..5acd355 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1194,6 +1194,49 @@ clunk_fid: } /** + * v9fs_vfs_link_dotl - create a hardlink for dotl + * @old_dentry: dentry for file to link to + * @dir: inode destination for new link + * @dentry: dentry for link + * + */ + +static int +v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir, + struct dentry *dentry) +{ + int err; + struct p9_fid *dfid; + char *name; + struct v9fs_session_info *v9ses; + + P9_DPRINTK(P9_DEBUG_VFS, + " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name, + old_dentry->d_name.name); + + v9ses = v9fs_inode2v9ses(dir); + dfid = v9fs_fid_lookup(dentry->d_parent); + if (IS_ERR(dfid)) + return PTR_ERR(dfid); + + name = (char *) dentry->d_name.name; + + err = p9_client_link(dfid, (char *)old_dentry->d_name.name, + (char *)dentry->d_name.name); + if (err < 0) { + P9_DPRINTK(P9_DEBUG_VFS, "p9_client_link failed %d\n", err); + return err; + } + + dentry->d_op = old_dentry->d_op; + /* Hard link, so we can use old_dentry's inode. Just i_count++ */ + atomic_inc(&old_dentry->d_inode->i_count); + d_instantiate(dentry, old_dentry->d_inode); + + return err; +} + +/** * v9fs_vfs_mknod - create a special file * @dir: inode destination for new link * @dentry: dentry for file @@ -1254,7 +1297,7 @@ static const struct inode_operations v9fs_dir_inode_operations_dotl = { .create = v9fs_vfs_create, .lookup = v9fs_vfs_lookup, .symlink = v9fs_vfs_symlink, - .link = v9fs_vfs_link, + .link = v9fs_vfs_link_dotl, .unlink = v9fs_vfs_unlink, .mkdir = v9fs_vfs_mkdir, .rmdir = v9fs_vfs_rmdir, diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index f1b0b31..6df324e 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h @@ -135,6 +135,8 @@ enum p9_msg_t { P9_RRENAME, P9_TREADDIR = 40, P9_RREADDIR, + P9_TLINK = 70, + P9_RLINK, P9_TVERSION = 100, P9_RVERSION, P9_TAUTH = 102, diff --git a/include/net/9p/client.h b/include/net/9p/client.h index cd6de1c..c214240 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h @@ -226,6 +226,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, int p9_client_open(struct p9_fid *fid, int mode); int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, char *extension); +int p9_client_link(struct p9_fid *fid, char *name, char *linkname); int p9_client_clunk(struct p9_fid *fid); int p9_client_remove(struct p9_fid *fid); int p9_client_read(struct p9_fid *fid, char *data, char __user *udata, diff --git a/net/9p/client.c b/net/9p/client.c index 5398b98..7f4d8f9 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -1093,6 +1093,27 @@ error: } EXPORT_SYMBOL(p9_client_fcreate); +int p9_client_link(struct p9_fid *dfid, char *oldname, char *newname) +{ + int err = 0; + struct p9_client *clnt; + struct p9_req_t *req; + + P9_DPRINTK(P9_DEBUG_9P, ">>> TLINK fid %d oldname %s newname %s\n", + dfid->fid, oldname, newname); + clnt = dfid->clnt; + req = p9_client_rpc(clnt, P9_TLINK, "dss", dfid->fid, oldname, newname); + if (IS_ERR(req)) { + err = PTR_ERR(req); + goto error; + } + P9_DPRINTK(P9_DEBUG_9P, "<<< RLINK\n"); + p9_free_req(clnt, req); +error: + return err; +} +EXPORT_SYMBOL(p9_client_link); + int p9_client_clunk(struct p9_fid *fid) { int err;