Skip to content

Commit

Permalink
9p: add 9P2000.L rename operation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sripathi Kodi authored and Eric Van Hensbergen committed May 21, 2010
1 parent bda8e77 commit 4681dbd
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,13 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
goto clunk_olddir;
}

if (v9fs_proto_dotl(v9ses)) {
retval = p9_client_rename(oldfid, newdirfid,
(char *) new_dentry->d_name.name);
if (retval != -ENOSYS)
goto clunk_newdir;
}

/* 9P can only handle file rename in the same directory */
if (memcmp(&olddirfid->qid, &newdirfid->qid, sizeof(newdirfid->qid))) {
P9_DPRINTK(P9_DEBUG_ERROR,
Expand Down
13 changes: 13 additions & 0 deletions include/net/9p/9p.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ do { \
* enum p9_msg_t - 9P message types
* @P9_TSTATFS: file system status request
* @P9_RSTATFS: file system status response
* @P9_TRENAME: rename request
* @P9_RRENAME: rename response
* @P9_TVERSION: version handshake request
* @P9_RVERSION: version handshake response
* @P9_TAUTH: request to establish authentication channel
Expand Down Expand Up @@ -129,6 +131,8 @@ do { \
enum p9_msg_t {
P9_TSTATFS = 8,
P9_RSTATFS,
P9_TRENAME = 20,
P9_RRENAME,
P9_TVERSION = 100,
P9_RVERSION,
P9_TAUTH = 102,
Expand Down Expand Up @@ -370,6 +374,15 @@ struct p9_rstatfs {
u32 namelen;
};

struct p9_trename {
u32 fid;
u32 newdirfid;
struct p9_str name;
};

struct p9_rrename {
};

struct p9_tversion {
u32 msize;
struct p9_str version;
Expand Down
1 change: 1 addition & 0 deletions include/net/9p/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ struct p9_fid {
};

int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb);
int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name);
int p9_client_version(struct p9_client *);
struct p9_client *p9_client_create(const char *dev_name, char *options);
void p9_client_destroy(struct p9_client *clnt);
Expand Down
28 changes: 28 additions & 0 deletions net/9p/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1404,3 +1404,31 @@ int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb)
return err;
}
EXPORT_SYMBOL(p9_client_statfs);

int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name)
{
int err;
struct p9_req_t *req;
struct p9_client *clnt;

err = 0;
clnt = fid->clnt;

P9_DPRINTK(P9_DEBUG_9P, ">>> TRENAME fid %d newdirfid %d name %s\n",
fid->fid, newdirfid->fid, name);

req = p9_client_rpc(clnt, P9_TRENAME, "dds", fid->fid,
newdirfid->fid, name);
if (IS_ERR(req)) {
err = PTR_ERR(req);
goto error;
}

P9_DPRINTK(P9_DEBUG_9P, "<<< RRENAME fid %d\n", fid->fid);

p9_free_req(clnt, req);
error:
return err;
}
EXPORT_SYMBOL(p9_client_rename);

0 comments on commit 4681dbd

Please sign in to comment.