Commit 342fee1d authored by Sripathi Kodi's avatar Sripathi Kodi Committed by Eric Van Hensbergen

9P2010.L handshake: Remove "dotu" variable

Removes 'dotu' variable and make everything dependent
on 'proto_version' field.
Signed-off-by: default avatarSripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent 0fb80abd
...@@ -262,7 +262,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, ...@@ -262,7 +262,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
goto error; goto error;
} }
if (!v9ses->clnt->dotu) if (!p9_is_proto_dotu(v9ses->clnt))
v9ses->flags &= ~V9FS_PROTO_2000U; v9ses->flags &= ~V9FS_PROTO_2000U;
v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ; v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ;
......
...@@ -135,7 +135,7 @@ static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -135,7 +135,7 @@ static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir)
while (rdir->head < rdir->tail) { while (rdir->head < rdir->tail) {
err = p9stat_read(rdir->buf + rdir->head, err = p9stat_read(rdir->buf + rdir->head,
buflen - rdir->head, &st, buflen - rdir->head, &st,
fid->clnt->dotu); fid->clnt->proto_version);
if (err) { if (err) {
P9_DPRINTK(P9_DEBUG_VFS, "returned %d\n", err); P9_DPRINTK(P9_DEBUG_VFS, "returned %d\n", err);
err = -EIO; err = -EIO;
......
...@@ -151,7 +151,6 @@ struct p9_req_t { ...@@ -151,7 +151,6 @@ struct p9_req_t {
struct p9_client { struct p9_client {
spinlock_t lock; /* protect client structure */ spinlock_t lock; /* protect client structure */
int msize; int msize;
unsigned char dotu;
unsigned char proto_version; unsigned char proto_version;
struct p9_trans_module *trans_mod; struct p9_trans_module *trans_mod;
enum p9_trans_status status; enum p9_trans_status status;
...@@ -224,5 +223,7 @@ int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int); ...@@ -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); int p9stat_read(char *, int, struct p9_wstat *, int);
void p9stat_free(struct p9_wstat *); 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 */ #endif /* NET_9P_CLIENT_H */
...@@ -58,6 +58,18 @@ static const match_table_t tokens = { ...@@ -58,6 +58,18 @@ static const match_table_t tokens = {
{Opt_err, NULL}, {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 */ /* Interpret mount option for protocol version */
static unsigned char get_protocol_version(const substring_t *name) static unsigned char get_protocol_version(const substring_t *name)
{ {
...@@ -97,7 +109,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) ...@@ -97,7 +109,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
int option; int option;
int ret = 0; int ret = 0;
clnt->dotu = 1; clnt->proto_version = p9_proto_2000u;
clnt->msize = 8192; clnt->msize = 8192;
if (!opts) if (!opts)
...@@ -140,7 +152,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) ...@@ -140,7 +152,7 @@ static int parse_opts(char *opts, struct p9_client *clnt)
} }
break; break;
case Opt_legacy: case Opt_legacy:
clnt->dotu = 0; clnt->proto_version = p9_proto_legacy;
break; break;
case Opt_version: case Opt_version:
ret = get_protocol_version(&args[0]); ret = get_protocol_version(&args[0]);
...@@ -438,14 +450,15 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req) ...@@ -438,14 +450,15 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
int ecode; int ecode;
char *ename; 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) { if (err) {
P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse error%d\n", P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse error%d\n",
err); err);
return err; return err;
} }
if (c->dotu) if (p9_is_proto_dotu(c))
err = -ecode; err = -ecode;
if (!err || !IS_ERR_VALUE(err)) if (!err || !IS_ERR_VALUE(err))
...@@ -543,7 +556,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) ...@@ -543,7 +556,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
/* marshall the data */ /* marshall the data */
p9pdu_prepare(req->tc, tag, type); p9pdu_prepare(req->tc, tag, type);
va_start(ap, fmt); 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); va_end(ap);
p9pdu_finalize(req->tc); p9pdu_finalize(req->tc);
...@@ -655,14 +668,14 @@ int p9_client_version(struct p9_client *c) ...@@ -655,14 +668,14 @@ int p9_client_version(struct p9_client *c)
char *version; char *version;
int msize; int msize;
P9_DPRINTK(P9_DEBUG_9P, ">>> TVERSION msize %d extended %d\n", P9_DPRINTK(P9_DEBUG_9P, ">>> TVERSION msize %d protocol %d\n",
c->msize, c->dotu); c->msize, c->proto_version);
req = p9_client_rpc(c, P9_TVERSION, "ds", c->msize, 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)) if (IS_ERR(req))
return PTR_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) { if (err) {
P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err);
p9pdu_dump(1, req->rc); p9pdu_dump(1, req->rc);
...@@ -670,10 +683,10 @@ int p9_client_version(struct p9_client *c) ...@@ -670,10 +683,10 @@ int p9_client_version(struct p9_client *c)
} }
P9_DPRINTK(P9_DEBUG_9P, "<<< RVERSION msize %d %s\n", msize, version); P9_DPRINTK(P9_DEBUG_9P, "<<< RVERSION msize %d %s\n", msize, version);
if (!memcmp(version, "9P2000.u", 8)) if (!strncmp(version, "9P2000.u", 8))
c->dotu = 1; c->proto_version = p9_proto_2000u;
else if (!memcmp(version, "9P2000", 6)) else if (!strncmp(version, "9P2000", 6))
c->dotu = 0; c->proto_version = p9_proto_legacy;
else { else {
err = -EREMOTEIO; err = -EREMOTEIO;
goto error; goto error;
...@@ -728,8 +741,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) ...@@ -728,8 +741,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
goto put_trans; goto put_trans;
} }
P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n", P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d protocol %d\n",
clnt, clnt->trans_mod, clnt->msize, clnt->dotu); clnt, clnt->trans_mod, clnt->msize, clnt->proto_version);
err = clnt->trans_mod->create(clnt, dev_name, options); err = clnt->trans_mod->create(clnt, dev_name, options);
if (err) if (err)
...@@ -812,7 +825,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, ...@@ -812,7 +825,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
goto error; goto error;
} }
err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid);
if (err) { if (err) {
p9pdu_dump(1, req->rc); p9pdu_dump(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
...@@ -861,7 +874,7 @@ p9_client_auth(struct p9_client *clnt, char *uname, u32 n_uname, char *aname) ...@@ -861,7 +874,7 @@ p9_client_auth(struct p9_client *clnt, char *uname, u32 n_uname, char *aname)
goto error; goto error;
} }
err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid);
if (err) { if (err) {
p9pdu_dump(1, req->rc); p9pdu_dump(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
...@@ -919,7 +932,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, ...@@ -919,7 +932,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames,
goto error; 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) { if (err) {
p9pdu_dump(1, req->rc); p9pdu_dump(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
...@@ -980,7 +993,7 @@ int p9_client_open(struct p9_fid *fid, int mode) ...@@ -980,7 +993,7 @@ int p9_client_open(struct p9_fid *fid, int mode)
goto error; 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) { if (err) {
p9pdu_dump(1, req->rc); p9pdu_dump(1, req->rc);
goto free_and_error; goto free_and_error;
...@@ -1025,7 +1038,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, ...@@ -1025,7 +1038,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
goto error; 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) { if (err) {
p9pdu_dump(1, req->rc); p9pdu_dump(1, req->rc);
goto free_and_error; goto free_and_error;
...@@ -1126,7 +1139,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, ...@@ -1126,7 +1139,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
goto error; 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) { if (err) {
p9pdu_dump(1, req->rc); p9pdu_dump(1, req->rc);
goto free_and_error; goto free_and_error;
...@@ -1187,7 +1200,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, ...@@ -1187,7 +1200,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
goto error; goto error;
} }
err = p9pdu_readf(req->rc, clnt->dotu, "d", &count); err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count);
if (err) { if (err) {
p9pdu_dump(1, req->rc); p9pdu_dump(1, req->rc);
goto free_and_error; goto free_and_error;
...@@ -1227,7 +1240,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid) ...@@ -1227,7 +1240,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
goto error; 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) { if (err) {
p9pdu_dump(1, req->rc); p9pdu_dump(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
...@@ -1254,7 +1267,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid) ...@@ -1254,7 +1267,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
} }
EXPORT_SYMBOL(p9_client_stat); 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; int ret;
...@@ -1273,7 +1286,7 @@ static int p9_client_statsize(struct p9_wstat *wst, int optional) ...@@ -1273,7 +1286,7 @@ static int p9_client_statsize(struct p9_wstat *wst, int optional)
if (wst->muid) if (wst->muid)
ret += strlen(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] */ ret += 2+4+4+4; /* extension[s] n_uid[4] n_gid[4] n_muid[4] */
if (wst->extension) if (wst->extension)
ret += strlen(wst->extension); ret += strlen(wst->extension);
...@@ -1290,7 +1303,7 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst) ...@@ -1290,7 +1303,7 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst)
err = 0; err = 0;
clnt = fid->clnt; 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, ">>> TWSTAT fid %d\n", fid->fid);
P9_DPRINTK(P9_DEBUG_9P, P9_DPRINTK(P9_DEBUG_9P,
" sz=%x type=%x dev=%x qid=%x.%llx.%x\n" " sz=%x type=%x dev=%x qid=%x.%llx.%x\n"
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#endif #endif
static int static int
p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...); p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...);
#ifdef CONFIG_NET_9P_DEBUG #ifdef CONFIG_NET_9P_DEBUG
void void
...@@ -144,7 +144,8 @@ pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size) ...@@ -144,7 +144,8 @@ pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size)
*/ */
static int static int
p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
va_list ap)
{ {
const char *ptr; const char *ptr;
int errcode = 0; int errcode = 0;
...@@ -194,7 +195,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -194,7 +195,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
int16_t len; int16_t len;
int size; int size;
errcode = p9pdu_readf(pdu, optional, "w", &len); errcode = p9pdu_readf(pdu, proto_version,
"w", &len);
if (errcode) if (errcode)
break; break;
...@@ -217,7 +219,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -217,7 +219,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
struct p9_qid *qid = struct p9_qid *qid =
va_arg(ap, struct p9_qid *); va_arg(ap, struct p9_qid *);
errcode = p9pdu_readf(pdu, optional, "bdq", errcode = p9pdu_readf(pdu, proto_version, "bdq",
&qid->type, &qid->version, &qid->type, &qid->version,
&qid->path); &qid->path);
} }
...@@ -230,7 +232,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -230,7 +232,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
stbuf->n_uid = stbuf->n_gid = stbuf->n_muid = stbuf->n_uid = stbuf->n_gid = stbuf->n_muid =
-1; -1;
errcode = errcode =
p9pdu_readf(pdu, optional, p9pdu_readf(pdu, proto_version,
"wwdQdddqssss?sddd", "wwdQdddqssss?sddd",
&stbuf->size, &stbuf->type, &stbuf->size, &stbuf->type,
&stbuf->dev, &stbuf->qid, &stbuf->dev, &stbuf->qid,
...@@ -250,7 +252,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -250,7 +252,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
void **data = va_arg(ap, void **); void **data = va_arg(ap, void **);
errcode = errcode =
p9pdu_readf(pdu, optional, "d", count); p9pdu_readf(pdu, proto_version, "d", count);
if (!errcode) { if (!errcode) {
*count = *count =
MIN(*count, MIN(*count,
...@@ -263,8 +265,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -263,8 +265,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
int16_t *nwname = va_arg(ap, int16_t *); int16_t *nwname = va_arg(ap, int16_t *);
char ***wnames = va_arg(ap, char ***); char ***wnames = va_arg(ap, char ***);
errcode = errcode = p9pdu_readf(pdu, proto_version,
p9pdu_readf(pdu, optional, "w", nwname); "w", nwname);
if (!errcode) { if (!errcode) {
*wnames = *wnames =
kmalloc(sizeof(char *) * *nwname, kmalloc(sizeof(char *) * *nwname,
...@@ -278,7 +280,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -278,7 +280,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
for (i = 0; i < *nwname; i++) { for (i = 0; i < *nwname; i++) {
errcode = errcode =
p9pdu_readf(pdu, optional, p9pdu_readf(pdu,
proto_version,
"s", "s",
&(*wnames)[i]); &(*wnames)[i]);
if (errcode) if (errcode)
...@@ -306,7 +309,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -306,7 +309,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
*wqids = NULL; *wqids = NULL;
errcode = errcode =
p9pdu_readf(pdu, optional, "w", nwqid); p9pdu_readf(pdu, proto_version, "w", nwqid);
if (!errcode) { if (!errcode) {
*wqids = *wqids =
kmalloc(*nwqid * kmalloc(*nwqid *
...@@ -321,7 +324,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -321,7 +324,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
for (i = 0; i < *nwqid; i++) { for (i = 0; i < *nwqid; i++) {
errcode = errcode =
p9pdu_readf(pdu, optional, p9pdu_readf(pdu,
proto_version,
"Q", "Q",
&(*wqids)[i]); &(*wqids)[i]);
if (errcode) if (errcode)
...@@ -336,7 +340,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -336,7 +340,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
} }
break; break;
case '?': case '?':
if (!optional) if (proto_version != p9_proto_2000u)
return 0; return 0;
break; break;
default: default:
...@@ -352,7 +356,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -352,7 +356,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
} }
int int
p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
va_list ap)
{ {
const char *ptr; const char *ptr;
int errcode = 0; int errcode = 0;
...@@ -389,7 +394,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -389,7 +394,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
if (sptr) if (sptr)
len = MIN(strlen(sptr), USHORT_MAX); len = MIN(strlen(sptr), USHORT_MAX);
errcode = p9pdu_writef(pdu, optional, "w", len); errcode = p9pdu_writef(pdu, proto_version,
"w", len);
if (!errcode && pdu_write(pdu, sptr, len)) if (!errcode && pdu_write(pdu, sptr, len))
errcode = -EFAULT; errcode = -EFAULT;
} }
...@@ -398,7 +404,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -398,7 +404,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
const struct p9_qid *qid = const struct p9_qid *qid =
va_arg(ap, const struct p9_qid *); va_arg(ap, const struct p9_qid *);
errcode = errcode =
p9pdu_writef(pdu, optional, "bdq", p9pdu_writef(pdu, proto_version, "bdq",
qid->type, qid->version, qid->type, qid->version,
qid->path); qid->path);
} break; } break;
...@@ -406,7 +412,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -406,7 +412,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
const struct p9_wstat *stbuf = const struct p9_wstat *stbuf =
va_arg(ap, const struct p9_wstat *); va_arg(ap, const struct p9_wstat *);
errcode = errcode =
p9pdu_writef(pdu, optional, p9pdu_writef(pdu, proto_version,
"wwdQdddqssss?sddd", "wwdQdddqssss?sddd",
stbuf->size, stbuf->type, stbuf->size, stbuf->type,
stbuf->dev, &stbuf->qid, stbuf->dev, &stbuf->qid,
...@@ -421,8 +427,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -421,8 +427,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
int32_t count = va_arg(ap, int32_t); int32_t count = va_arg(ap, int32_t);
const void *data = va_arg(ap, const void *); const void *data = va_arg(ap, const void *);
errcode = errcode = p9pdu_writef(pdu, proto_version, "d",
p9pdu_writef(pdu, optional, "d", count); count);
if (!errcode && pdu_write(pdu, data, count)) if (!errcode && pdu_write(pdu, data, count))
errcode = -EFAULT; errcode = -EFAULT;
} }
...@@ -431,8 +437,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -431,8 +437,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
int32_t count = va_arg(ap, int32_t); int32_t count = va_arg(ap, int32_t);
const char __user *udata = const char __user *udata =
va_arg(ap, const void __user *); va_arg(ap, const void __user *);
errcode = errcode = p9pdu_writef(pdu, proto_version, "d",
p9pdu_writef(pdu, optional, "d", count); count);
if (!errcode && pdu_write_u(pdu, udata, count)) if (!errcode && pdu_write_u(pdu, udata, count))
errcode = -EFAULT; errcode = -EFAULT;
} }
...@@ -441,14 +447,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -441,14 +447,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
int16_t nwname = va_arg(ap, int); int16_t nwname = va_arg(ap, int);
const char **wnames = va_arg(ap, const char **); const char **wnames = va_arg(ap, const char **);
errcode = errcode = p9pdu_writef(pdu, proto_version, "w",
p9pdu_writef(pdu, optional, "w", nwname); nwname);
if (!errcode) { if (!errcode) {
int i; int i;
for (i = 0; i < nwname; i++) { for (i = 0; i < nwname; i++) {
errcode = errcode =
p9pdu_writef(pdu, optional, p9pdu_writef(pdu,
proto_version,
"s", "s",
wnames[i]); wnames[i]);
if (errcode) if (errcode)
...@@ -462,14 +469,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -462,14 +469,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
struct p9_qid *wqids = struct p9_qid *wqids =
va_arg(ap, struct p9_qid *); va_arg(ap, struct p9_qid *);
errcode = errcode = p9pdu_writef(pdu, proto_version, "w",
p9pdu_writef(pdu, optional, "w", nwqid); nwqid);
if (!errcode) { if (!errcode) {
int i; int i;
for (i = 0; i < nwqid; i++) { for (i = 0; i < nwqid; i++) {
errcode = errcode =
p9pdu_writef(pdu, optional, p9pdu_writef(pdu,
proto_version,
"Q", "Q",
&wqids[i]); &wqids[i]);
if (errcode) if (errcode)
...@@ -479,7 +487,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -479,7 +487,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
} }
break; break;
case '?': case '?':
if (!optional) if (proto_version != p9_proto_2000u)
return 0; return 0;
break; break;
default: default:
...@@ -494,32 +502,32 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -494,32 +502,32 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
return errcode; return errcode;
} }
int p9pdu_readf(struct p9_fcall *pdu, int optional, const char *fmt, ...) int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...)
{ {
va_list ap; va_list ap;
int ret; int ret;
va_start(ap, fmt); va_start(ap, fmt);
ret = p9pdu_vreadf(pdu, optional, fmt, ap); ret = p9pdu_vreadf(pdu, proto_version, fmt, ap);
va_end(ap); va_end(ap);
return ret; return ret;
} }
static int static int
p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...) p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...)
{ {
va_list ap; va_list ap;
int ret; int ret;
va_start(ap, fmt); va_start(ap, fmt);
ret = p9pdu_vwritef(pdu, optional, fmt, ap); ret = p9pdu_vwritef(pdu, proto_version, fmt, ap);
va_end(ap); va_end(ap);
return ret; return ret;
} }
int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu) int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version)
{ {
struct p9_fcall fake_pdu; struct p9_fcall fake_pdu;
int ret; int ret;
...@@ -529,7 +537,7 @@ int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu) ...@@ -529,7 +537,7 @@ int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu)
fake_pdu.sdata = buf; fake_pdu.sdata = buf;
fake_pdu.offset = 0; fake_pdu.offset = 0;
ret = p9pdu_readf(&fake_pdu, dotu, "S", st); ret = p9pdu_readf(&fake_pdu, proto_version, "S", st);
if (ret) { if (ret) {
P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret);
p9pdu_dump(1, &fake_pdu); p9pdu_dump(1, &fake_pdu);
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
* *
*/ */
int int p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap); va_list ap);
int p9pdu_readf(struct p9_fcall *pdu, int optional, const char *fmt, ...); int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...);
int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type); int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type);
int p9pdu_finalize(struct p9_fcall *pdu); int p9pdu_finalize(struct p9_fcall *pdu);
void p9pdu_dump(int, struct p9_fcall *); void p9pdu_dump(int, struct p9_fcall *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment