Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

9p: add 9P2000.L rename operation

I made a V2 of this patch on top of my patches for VFS switches.
All the changes were due to change in some offsets.

rename - change name of file or directory

size[4] Trename tag[2] fid[4] newdirfid[4] name[s]
size[4] Rrename tag[2]

The rename message is used to change the name of a file, possibly moving it
to a new directory. The 9P wstat message can only rename a file within the
same directory.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>

authored by

Sripathi Kodi and committed by
Eric Van Hensbergen
4681dbda bda8e775

+49
+7
fs/9p/vfs_inode.c
··· 794 794 goto clunk_olddir; 795 795 } 796 796 797 + if (v9fs_proto_dotl(v9ses)) { 798 + retval = p9_client_rename(oldfid, newdirfid, 799 + (char *) new_dentry->d_name.name); 800 + if (retval != -ENOSYS) 801 + goto clunk_newdir; 802 + } 803 + 797 804 /* 9P can only handle file rename in the same directory */ 798 805 if (memcmp(&olddirfid->qid, &newdirfid->qid, sizeof(newdirfid->qid))) { 799 806 P9_DPRINTK(P9_DEBUG_ERROR,
+13
include/net/9p/9p.h
··· 88 88 * enum p9_msg_t - 9P message types 89 89 * @P9_TSTATFS: file system status request 90 90 * @P9_RSTATFS: file system status response 91 + * @P9_TRENAME: rename request 92 + * @P9_RRENAME: rename response 91 93 * @P9_TVERSION: version handshake request 92 94 * @P9_RVERSION: version handshake response 93 95 * @P9_TAUTH: request to establish authentication channel ··· 131 129 enum p9_msg_t { 132 130 P9_TSTATFS = 8, 133 131 P9_RSTATFS, 132 + P9_TRENAME = 20, 133 + P9_RRENAME, 134 134 P9_TVERSION = 100, 135 135 P9_RVERSION, 136 136 P9_TAUTH = 102, ··· 372 368 u64 ffree; 373 369 u64 fsid; 374 370 u32 namelen; 371 + }; 372 + 373 + struct p9_trename { 374 + u32 fid; 375 + u32 newdirfid; 376 + struct p9_str name; 377 + }; 378 + 379 + struct p9_rrename { 375 380 }; 376 381 377 382 struct p9_tversion {
+1
include/net/9p/client.h
··· 196 196 }; 197 197 198 198 int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb); 199 + int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name); 199 200 int p9_client_version(struct p9_client *); 200 201 struct p9_client *p9_client_create(const char *dev_name, char *options); 201 202 void p9_client_destroy(struct p9_client *clnt);
+28
net/9p/client.c
··· 1404 1404 return err; 1405 1405 } 1406 1406 EXPORT_SYMBOL(p9_client_statfs); 1407 + 1408 + int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name) 1409 + { 1410 + int err; 1411 + struct p9_req_t *req; 1412 + struct p9_client *clnt; 1413 + 1414 + err = 0; 1415 + clnt = fid->clnt; 1416 + 1417 + P9_DPRINTK(P9_DEBUG_9P, ">>> TRENAME fid %d newdirfid %d name %s\n", 1418 + fid->fid, newdirfid->fid, name); 1419 + 1420 + req = p9_client_rpc(clnt, P9_TRENAME, "dds", fid->fid, 1421 + newdirfid->fid, name); 1422 + if (IS_ERR(req)) { 1423 + err = PTR_ERR(req); 1424 + goto error; 1425 + } 1426 + 1427 + P9_DPRINTK(P9_DEBUG_9P, "<<< RRENAME fid %d\n", fid->fid); 1428 + 1429 + p9_free_req(clnt, req); 1430 + error: 1431 + return err; 1432 + } 1433 + EXPORT_SYMBOL(p9_client_rename); 1434 +