Define and implement TLINK for 9P2000.L
Subsystems (3)
PATCH v2 1/1 Define and implement TLINK for 9P2000.L
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.
[[email protected] : p9_client_link should not free req structure if p9_client_rpc has returned an error.]
Signed-off-by Venkateswararao Jujjuri <[email protected]>
--- fs/9p/vfs_inode.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++- include/net/9p/9p.h | 2 + include/net/9p/client.h | 1 + net/9p/client.c | 19 +++++++++++++ 4 files changed, 86 insertions(+), 1 deletions(-)
fs/9p/vfs_inode.c +64 -1
@@ -1186,6 +1186,69 @@ 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, *oldfid; +char *name; +struct v9fs_session_info *v9ses; + +P9_DPRINTK (P9_DEBUG_VFS ,"dir ino: %lu, old_name: %s, new_name: %s\n" , + dir->i_ino, old_dentry->d_name.name, + dentry->d_name.name); + + v9ses =v9fs_inode2v9ses (dir); + dfid =v9fs_fid_lookup (dentry->d_parent); +if (IS_ERR (dfid)) +return PTR_ERR (dfid); + + oldfid =v9fs_fid_lookup (old_dentry); +if (IS_ERR (oldfid)) +return PTR_ERR (oldfid); + + name = (char *) dentry->d_name.name; + + err =p9_client_link (dfid, oldfid, (char *)dentry->d_name.name); + +if (err <0 ) { +P9_DPRINTK (P9_DEBUG_VFS ,"p9_client_link failed %d\n" , err); +return err; + } + +if (v9ses->cache ==CACHE_LOOSE || v9ses->cache ==CACHE_FSCACHE ) { +/* Get the latest stat info from server. */ +struct p9_stat_dotl *st; + + st =p9_client_getattr_dotl (oldfid); +if (IS_ERR (st)) +return PTR_ERR (st); + +v9fs_stat2inode_dotl (st, old_dentry->d_inode); + +kfree (st); + }else { +/* Caching disabled. No need to get upto date stat info. +* This dentry will be released immediately. So, just i_count++ +*/ +atomic_inc (&old_dentry->d_inode->i_count); + } + + dentry->d_op = old_dentry->d_op; +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
@@ -1248,7 +1311,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,
include/net/9p/9p.h +2 -0
@@ -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,
include/net/9p/client.h +1 -0
@@ -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,struct p9_fid *oldfid,char *newname);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,
net/9p/client.c +19 -0
@@ -1095,6 +1095,25 @@ error: }EXPORT_SYMBOL (p9_client_fcreate); +int p9_client_link (struct p9_fid *dfid,struct p9_fid *oldfid,char *newname) +{ +struct p9_client *clnt; +struct p9_req_t *req; + +P9_DPRINTK (P9_DEBUG_9P ,">>> TLINK dfid %d oldfid %d newname %s\n" , + dfid->fid, oldfid->fid, newname); + clnt = dfid->clnt; + req =p9_client_rpc (clnt,P9_TLINK ,"dds" , dfid->fid, oldfid->fid, + newname); +if (IS_ERR (req)) +return PTR_ERR (req); + +P9_DPRINTK (P9_DEBUG_9P ,"<<< RLINK\n" ); +p9_free_req (clnt, req); +return 0 ; +} +EXPORT_SYMBOL (p9_client_link); +int p9_client_clunk (struct p9_fid *fid) {int err;
Signature · 1 line
1.6.5.2