Skip to content

Commit

Permalink
9P2010.L handshake: Remove "dotu" variable
Browse files Browse the repository at this point in the history
Removes 'dotu' variable and make everything dependent
on 'proto_version' field.

Signed-off-by: Sripathi Kodi <[email protected]>
Signed-off-by: Eric Van Hensbergen <[email protected]>
  • Loading branch information
sripathi authored and ericvh committed Mar 5, 2010
1 parent 0fb80ab commit 342fee1
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 65 deletions.
2 changes: 1 addition & 1 deletion fs/9p/v9fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
goto error;
}

if (!v9ses->clnt->dotu)
if (!p9_is_proto_dotu(v9ses->clnt))
v9ses->flags &= ~V9FS_PROTO_2000U;

v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ;
Expand Down
2 changes: 1 addition & 1 deletion fs/9p/vfs_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir)
while (rdir->head < rdir->tail) {
err = p9stat_read(rdir->buf + rdir->head,
buflen - rdir->head, &st,
fid->clnt->dotu);
fid->clnt->proto_version);
if (err) {
P9_DPRINTK(P9_DEBUG_VFS, "returned %d\n", err);
err = -EIO;
Expand Down
3 changes: 2 additions & 1 deletion include/net/9p/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ struct p9_req_t {
struct p9_client {
spinlock_t lock; /* protect client structure */
int msize;
unsigned char dotu;
unsigned char proto_version;
struct p9_trans_module *trans_mod;
enum p9_trans_status status;
Expand Down Expand Up @@ -224,5 +223,7 @@ int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int);
int p9stat_read(char *, int, struct p9_wstat *, int);
void p9stat_free(struct p9_wstat *);

int p9_is_proto_dotu(struct p9_client *clnt);
int p9_is_proto_dotl(struct p9_client *clnt);

#endif /* NET_9P_CLIENT_H */
65 changes: 39 additions & 26 deletions net/9p/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ static const match_table_t tokens = {
{Opt_err, NULL},
};

inline int p9_is_proto_dotl(struct p9_client *clnt)
{
return (clnt->proto_version == p9_proto_2010L);
}
EXPORT_SYMBOL(p9_is_proto_dotl);

inline int p9_is_proto_dotu(struct p9_client *clnt)
{
return (clnt->proto_version == p9_proto_2000u);
}
EXPORT_SYMBOL(p9_is_proto_dotu);

/* Interpret mount option for protocol version */
static unsigned char get_protocol_version(const substring_t *name)
{
Expand Down Expand Up @@ -97,7 +109,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
int option;
int ret = 0;

clnt->dotu = 1;
clnt->proto_version = p9_proto_2000u;
clnt->msize = 8192;

if (!opts)
Expand Down Expand Up @@ -140,7 +152,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
}
break;
case Opt_legacy:
clnt->dotu = 0;
clnt->proto_version = p9_proto_legacy;
break;
case Opt_version:
ret = get_protocol_version(&args[0]);
Expand Down Expand Up @@ -438,14 +450,15 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
int ecode;
char *ename;

err = p9pdu_readf(req->rc, c->dotu, "s?d", &ename, &ecode);
err = p9pdu_readf(req->rc, c->proto_version, "s?d",
&ename, &ecode);
if (err) {
P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse error%d\n",
err);
return err;
}

if (c->dotu)
if (p9_is_proto_dotu(c))
err = -ecode;

if (!err || !IS_ERR_VALUE(err))
Expand Down Expand Up @@ -543,7 +556,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
/* marshall the data */
p9pdu_prepare(req->tc, tag, type);
va_start(ap, fmt);
err = p9pdu_vwritef(req->tc, c->dotu, fmt, ap);
err = p9pdu_vwritef(req->tc, c->proto_version, fmt, ap);
va_end(ap);
p9pdu_finalize(req->tc);

Expand Down Expand Up @@ -655,25 +668,25 @@ int p9_client_version(struct p9_client *c)
char *version;
int msize;

P9_DPRINTK(P9_DEBUG_9P, ">>> TVERSION msize %d extended %d\n",
c->msize, c->dotu);
P9_DPRINTK(P9_DEBUG_9P, ">>> TVERSION msize %d protocol %d\n",
c->msize, c->proto_version);
req = p9_client_rpc(c, P9_TVERSION, "ds", c->msize,
c->dotu ? "9P2000.u" : "9P2000");
p9_is_proto_dotu(c) ? "9P2000.u" : "9P2000");
if (IS_ERR(req))
return PTR_ERR(req);

