diff options
author | Sripathi Kodi <sripathik@in.ibm.com> | 2010-03-05 13:50:14 -0500 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2010-03-05 16:04:42 -0500 |
commit | 342fee1d5c7dfa05f4e14ec1e583df4553b09776 (patch) | |
tree | 87931dea926f16b44374db8a849ef131cd6ff3de /net | |
parent | 0fb80abd911a7cb1e6548b5279568dc1e8949702 (diff) |
9P2010.L handshake: Remove "dotu" variable
Removes 'dotu' variable and make everything dependent
on 'proto_version' field.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/9p/client.c | 65 | ||||
-rw-r--r-- | net/9p/protocol.c | 74 | ||||
-rw-r--r-- | net/9p/protocol.h | 6 |
3 files changed, 83 insertions, 62 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index 3b5f3c94a6eb..9994676e57da 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -58,6 +58,18 @@ static const match_table_t tokens = { | |||
58 | {Opt_err, NULL}, | 58 | {Opt_err, NULL}, |
59 | }; | 59 | }; |
60 | 60 | ||
61 | inline int p9_is_proto_dotl(struct p9_client *clnt) | ||
62 | { | ||
63 | return (clnt->proto_version == p9_proto_2010L); | ||
64 | } | ||
65 | EXPORT_SYMBOL(p9_is_proto_dotl); | ||
66 | |||
67 | inline int p9_is_proto_dotu(struct p9_client *clnt) | ||
68 | { | ||
69 | return (clnt->proto_version == p9_proto_2000u); | ||
70 | } | ||
71 | EXPORT_SYMBOL(p9_is_proto_dotu); | ||
72 | |||
61 | /* Interpret mount option for protocol version */ | 73 | /* Interpret mount option for protocol version */ |
62 | static unsigned char get_protocol_version(const substring_t *name) | 74 | static unsigned char get_protocol_version(const substring_t *name) |
63 | { | 75 | { |
@@ -97,7 +109,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
97 | int option; | 109 | int option; |
98 | int ret = 0; | 110 | int ret = 0; |
99 | 111 | ||
100 | clnt->dotu = 1; | 112 | clnt->proto_version = p9_proto_2000u; |
101 | clnt->msize = 8192; | 113 | clnt->msize = 8192; |
102 | 114 | ||
103 | if (!opts) | 115 | if (!opts) |
@@ -140,7 +152,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
140 | } | 152 | } |
141 | break; | 153 | break; |
142 | case Opt_legacy: | 154 | case Opt_legacy: |
143 | clnt->dotu = 0; | 155 | clnt->proto_version = p9_proto_legacy; |
144 | break; | 156 | break; |
145 | case Opt_version: | 157 | case Opt_version: |
146 | ret = get_protocol_version(&args[0]); | 158 | 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 | int ecode; | 450 | int ecode; |
439 | char *ename; | 451 | char *ename; |
440 | 452 | ||
441 | err = p9pdu_readf(req->rc, c->dotu, "s?d", &ename, &ecode); | 453 | err = p9pdu_readf(req->rc, c->proto_version, "s?d", |
454 | &ename, &ecode); | ||
442 | if (err) { | 455 | if (err) { |
443 | P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse error%d\n", | 456 | P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse error%d\n", |
444 | err); | 457 | err); |
445 | return err; | 458 | return err; |
446 | } | 459 | } |
447 | 460 | ||
448 | if (c->dotu) | 461 | if (p9_is_proto_dotu(c)) |
449 | err = -ecode; | 462 | err = -ecode; |
450 | 463 | ||
451 | if (!err || !IS_ERR_VALUE(err)) | 464 | if (!err || !IS_ERR_VALUE(err)) |
@@ -543,7 +556,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) | |||
543 | /* marshall the data */ | 556 | /* marshall the data */ |
544 | p9pdu_prepare(req->tc, tag, type); | 557 | p9pdu_prepare(req->tc, tag, type); |
545 | va_start(ap, fmt); | 558 | va_start(ap, fmt); |
546 | err = p9pdu_vwritef(req->tc, c->dotu, fmt, ap); | 559 | err = p9pdu_vwritef(req->tc, c->proto_version, fmt, ap); |
547 | va_end(ap); | 560 | va_end(ap); |
548 | p9pdu_finalize(req->tc); | 561 | p9pdu_finalize(req->tc); |
549 | 562 | ||
@@ -655,14 +668,14 @@ int p9_client_version(struct p9_client *c) | |||
655 | char *version; | 668 | char *version; |
656 | int msize; | 669 | int msize; |
657 | 670 | ||
658 | P9_DPRINTK(P9_DEBUG_9P, ">>> TVERSION msize %d extended %d\n", | 671 | P9_DPRINTK(P9_DEBUG_9P, ">>> TVERSION msize %d protocol %d\n", |
659 | c->msize, c->dotu); | 672 | c->msize, c->proto_version); |
660 | req = p9_client_rpc(c, P9_TVERSION, "ds", c->msize, | 673 | req = p9_client_rpc(c, P9_TVERSION, "ds", c->msize, |
661 | c->dotu ? "9P2000.u" : "9P2000"); | 674 | p9_is_proto_dotu(c) ? "9P2000.u" : "9P2000"); |
662 | if (IS_ERR(req)) | 675 | if (IS_ERR(req)) |
663 | return PTR_ERR(req); | 676 | return PTR_ERR(req); |
664 | 677 | ||
665 | err = p9pdu_readf(req->rc, c->dotu, "ds", &msize, &version); | 678 | err = p9pdu_readf(req->rc, c->proto_version, "ds", &msize, &version); |
666 | if (err) { | 679 | if (err) { |
667 | P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); | 680 | P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); |
668 | p9pdu_dump(1, req->rc); | 681 | p9pdu_dump(1, req->rc); |
@@ -670,10 +683,10 @@ int p9_client_version(struct p9_client *c) | |||
670 | } | 683 | } |
671 | 684 | ||
672 | P9_DPRINTK(P9_DEBUG_9P, "<<< RVERSION msize %d %s\n", msize, version); | 685 | P9_DPRINTK(P9_DEBUG_9P, "<<< RVERSION msize %d %s\n", msize, version); |
673 | if (!memcmp(version, "9P2000.u", 8)) | 686 | if (!strncmp(version, "9P2000.u", 8)) |
674 | c->dotu = 1; | 687 | c->proto_version = p9_proto_2000u; |
675 | else if (!memcmp(version, "9P2000", 6)) | 688 | else if (!strncmp(version, "9P2000", 6)) |
676 | c->dotu = 0; | 689 | c->proto_version = p9_proto_legacy; |
677 | else { | 690 | else { |
678 | err = -EREMOTEIO; | 691 | err = -EREMOTEIO; |
679 | goto error; | 692 | goto error; |
@@ -728,8 +741,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
728 | goto put_trans; | 741 | goto put_trans; |
729 | } | 742 | } |
730 | 743 | ||
731 | P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n", | 744 | P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d protocol %d\n", |
732 | clnt, clnt->trans_mod, clnt->msize, clnt->dotu); | 745 | clnt, clnt->trans_mod, clnt->msize, clnt->proto_version); |
733 | 746 | ||
734 | err = clnt->trans_mod->create(clnt, dev_name, options); | 747 | err = clnt->trans_mod->create(clnt, dev_name, options); |
735 | if (err) | 748 | if (err) |
@@ -812,7 +825,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, | |||
812 | goto error; | 825 | goto error; |
813 | } | 826 | } |
814 | 827 | ||
815 | err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); | 828 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid); |
816 | if (err) { | 829 | if (err) { |
817 | p9pdu_dump(1, req->rc); | 830 | p9pdu_dump(1, req->rc); |
818 | p9_free_req(clnt, req); | 831 | p9_free_req(clnt, req); |
@@ -861,7 +874,7 @@ p9_client_auth(struct p9_client *clnt, char *uname, u32 n_uname, char *aname) | |||
861 | goto error; | 874 | goto error; |
862 | } | 875 | } |
863 | 876 | ||
864 | err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); | 877 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid); |
865 | if (err) { | 878 | if (err) { |
866 | p9pdu_dump(1, req->rc); | 879 | p9pdu_dump(1, req->rc); |
867 | p9_free_req(clnt, req); | 880 | p9_free_req(clnt, req); |
@@ -919,7 +932,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, | |||
919 | goto error; | 932 | goto error; |
920 | } | 933 | } |
921 | 934 | ||
922 | err = p9pdu_readf(req->rc, clnt->dotu, "R", &nwqids, &wqids); | 935 | err = p9pdu_readf(req->rc, clnt->proto_version, "R", &nwqids, &wqids); |
923 | if (err) { | 936 | if (err) { |
924 | p9pdu_dump(1, req->rc); | 937 | p9pdu_dump(1, req->rc); |
925 | p9_free_req(clnt, req); | 938 | p9_free_req(clnt, req); |
@@ -980,7 +993,7 @@ int p9_client_open(struct p9_fid *fid, int mode) | |||
980 | goto error; | 993 | goto error; |
981 | } | 994 | } |
982 | 995 | ||
983 | err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); | 996 | err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); |
984 | if (err) { | 997 | if (err) { |
985 | p9pdu_dump(1, req->rc); | 998 | p9pdu_dump(1, req->rc); |
986 | goto free_and_error; | 999 | goto free_and_error; |
@@ -1025,7 +1038,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, | |||
1025 | goto error; | 1038 | goto error; |
1026 | } | 1039 | } |
1027 | 1040 | ||
1028 | err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); | 1041 | err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); |
1029 | if (err) { | 1042 | if (err) { |
1030 | p9pdu_dump(1, req->rc); | 1043 | p9pdu_dump(1, req->rc); |
1031 | goto free_and_error; | 1044 | goto free_and_error; |
@@ -1126,7 +1139,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, | |||
1126 | goto error; | 1139 | goto error; |
1127 | } | 1140 | } |
1128 | 1141 | ||
1129 | err = p9pdu_readf(req->rc, clnt->dotu, "D", &count, &dataptr); | 1142 | err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); |
1130 | if (err) { | 1143 | if (err) { |
1131 | p9pdu_dump(1, req->rc); | 1144 | p9pdu_dump(1, req->rc); |
1132 | goto free_and_error; | 1145 | goto free_and_error; |
@@ -1187,7 +1200,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, | |||
1187 | goto error; | 1200 | goto error; |
1188 | } | 1201 | } |
1189 | 1202 | ||
1190 | err = p9pdu_readf(req->rc, clnt->dotu, "d", &count); | 1203 | err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count); |
1191 | if (err) { | 1204 | if (err) { |
1192 | p9pdu_dump(1, req->rc); | 1205 | p9pdu_dump(1, req->rc); |
1193 | goto free_and_error; | 1206 | goto free_and_error; |
@@ -1227,7 +1240,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid) | |||
1227 | goto error; | 1240 | goto error; |
1228 | } | 1241 | } |
1229 | 1242 | ||
1230 | err = p9pdu_readf(req->rc, clnt->dotu, "wS", &ignored, ret); | 1243 | err = p9pdu_readf(req->rc, clnt->proto_version, "wS", &ignored, ret); |
1231 | if (err) { | 1244 | if (err) { |
1232 | p9pdu_dump(1, req->rc); | 1245 | p9pdu_dump(1, req->rc); |
1233 | p9_free_req(clnt, req); | 1246 | p9_free_req(clnt, req); |
@@ -1254,7 +1267,7 @@ error: | |||
1254 | } | 1267 | } |
1255 | EXPORT_SYMBOL(p9_client_stat); | 1268 | EXPORT_SYMBOL(p9_client_stat); |
1256 | 1269 | ||
1257 | static int p9_client_statsize(struct p9_wstat *wst, int optional) | 1270 | static int p9_client_statsize(struct p9_wstat *wst, int proto_version) |
1258 | { | 1271 | { |
1259 | int ret; | 1272 | int ret; |
1260 | 1273 | ||
@@ -1273,7 +1286,7 @@ static int p9_client_statsize(struct p9_wstat *wst, int optional) | |||
1273 | if (wst->muid) | 1286 | if (wst->muid) |
1274 | ret += strlen(wst->muid); | 1287 | ret += strlen(wst->muid); |
1275 | 1288 | ||
1276 | if (optional) { | 1289 | if (proto_version == p9_proto_2000u) { |
1277 | ret += 2+4+4+4; /* extension[s] n_uid[4] n_gid[4] n_muid[4] */ | 1290 | ret += 2+4+4+4; /* extension[s] n_uid[4] n_gid[4] n_muid[4] */ |
1278 | if (wst->extension) | 1291 | if (wst->extension) |
1279 | ret += strlen(wst->extension); | 1292 | ret += strlen(wst->extension); |
@@ -1290,7 +1303,7 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst) | |||
1290 | 1303 | ||
1291 | err = 0; | 1304 | err = 0; |
1292 | clnt = fid->clnt; | 1305 | clnt = fid->clnt; |
1293 | wst->size = p9_client_statsize(wst, clnt->dotu); | 1306 | wst->size = p9_client_statsize(wst, clnt->proto_version); |
1294 | P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid); | 1307 | P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid); |
1295 | P9_DPRINTK(P9_DEBUG_9P, | 1308 | P9_DPRINTK(P9_DEBUG_9P, |
1296 | " sz=%x type=%x dev=%x qid=%x.%llx.%x\n" | 1309 | " sz=%x type=%x dev=%x qid=%x.%llx.%x\n" |
diff --git a/net/9p/protocol.c b/net/9p/protocol.c index fc70147c771e..94f5a8f65e9c 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c | |||
@@ -52,7 +52,7 @@ | |||
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | static int | 54 | static int |
55 | p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...); | 55 | p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...); |
56 | 56 | ||
57 | #ifdef CONFIG_NET_9P_DEBUG | 57 | #ifdef CONFIG_NET_9P_DEBUG |
58 | void | 58 | void |
@@ -144,7 +144,8 @@ pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size) | |||
144 | */ | 144 | */ |
145 | 145 | ||
146 | static int | 146 | static int |
147 | p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | 147 | p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, |
148 | va_list ap) | ||
148 | { | 149 | { |
149 | const char *ptr; | 150 | const char *ptr; |
150 | int errcode = 0; | 151 | int errcode = 0; |
@@ -194,7 +195,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
194 | int16_t len; | 195 | int16_t len; |
195 | int size; | 196 | int size; |
196 | 197 | ||
197 | errcode = p9pdu_readf(pdu, optional, "w", &len); | 198 | errcode = p9pdu_readf(pdu, proto_version, |
199 | "w", &len); | ||
198 | if (errcode) | 200 | if (errcode) |
199 | break; | 201 | break; |
200 | 202 | ||
@@ -217,7 +219,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
217 | struct p9_qid *qid = | 219 | struct p9_qid *qid = |
218 | va_arg(ap, struct p9_qid *); | 220 | va_arg(ap, struct p9_qid *); |
219 | 221 | ||
220 | errcode = p9pdu_readf(pdu, optional, "bdq", | 222 | errcode = p9pdu_readf(pdu, proto_version, "bdq", |
221 | &qid->type, &qid->version, | 223 | &qid->type, &qid->version, |
222 | &qid->path); | 224 | &qid->path); |
223 | } | 225 | } |
@@ -230,7 +232,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
230 | stbuf->n_uid = stbuf->n_gid = stbuf->n_muid = | 232 | stbuf->n_uid = stbuf->n_gid = stbuf->n_muid = |
231 | -1; | 233 | -1; |
232 | errcode = | 234 | errcode = |
233 | p9pdu_readf(pdu, optional, | 235 | p9pdu_readf(pdu, proto_version, |
234 | "wwdQdddqssss?sddd", | 236 | "wwdQdddqssss?sddd", |
235 | &stbuf->size, &stbuf->type, | 237 | &stbuf->size, &stbuf->type, |
236 | &stbuf->dev, &stbuf->qid, | 238 | &stbuf->dev, &stbuf->qid, |
@@ -250,7 +252,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
250 | void **data = va_arg(ap, void **); | 252 | void **data = va_arg(ap, void **); |
251 | 253 | ||
252 | errcode = | 254 | errcode = |
253 | p9pdu_readf(pdu, optional, "d", count); | 255 | p9pdu_readf(pdu, proto_version, "d", count); |
254 | if (!errcode) { | 256 | if (!errcode) { |
255 | *count = | 257 | *count = |
256 | MIN(*count, | 258 | MIN(*count, |
@@ -263,8 +265,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
263 | int16_t *nwname = va_arg(ap, int16_t *); | 265 | int16_t *nwname = va_arg(ap, int16_t *); |
264 | char ***wnames = va_arg(ap, char ***); | 266 | char ***wnames = va_arg(ap, char ***); |
265 | 267 | ||
266 | errcode = | 268 | errcode = p9pdu_readf(pdu, proto_version, |
267 | p9pdu_readf(pdu, optional, "w", nwname); | 269 | "w", nwname); |
268 | if (!errcode) { | 270 | if (!errcode) { |
269 | *wnames = | 271 | *wnames = |
270 | kmalloc(sizeof(char *) * *nwname, | 272 | kmalloc(sizeof(char *) * *nwname, |
@@ -278,7 +280,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
278 | 280 | ||
279 | for (i = 0; i < *nwname; i++) { | 281 | for (i = 0; i < *nwname; i++) { |
280 | errcode = | 282 | errcode = |
281 | p9pdu_readf(pdu, optional, | 283 | p9pdu_readf(pdu, |
284 | proto_version, | ||
282 | "s", | 285 | "s", |
283 | &(*wnames)[i]); | 286 | &(*wnames)[i]); |
284 | if (errcode) | 287 | if (errcode) |
@@ -306,7 +309,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
306 | *wqids = NULL; | 309 | *wqids = NULL; |
307 | 310 | ||
308 | errcode = | 311 | errcode = |
309 | p9pdu_readf(pdu, optional, "w", nwqid); | 312 | p9pdu_readf(pdu, proto_version, "w", nwqid); |
310 | if (!errcode) { | 313 | if (!errcode) { |
311 | *wqids = | 314 | *wqids = |
312 | kmalloc(*nwqid * | 315 | kmalloc(*nwqid * |
@@ -321,7 +324,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
321 | 324 | ||
322 | for (i = 0; i < *nwqid; i++) { | 325 | for (i = 0; i < *nwqid; i++) { |
323 | errcode = | 326 | errcode = |
324 | p9pdu_readf(pdu, optional, | 327 | p9pdu_readf(pdu, |
328 | proto_version, | ||
325 | "Q", | 329 | "Q", |
326 | &(*wqids)[i]); | 330 | &(*wqids)[i]); |
327 | if (errcode) | 331 | if (errcode) |
@@ -336,7 +340,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
336 | } | 340 | } |
337 | break; | 341 | break; |
338 | case '?': | 342 | case '?': |
339 | if (!optional) | 343 | if (proto_version != p9_proto_2000u) |
340 | return 0; | 344 | return 0; |
341 | break; | 345 | break; |
342 | default: | 346 | default: |
@@ -352,7 +356,8 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
352 | } | 356 | } |
353 | 357 | ||
354 | int | 358 | int |
355 | p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | 359 | p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt, |
360 | va_list ap) | ||
356 | { | 361 | { |
357 | const char *ptr; | 362 | const char *ptr; |
358 | int errcode = 0; | 363 | int errcode = 0; |
@@ -389,7 +394,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
389 | if (sptr) | 394 | if (sptr) |
390 | len = MIN(strlen(sptr), USHORT_MAX); | 395 | len = MIN(strlen(sptr), USHORT_MAX); |
391 | 396 | ||
392 | errcode = p9pdu_writef(pdu, optional, "w", len); | 397 | errcode = p9pdu_writef(pdu, proto_version, |
398 | "w", len); | ||
393 | if (!errcode && pdu_write(pdu, sptr, len)) | 399 | if (!errcode && pdu_write(pdu, sptr, len)) |
394 | errcode = -EFAULT; | 400 | errcode = -EFAULT; |
395 | } | 401 | } |
@@ -398,7 +404,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
398 | const struct p9_qid *qid = | 404 | const struct p9_qid *qid = |
399 | va_arg(ap, const struct p9_qid *); | 405 | va_arg(ap, const struct p9_qid *); |
400 | errcode = | 406 | errcode = |
401 | p9pdu_writef(pdu, optional, "bdq", | 407 | p9pdu_writef(pdu, proto_version, "bdq", |
402 | qid->type, qid->version, | 408 | qid->type, qid->version, |
403 | qid->path); | 409 | qid->path); |
404 | } break; | 410 | } break; |
@@ -406,7 +412,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
406 | const struct p9_wstat *stbuf = | 412 | const struct p9_wstat *stbuf = |
407 | va_arg(ap, const struct p9_wstat *); | 413 | va_arg(ap, const struct p9_wstat *); |
408 | errcode = | 414 | errcode = |
409 | p9pdu_writef(pdu, optional, | 415 | p9pdu_writef(pdu, proto_version, |
410 | "wwdQdddqssss?sddd", | 416 | "wwdQdddqssss?sddd", |
411 | stbuf->size, stbuf->type, | 417 | stbuf->size, stbuf->type, |
412 | stbuf->dev, &stbuf->qid, | 418 | stbuf->dev, &stbuf->qid, |
@@ -421,8 +427,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
421 | int32_t count = va_arg(ap, int32_t); | 427 | int32_t count = va_arg(ap, int32_t); |
422 | const void *data = va_arg(ap, const void *); | 428 | const void *data = va_arg(ap, const void *); |
423 | 429 | ||
424 | errcode = | 430 | errcode = p9pdu_writef(pdu, proto_version, "d", |
425 | p9pdu_writef(pdu, optional, "d", count); | 431 | count); |
426 | if (!errcode && pdu_write(pdu, data, count)) | 432 | if (!errcode && pdu_write(pdu, data, count)) |
427 | errcode = -EFAULT; | 433 | errcode = -EFAULT; |
428 | } | 434 | } |
@@ -431,8 +437,8 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
431 | int32_t count = va_arg(ap, int32_t); | 437 | int32_t count = va_arg(ap, int32_t); |
432 | const char __user *udata = | 438 | const char __user *udata = |
433 | va_arg(ap, const void __user *); | 439 | va_arg(ap, const void __user *); |
434 | errcode = | 440 | errcode = p9pdu_writef(pdu, proto_version, "d", |
435 | p9pdu_writef(pdu, optional, "d", count); | 441 | count); |
436 | if (!errcode && pdu_write_u(pdu, udata, count)) | 442 | if (!errcode && pdu_write_u(pdu, udata, count)) |
437 | errcode = -EFAULT; | 443 | errcode = -EFAULT; |
438 | } | 444 | } |
@@ -441,14 +447,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
441 | int16_t nwname = va_arg(ap, int); | 447 | int16_t nwname = va_arg(ap, int); |
442 | const char **wnames = va_arg(ap, const char **); | 448 | const char **wnames = va_arg(ap, const char **); |
443 | 449 | ||
444 | errcode = | 450 | errcode = p9pdu_writef(pdu, proto_version, "w", |
445 | p9pdu_writef(pdu, optional, "w", nwname); | 451 | nwname); |
446 | if (!errcode) { | 452 | if (!errcode) { |
447 | int i; | 453 | int i; |
448 | 454 | ||
449 | for (i = 0; i < nwname; i++) { | 455 | for (i = 0; i < nwname; i++) { |
450 | errcode = | 456 | errcode = |
451 | p9pdu_writef(pdu, optional, | 457 | p9pdu_writef(pdu, |
458 | proto_version, | ||
452 | "s", | 459 | "s", |
453 | wnames[i]); | 460 | wnames[i]); |
454 | if (errcode) | 461 | if (errcode) |
@@ -462,14 +469,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
462 | struct p9_qid *wqids = | 469 | struct p9_qid *wqids = |
463 | va_arg(ap, struct p9_qid *); | 470 | va_arg(ap, struct p9_qid *); |
464 | 471 | ||
465 | errcode = | 472 | errcode = p9pdu_writef(pdu, proto_version, "w", |
466 | p9pdu_writef(pdu, optional, "w", nwqid); | 473 | nwqid); |
467 | if (!errcode) { | 474 | if (!errcode) { |
468 | int i; | 475 | int i; |
469 | 476 | ||
470 | for (i = 0; i < nwqid; i++) { | 477 | for (i = 0; i < nwqid; i++) { |
471 | errcode = | 478 | errcode = |
472 | p9pdu_writef(pdu, optional, | 479 | p9pdu_writef(pdu, |
480 | proto_version, | ||
473 | "Q", | 481 | "Q", |
474 | &wqids[i]); | 482 | &wqids[i]); |
475 | if (errcode) | 483 | if (errcode) |
@@ -479,7 +487,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
479 | } | 487 | } |
480 | break; | 488 | break; |
481 | case '?': | 489 | case '?': |
482 | if (!optional) | 490 | if (proto_version != p9_proto_2000u) |
483 | return 0; | 491 | return 0; |
484 | break; | 492 | break; |
485 | default: | 493 | default: |
@@ -494,32 +502,32 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) | |||
494 | return errcode; | 502 | return errcode; |
495 | } | 503 | } |
496 | 504 | ||
497 | int p9pdu_readf(struct p9_fcall *pdu, int optional, const char *fmt, ...) | 505 | int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...) |
498 | { | 506 | { |
499 | va_list ap; | 507 | va_list ap; |
500 | int ret; | 508 | int ret; |
501 | 509 | ||
502 | va_start(ap, fmt); | 510 | va_start(ap, fmt); |
503 | ret = p9pdu_vreadf(pdu, optional, fmt, ap); | 511 | ret = p9pdu_vreadf(pdu, proto_version, fmt, ap); |
504 | va_end(ap); | 512 | va_end(ap); |
505 | 513 | ||
506 | return ret; | 514 | return ret; |
507 | } | 515 | } |
508 | 516 | ||
509 | static int | 517 | static int |
510 | p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...) | 518 | p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...) |
511 | { | 519 | { |
512 | va_list ap; | 520 | va_list ap; |
513 | int ret; | 521 | int ret; |
514 | 522 | ||
515 | va_start(ap, fmt); | 523 | va_start(ap, fmt); |
516 | ret = p9pdu_vwritef(pdu, optional, fmt, ap); | 524 | ret = p9pdu_vwritef(pdu, proto_version, fmt, ap); |
517 | va_end(ap); | 525 | va_end(ap); |
518 | 526 | ||
519 | return ret; | 527 | return ret; |
520 | } | 528 | } |
521 | 529 | ||
522 | int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu) | 530 | int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version) |
523 | { | 531 | { |
524 | struct p9_fcall fake_pdu; | 532 | struct p9_fcall fake_pdu; |
525 | int ret; | 533 | int ret; |
@@ -529,7 +537,7 @@ int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu) | |||
529 | fake_pdu.sdata = buf; | 537 | fake_pdu.sdata = buf; |
530 | fake_pdu.offset = 0; | 538 | fake_pdu.offset = 0; |
531 | 539 | ||
532 | ret = p9pdu_readf(&fake_pdu, dotu, "S", st); | 540 | ret = p9pdu_readf(&fake_pdu, proto_version, "S", st); |
533 | if (ret) { | 541 | if (ret) { |
534 | P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); | 542 | P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); |
535 | p9pdu_dump(1, &fake_pdu); | 543 | p9pdu_dump(1, &fake_pdu); |
diff --git a/net/9p/protocol.h b/net/9p/protocol.h index ccde462e7ac5..2431c0f38d56 100644 --- a/net/9p/protocol.h +++ b/net/9p/protocol.h | |||
@@ -25,9 +25,9 @@ | |||
25 | * | 25 | * |
26 | */ | 26 | */ |
27 | 27 | ||
28 | int | 28 | int p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt, |
29 | p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap); | 29 | va_list ap); |
30 | int p9pdu_readf(struct p9_fcall *pdu, int optional, const char *fmt, ...); | 30 | int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...); |
31 | int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type); | 31 | int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type); |
32 | int p9pdu_finalize(struct p9_fcall *pdu); | 32 | int p9pdu_finalize(struct p9_fcall *pdu); |
33 | void p9pdu_dump(int, struct p9_fcall *); | 33 | void p9pdu_dump(int, struct p9_fcall *); |