aboutsummaryrefslogtreecommitdiffstats
path: root/net/9p/client.c
diff options
context:
space:
mode:
authorSripathi Kodi <sripathik@in.ibm.com>2010-03-05 13:50:14 -0500
committerEric Van Hensbergen <ericvh@gmail.com>2010-03-05 16:04:42 -0500
commit342fee1d5c7dfa05f4e14ec1e583df4553b09776 (patch)
tree87931dea926f16b44374db8a849ef131cd6ff3de /net/9p/client.c
parent0fb80abd911a7cb1e6548b5279568dc1e8949702 (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/9p/client.c')
-rw-r--r--net/9p/client.c65
1 files changed, 39 insertions, 26 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
61inline int p9_is_proto_dotl(struct p9_client *clnt)
62{
63 return (clnt->proto_version == p9_proto_2010L);
64}
65EXPORT_SYMBOL(p9_is_proto_dotl);
66
67inline int p9_is_proto_dotu(struct p9_client *clnt)
68{
69 return (clnt->proto_version == p9_proto_2000u);
70}
71EXPORT_SYMBOL(p9_is_proto_dotu);
72
61/* Interpret mount option for protocol version */ 73/* Interpret mount option for protocol version */
62static unsigned char get_protocol_version(const substring_t *name) 74static 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}
1255EXPORT_SYMBOL(p9_client_stat); 1268EXPORT_SYMBOL(p9_client_stat);
1256 1269
1257static int p9_client_statsize(struct p9_wstat *wst, int optional) 1270static 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"