aboutsummaryrefslogtreecommitdiffstats
path: root/net/9p/protocol.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/protocol.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/protocol.c')
-rw-r--r--net/9p/protocol.c74
1 files changed, 41 insertions, 33 deletions
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
54static int 54static int
55p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...); 55p9pdu_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
58void 58void
@@ -144,7 +144,8 @@ pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size)
144*/ 144*/
145 145
146static int 146static int
147p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) 147p9pdu_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
354int 358int
355p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) 359p9pdu_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
497int p9pdu_readf(struct p9_fcall *pdu, int optional, const char *fmt, ...) 505int 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
509static int 517static int
510p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...) 518p9pdu_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
522int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu) 530int 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);