err = p9pdu_readf(req->rc, c->dotu, "ds", &msize, &version);
err = p9pdu_readf(req->rc, c->proto_version, "ds", &msize, &version);
if (err) {
P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err);
p9pdu_dump(1, req->rc);
goto error;
}

P9_DPRINTK(P9_DEBUG_9P, "<<< RVERSION msize %d %s\n", msize, version);
if (!memcmp(version, "9P2000.u", 8))
c->dotu = 1;
else if (!memcmp(version, "9P2000", 6))
c->dotu = 0;
if (!strncmp(version, "9P2000.u", 8))
c->proto_version = p9_proto_2000u;
else if (!strncmp(version, "9P2000", 6))
c->proto_version = p9_proto_legacy;
else {
err = -EREMOTEIO;
goto error;
Expand Down Expand Up @@ -728,8 +741,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
goto put_trans;
}

P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n",
clnt, clnt->trans_mod, clnt->msize, clnt->dotu);
P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d protocol %d\n",
clnt, clnt->trans_mod, clnt->msize, clnt->proto_version);

err = clnt->trans_mod->create(clnt, dev_name, options);
if (err)
Expand Down Expand Up @@ -812,7 +825,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
goto error;
}

err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid);
err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid);
if (err) {
p9pdu_dump(1, req->rc);
p9_free_req(clnt, req);
Expand Down Expand Up @@ -861,7 +874,7 @@ p9_client_auth(struct p9_client *clnt, char *uname, u32 n_uname, char *aname)
goto error;
}

err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid);
err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid);
if (err) {
p9pdu_dump(1, req->rc);
p9_free_req(clnt, req);
Expand Down Expand Up @@ -919,7 +932,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames,
goto error;
}

err = p9pdu_readf(req->rc, clnt->dotu, "R", &nwqids, &wqids);
err = p9pdu_readf(req->rc, clnt->proto_version, "R", &nwqids, &wqids);
if (err) {
p9pdu_dump(1, req->rc);
p9_free_req(clnt, req);
Expand Down Expand Up @@ -980,7 +993,7 @@ int p9_client_open(struct p9_fid *fid, int mode)
goto error;
}

err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit);
err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit);
if (err) {
p9pdu_dump(1, req->rc);
goto free_and_error;
Expand Down Expand Up @@ -1025,7 +1038,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
goto error;
}

err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit);
err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit);
if (err) {
p9pdu_dump(1, req->rc);
goto free_and_error;
Expand Down Expand Up @@ -1126,7 +1139,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
goto error;
}

err = p9pdu_readf(req->rc, clnt->dotu, "D", &count, &dataptr);
err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr);
if (err) {
p9pdu_dump(1, req->rc);
goto free_and_error;
Expand Down Expand Up @@ -1187,7 +1200,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
goto error;
}

err = p9pdu_readf(req->rc, clnt->dotu, "d", &count);
err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count);
if (err) {
p9pdu_dump(1, req->rc);
goto free_and_error;
Expand Down Expand Up @@ -1227,7 +1240,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
goto error;
}

err = p9pdu_readf(req->rc, clnt->dotu, "wS", &ignored, ret);
err = p9pdu_readf(req->rc, clnt->proto_version, "wS", &ignored, ret);
if (err) {
p9pdu_dump(1, req->rc);
p9_free_req(clnt, req);
Expand All @@ -1254,7 +1267,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
}
EXPORT_SYMBOL(p9_client_stat);

static int p9_client_statsize(struct p9_wstat *wst, int optional)
static int p9_client_statsize(struct p9_wstat *wst, int proto_version)
{
int ret;

Expand All @@ -1273,7 +1286,7 @@ static int p9_client_statsize(struct p9_wstat *wst, int optional)
if (wst->muid)
ret += strlen(wst->muid);

if (optional) {
if (proto_version == p9_proto_2000u) {
ret += 2+4+4+4; /* extension[s] n_uid[4] n_gid[4] n_muid[4] */
if (wst->extension)
ret += strlen(wst->extension);
Expand All @@ -1290,7 +1303,7 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst)

err = 0;
clnt = fid->clnt;
wst->size = p9_client_statsize(wst, clnt->dotu);
wst->size = p9_client_statsize(wst, clnt->proto_version);
P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid);
P9_DPRINTK(P9_DEBUG_9P,
" sz=%x type=%x dev=%x qid=%x.%llx.%x\n"
Expand Down
Loading

0 comments on commit 342fee1

Please sign in to comment.