diff options
Diffstat (limited to 'net/9p/protocol.c')
-rw-r--r-- | net/9p/protocol.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/net/9p/protocol.c b/net/9p/protocol.c index 1e308f210928..2ce515b859b3 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c | |||
@@ -114,6 +114,26 @@ pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size) | |||
114 | return size - len; | 114 | return size - len; |
115 | } | 115 | } |
116 | 116 | ||
117 | static size_t | ||
118 | pdu_write_urw(struct p9_fcall *pdu, const char *kdata, const char __user *udata, | ||
119 | size_t size) | ||
120 | { | ||
121 | BUG_ON(pdu->size > P9_IOHDRSZ); | ||
122 | pdu->pubuf = (char __user *)udata; | ||
123 | pdu->pkbuf = (char *)kdata; | ||
124 | pdu->pbuf_size = size; | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static size_t | ||
129 | pdu_write_readdir(struct p9_fcall *pdu, const char *kdata, size_t size) | ||
130 | { | ||
131 | BUG_ON(pdu->size > P9_READDIRHDRSZ); | ||
132 | pdu->pkbuf = (char *)kdata; | ||
133 | pdu->pbuf_size = size; | ||
134 | return 0; | ||
135 | } | ||
136 | |||
117 | /* | 137 | /* |
118 | b - int8_t | 138 | b - int8_t |
119 | w - int16_t | 139 | w - int16_t |
@@ -445,6 +465,25 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt, | |||
445 | errcode = -EFAULT; | 465 | errcode = -EFAULT; |
446 | } | 466 | } |
447 | break; | 467 | break; |
468 | case 'E':{ | ||
469 | int32_t cnt = va_arg(ap, int32_t); | ||
470 | const char *k = va_arg(ap, const void *); | ||
471 | const char *u = va_arg(ap, const void *); | ||
472 | errcode = p9pdu_writef(pdu, proto_version, "d", | ||
473 | cnt); | ||
474 | if (!errcode && pdu_write_urw(pdu, k, u, cnt)) | ||
475 | errcode = -EFAULT; | ||
476 | } | ||
477 | break; | ||
478 | case 'F':{ | ||
479 | int32_t cnt = va_arg(ap, int32_t); | ||
480 | const char *k = va_arg(ap, const void *); | ||
481 | errcode = p9pdu_writef(pdu, proto_version, "d", | ||
482 | cnt); | ||
483 | if (!errcode && pdu_write_readdir(pdu, k, cnt)) | ||
484 | errcode = -EFAULT; | ||
485 | } | ||
486 | break; | ||
448 | case 'U':{ | 487 | case 'U':{ |
449 | int32_t count = va_arg(ap, int32_t); | 488 | int32_t count = va_arg(ap, int32_t); |
450 | const char __user *udata = | 489 | const char __user *udata = |
@@ -579,6 +618,7 @@ EXPORT_SYMBOL(p9stat_read); | |||
579 | 618 | ||
580 | int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type) | 619 | int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type) |
581 | { | 620 | { |
621 | pdu->id = type; | ||
582 | return p9pdu_writef(pdu, 0, "dbw", 0, type, tag); | 622 | return p9pdu_writef(pdu, 0, "dbw", 0, type, tag); |
583 | } | 623 | } |
584 | 624 | ||
@@ -606,6 +646,10 @@ void p9pdu_reset(struct p9_fcall *pdu) | |||
606 | { | 646 | { |
607 | pdu->offset = 0; | 647 | pdu->offset = 0; |
608 | pdu->size = 0; | 648 | pdu->size = 0; |
649 | pdu->private = NULL; | ||
650 | pdu->pubuf = NULL; | ||
651 | pdu->pkbuf = NULL; | ||
652 | pdu->pbuf_size = 0; | ||
609 | } | 653 | } |
610 | 654 | ||
611 | int p9dirent_read(char *buf, int len, struct p9_dirent *dirent, | 655 | int p9dirent_read(char *buf, int len, struct p9_dirent *dirent, |