@@ -562,11 +562,11 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
return req;
/* marshall the data */
- p9pdu_prepare(req->tc, tag, type);
+ p9pdu_prepare(c, req->tc, tag, type);
va_start(ap, fmt);
- err = p9pdu_vwritef(req->tc, c->proto_version, fmt, ap);
+ err = p9pdu_vwritef(req->tc, c, fmt, ap);
va_end(ap);
- p9pdu_finalize(req->tc);
+ p9pdu_finalize(c, req->tc);
err = c->trans_mod->request(c, req);
if (err < 0) {
@@ -53,7 +53,7 @@
#endif
static int
-p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...);
+p9pdu_writef(struct p9_fcall *pdu, struct p9_client *c, const char *fmt, ...);
#ifdef CONFIG_NET_9P_DEBUG
void
@@ -386,11 +386,12 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
}
int
-p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
+p9pdu_vwritef(struct p9_fcall *pdu, struct p9_client *c, const char *fmt,
va_list ap)
{
const char *ptr;
int errcode = 0;
+ int proto_version = c->proto_version;
for (ptr = fmt; *ptr; ptr++) {
switch (*ptr) {
@@ -424,8 +425,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
if (sptr)
len = MIN(strlen(sptr), USHRT_MAX);
- errcode = p9pdu_writef(pdu, proto_version,
- "w", len);
+ errcode = p9pdu_writef(pdu, c, "w", len);
if (!errcode && pdu_write(pdu, sptr, len))
errcode = -EFAULT;
}
@@ -434,7 +434,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
const struct p9_qid *qid =
va_arg(ap, const struct p9_qid *);
errcode =
- p9pdu_writef(pdu, proto_version, "bdq",
+ p9pdu_writef(pdu, c, "bdq",
qid->type, qid->version,
qid->path);
} break;
@@ -442,7 +442,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
const struct p9_wstat *stbuf =
va_arg(ap, const struct p9_wstat *);
errcode =
- p9pdu_writef(pdu, proto_version,
+ p9pdu_writef(pdu, c,
"wwdQdddqssss?sddd",
stbuf->size, stbuf->type,
stbuf->dev, &stbuf->qid,
@@ -457,8 +457,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
int32_t count = va_arg(ap, int32_t);
const void *data = va_arg(ap, const void *);
- errcode = p9pdu_writef(pdu, proto_version, "d",
- count);
+ errcode = p9pdu_writef(pdu, c, "d", count);
if (!errcode && pdu_write(pdu, data, count))
errcode = -EFAULT;
}
@@ -467,8 +466,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
int32_t count = va_arg(ap, int32_t);
const char __user *udata =
va_arg(ap, const void __user *);
- errcode = p9pdu_writef(pdu, proto_version, "d",
- count);
+ errcode = p9pdu_writef(pdu, c, "d", count);
if (!errcode && pdu_write_u(pdu, udata, count))
errcode = -EFAULT;
}
@@ -477,17 +475,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
int16_t nwname = va_arg(ap, int);
const char **wnames = va_arg(ap, const char **);
- errcode = p9pdu_writef(pdu, proto_version, "w",
- nwname);
+ errcode = p9pdu_writef(pdu, c, "w", nwname);
if (!errcode) {
int i;
for (i = 0; i < nwname; i++) {
errcode =
p9pdu_writef(pdu,
- proto_version,
- "s",
- wnames[i]);
+ c, "s",
+ wnames[i]);
if (errcode)
break;
}
@@ -499,17 +495,15 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
struct p9_qid *wqids =
va_arg(ap, struct p9_qid *);
- errcode = p9pdu_writef(pdu, proto_version, "w",
- nwqid);
+ errcode = p9pdu_writef(pdu, c, "w", nwqid);
if (!errcode) {
int i;
for (i = 0; i < nwqid; i++) {
errcode =
p9pdu_writef(pdu,
- proto_version,
- "Q",
- &wqids[i]);
+ c, "Q",
+ &wqids[i]);
if (errcode)
break;
}
@@ -520,7 +514,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
struct p9_iattr_dotl *p9attr = va_arg(ap,
struct p9_iattr_dotl *);
- errcode = p9pdu_writef(pdu, proto_version,
+ errcode = p9pdu_writef(pdu, c,
"ddddqqqqq",
p9attr->valid,
p9attr->mode,
@@ -563,13 +557,13 @@ int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...)
}
static int
-p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...)
+p9pdu_writef(struct p9_fcall *pdu, struct p9_client *c, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
- ret = p9pdu_vwritef(pdu, proto_version, fmt, ap);
+ ret = p9pdu_vwritef(pdu, c, fmt, ap);
va_end(ap);
return ret;
@@ -595,18 +589,19 @@ int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version)
}
EXPORT_SYMBOL(p9stat_read);
-int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type)
+int p9pdu_prepare(struct p9_client *c, struct p9_fcall *pdu, int16_t tag,
+ int8_t type)
{
- return p9pdu_writef(pdu, 0, "dbw", 0, type, tag);
+ return p9pdu_writef(pdu, c, "dbw", 0, type, tag);
}
-int p9pdu_finalize(struct p9_fcall *pdu)
+int p9pdu_finalize(struct p9_client *c, struct p9_fcall *pdu)
{
int size = pdu->size;
int err;
pdu->size = 0;
- err = p9pdu_writef(pdu, 0, "d", size);
+ err = p9pdu_writef(pdu, c, "d", size);
pdu->size = size;
#ifdef CONFIG_NET_9P_DEBUG
@@ -25,10 +25,11 @@
*
*/
-int p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
+int p9pdu_vwritef(struct p9_fcall *pdu, struct p9_client *c, const char *fmt,
va_list ap);
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_finalize(struct p9_fcall *pdu);
+int p9pdu_prepare(struct p9_client *c, struct p9_fcall *pdu, int16_t tag,
+ int8_t type);
+int p9pdu_finalize(struct p9_client *c, struct p9_fcall *pdu);
void p9pdu_dump(int, struct p9_fcall *);
void p9pdu_reset(struct p9_fcall *pdu);