conv.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. /*
  2. * linux/fs/9p/conv.c
  3. *
  4. * 9P protocol conversion functions
  5. *
  6. * Copyright (C) 2004, 2005 by Latchesar Ionkov <lucho@ionkov.net>
  7. * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
  8. * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to:
  22. * Free Software Foundation
  23. * 51 Franklin Street, Fifth Floor
  24. * Boston, MA 02111-1301 USA
  25. *
  26. */
  27. #include <linux/config.h>
  28. #include <linux/module.h>
  29. #include <linux/errno.h>
  30. #include <linux/fs.h>
  31. #include <linux/idr.h>
  32. #include "debug.h"
  33. #include "v9fs.h"
  34. #include "9p.h"
  35. #include "conv.h"
  36. /*
  37. * Buffer to help with string parsing
  38. */
  39. struct cbuf {
  40. unsigned char *sp;
  41. unsigned char *p;
  42. unsigned char *ep;
  43. };
  44. static inline void buf_init(struct cbuf *buf, void *data, int datalen)
  45. {
  46. buf->sp = buf->p = data;
  47. buf->ep = data + datalen;
  48. }
  49. static inline int buf_check_overflow(struct cbuf *buf)
  50. {
  51. return buf->p > buf->ep;
  52. }
  53. static inline int buf_check_size(struct cbuf *buf, int len)
  54. {
  55. if (buf->p+len > buf->ep) {
  56. if (buf->p < buf->ep) {
  57. eprintk(KERN_ERR, "buffer overflow\n");
  58. buf->p = buf->ep + 1;
  59. return 0;
  60. }
  61. }
  62. return 1;
  63. }
  64. static inline void *buf_alloc(struct cbuf *buf, int len)
  65. {
  66. void *ret = NULL;
  67. if (buf_check_size(buf, len)) {
  68. ret = buf->p;
  69. buf->p += len;
  70. }
  71. return ret;
  72. }
  73. static inline void buf_put_int8(struct cbuf *buf, u8 val)
  74. {
  75. if (buf_check_size(buf, 1)) {
  76. buf->p[0] = val;
  77. buf->p++;
  78. }
  79. }
  80. static inline void buf_put_int16(struct cbuf *buf, u16 val)
  81. {
  82. if (buf_check_size(buf, 2)) {
  83. *(__le16 *) buf->p = cpu_to_le16(val);
  84. buf->p += 2;
  85. }
  86. }
  87. static inline void buf_put_int32(struct cbuf *buf, u32 val)
  88. {
  89. if (buf_check_size(buf, 4)) {
  90. *(__le32 *)buf->p = cpu_to_le32(val);
  91. buf->p += 4;
  92. }
  93. }
  94. static inline void buf_put_int64(struct cbuf *buf, u64 val)
  95. {
  96. if (buf_check_size(buf, 8)) {
  97. *(__le64 *)buf->p = cpu_to_le64(val);
  98. buf->p += 8;
  99. }
  100. }
  101. static inline void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
  102. {
  103. if (buf_check_size(buf, slen + 2)) {
  104. buf_put_int16(buf, slen);
  105. memcpy(buf->p, s, slen);
  106. buf->p += slen;
  107. }
  108. }
  109. static inline void buf_put_string(struct cbuf *buf, const char *s)
  110. {
  111. buf_put_stringn(buf, s, strlen(s));
  112. }
  113. static inline void buf_put_data(struct cbuf *buf, void *data, u32 datalen)
  114. {
  115. if (buf_check_size(buf, datalen)) {
  116. memcpy(buf->p, data, datalen);
  117. buf->p += datalen;
  118. }
  119. }
  120. static inline u8 buf_get_int8(struct cbuf *buf)
  121. {
  122. u8 ret = 0;
  123. if (buf_check_size(buf, 1)) {
  124. ret = buf->p[0];
  125. buf->p++;
  126. }
  127. return ret;
  128. }
  129. static inline u16 buf_get_int16(struct cbuf *buf)
  130. {
  131. u16 ret = 0;
  132. if (buf_check_size(buf, 2)) {
  133. ret = le16_to_cpu(*(__le16 *)buf->p);
  134. buf->p += 2;
  135. }
  136. return ret;
  137. }
  138. static inline u32 buf_get_int32(struct cbuf *buf)
  139. {
  140. u32 ret = 0;
  141. if (buf_check_size(buf, 4)) {
  142. ret = le32_to_cpu(*(__le32 *)buf->p);
  143. buf->p += 4;
  144. }
  145. return ret;
  146. }
  147. static inline u64 buf_get_int64(struct cbuf *buf)
  148. {
  149. u64 ret = 0;
  150. if (buf_check_size(buf, 8)) {
  151. ret = le64_to_cpu(*(__le64 *)buf->p);
  152. buf->p += 8;
  153. }
  154. return ret;
  155. }
  156. static inline int
  157. buf_get_string(struct cbuf *buf, char *data, unsigned int datalen)
  158. {
  159. u16 len = 0;
  160. len = buf_get_int16(buf);
  161. if (!buf_check_overflow(buf) && buf_check_size(buf, len) && len+1>datalen) {
  162. memcpy(data, buf->p, len);
  163. data[len] = 0;
  164. buf->p += len;
  165. len++;
  166. }
  167. return len;
  168. }
  169. static inline char *buf_get_stringb(struct cbuf *buf, struct cbuf *sbuf)
  170. {
  171. char *ret;
  172. u16 len;
  173. ret = NULL;
  174. len = buf_get_int16(buf);
  175. if (!buf_check_overflow(buf) && buf_check_size(buf, len) &&
  176. buf_check_size(sbuf, len+1)) {
  177. memcpy(sbuf->p, buf->p, len);
  178. sbuf->p[len] = 0;
  179. ret = sbuf->p;
  180. buf->p += len;
  181. sbuf->p += len + 1;
  182. }
  183. return ret;
  184. }
  185. static inline int buf_get_data(struct cbuf *buf, void *data, int datalen)
  186. {
  187. int ret = 0;
  188. if (buf_check_size(buf, datalen)) {
  189. memcpy(data, buf->p, datalen);
  190. buf->p += datalen;
  191. ret = datalen;
  192. }
  193. return ret;
  194. }
  195. static inline void *buf_get_datab(struct cbuf *buf, struct cbuf *dbuf,
  196. int datalen)
  197. {
  198. char *ret = NULL;
  199. int n = 0;
  200. if (buf_check_size(dbuf, datalen)) {
  201. n = buf_get_data(buf, dbuf->p, datalen);
  202. if (n > 0) {
  203. ret = dbuf->p;
  204. dbuf->p += n;
  205. }
  206. }
  207. return ret;
  208. }
  209. /**
  210. * v9fs_size_stat - calculate the size of a variable length stat struct
  211. * @v9ses: session information
  212. * @stat: metadata (stat) structure
  213. *
  214. */
  215. static int v9fs_size_stat(struct v9fs_session_info *v9ses,
  216. struct v9fs_stat *stat)
  217. {
  218. int size = 0;
  219. if (stat == NULL) {
  220. eprintk(KERN_ERR, "v9fs_size_stat: got a NULL stat pointer\n");
  221. return 0;
  222. }
  223. size = /* 2 + *//* size[2] */
  224. 2 + /* type[2] */
  225. 4 + /* dev[4] */
  226. 1 + /* qid.type[1] */
  227. 4 + /* qid.vers[4] */
  228. 8 + /* qid.path[8] */
  229. 4 + /* mode[4] */
  230. 4 + /* atime[4] */
  231. 4 + /* mtime[4] */
  232. 8 + /* length[8] */
  233. 8; /* minimum sum of string lengths */
  234. if (stat->name)
  235. size += strlen(stat->name);
  236. if (stat->uid)
  237. size += strlen(stat->uid);
  238. if (stat->gid)
  239. size += strlen(stat->gid);
  240. if (stat->muid)
  241. size += strlen(stat->muid);
  242. if (v9ses->extended) {
  243. size += 4 + /* n_uid[4] */
  244. 4 + /* n_gid[4] */
  245. 4 + /* n_muid[4] */
  246. 2; /* string length of extension[4] */
  247. if (stat->extension)
  248. size += strlen(stat->extension);
  249. }
  250. return size;
  251. }
  252. /**
  253. * serialize_stat - safely format a stat structure for transmission
  254. * @v9ses: session info
  255. * @stat: metadata (stat) structure
  256. * @bufp: buffer to serialize structure into
  257. *
  258. */
  259. static int
  260. serialize_stat(struct v9fs_session_info *v9ses, struct v9fs_stat *stat,
  261. struct cbuf *bufp)
  262. {
  263. buf_put_int16(bufp, stat->size);
  264. buf_put_int16(bufp, stat->type);
  265. buf_put_int32(bufp, stat->dev);
  266. buf_put_int8(bufp, stat->qid.type);
  267. buf_put_int32(bufp, stat->qid.version);
  268. buf_put_int64(bufp, stat->qid.path);
  269. buf_put_int32(bufp, stat->mode);
  270. buf_put_int32(bufp, stat->atime);
  271. buf_put_int32(bufp, stat->mtime);
  272. buf_put_int64(bufp, stat->length);
  273. buf_put_string(bufp, stat->name);
  274. buf_put_string(bufp, stat->uid);
  275. buf_put_string(bufp, stat->gid);
  276. buf_put_string(bufp, stat->muid);
  277. if (v9ses->extended) {
  278. buf_put_string(bufp, stat->extension);
  279. buf_put_int32(bufp, stat->n_uid);
  280. buf_put_int32(bufp, stat->n_gid);
  281. buf_put_int32(bufp, stat->n_muid);
  282. }
  283. if (buf_check_overflow(bufp))
  284. return 0;
  285. return stat->size;
  286. }
  287. /**
  288. * deserialize_stat - safely decode a recieved metadata (stat) structure
  289. * @v9ses: session info
  290. * @bufp: buffer to deserialize
  291. * @stat: metadata (stat) structure
  292. * @dbufp: buffer to deserialize variable strings into
  293. *
  294. */
  295. static inline int
  296. deserialize_stat(struct v9fs_session_info *v9ses, struct cbuf *bufp,
  297. struct v9fs_stat *stat, struct cbuf *dbufp)
  298. {
  299. stat->size = buf_get_int16(bufp);
  300. stat->type = buf_get_int16(bufp);
  301. stat->dev = buf_get_int32(bufp);
  302. stat->qid.type = buf_get_int8(bufp);
  303. stat->qid.version = buf_get_int32(bufp);
  304. stat->qid.path = buf_get_int64(bufp);
  305. stat->mode = buf_get_int32(bufp);
  306. stat->atime = buf_get_int32(bufp);
  307. stat->mtime = buf_get_int32(bufp);
  308. stat->length = buf_get_int64(bufp);
  309. stat->name = buf_get_stringb(bufp, dbufp);
  310. stat->uid = buf_get_stringb(bufp, dbufp);
  311. stat->gid = buf_get_stringb(bufp, dbufp);
  312. stat->muid = buf_get_stringb(bufp, dbufp);
  313. if (v9ses->extended) {
  314. stat->extension = buf_get_stringb(bufp, dbufp);
  315. stat->n_uid = buf_get_int32(bufp);
  316. stat->n_gid = buf_get_int32(bufp);
  317. stat->n_muid = buf_get_int32(bufp);
  318. }
  319. if (buf_check_overflow(bufp) || buf_check_overflow(dbufp))
  320. return 0;
  321. return stat->size + 2;
  322. }
  323. /**
  324. * deserialize_statb - wrapper for decoding a received metadata structure
  325. * @v9ses: session info
  326. * @bufp: buffer to deserialize
  327. * @dbufp: buffer to deserialize variable strings into
  328. *
  329. */
  330. static inline struct v9fs_stat *deserialize_statb(struct v9fs_session_info
  331. *v9ses, struct cbuf *bufp,
  332. struct cbuf *dbufp)
  333. {
  334. struct v9fs_stat *ret = buf_alloc(dbufp, sizeof(struct v9fs_stat));
  335. if (ret) {
  336. int n = deserialize_stat(v9ses, bufp, ret, dbufp);
  337. if (n <= 0)
  338. return NULL;
  339. }
  340. return ret;
  341. }
  342. /**
  343. * v9fs_deserialize_stat - decode a received metadata structure
  344. * @v9ses: session info
  345. * @buf: buffer to deserialize
  346. * @buflen: length of received buffer
  347. * @stat: metadata structure to decode into
  348. * @statlen: length of destination metadata structure
  349. *
  350. */
  351. int
  352. v9fs_deserialize_stat(struct v9fs_session_info *v9ses, void *buf,
  353. u32 buflen, struct v9fs_stat *stat, u32 statlen)
  354. {
  355. struct cbuf buffer;
  356. struct cbuf *bufp = &buffer;
  357. struct cbuf dbuffer;
  358. struct cbuf *dbufp = &dbuffer;
  359. buf_init(bufp, buf, buflen);
  360. buf_init(dbufp, (char *)stat + sizeof(struct v9fs_stat),
  361. statlen - sizeof(struct v9fs_stat));
  362. return deserialize_stat(v9ses, bufp, stat, dbufp);
  363. }
  364. static inline int
  365. v9fs_size_fcall(struct v9fs_session_info *v9ses, struct v9fs_fcall *fcall)
  366. {
  367. int size = 4 + 1 + 2; /* size[4] msg[1] tag[2] */
  368. int i = 0;
  369. switch (fcall->id) {
  370. default:
  371. eprintk(KERN_ERR, "bad msg type %d\n", fcall->id);
  372. return 0;
  373. case TVERSION: /* msize[4] version[s] */
  374. size += 4 + 2 + strlen(fcall->params.tversion.version);
  375. break;
  376. case TAUTH: /* afid[4] uname[s] aname[s] */
  377. size += 4 + 2 + strlen(fcall->params.tauth.uname) +
  378. 2 + strlen(fcall->params.tauth.aname);
  379. break;
  380. case TFLUSH: /* oldtag[2] */
  381. size += 2;
  382. break;
  383. case TATTACH: /* fid[4] afid[4] uname[s] aname[s] */
  384. size += 4 + 4 + 2 + strlen(fcall->params.tattach.uname) +
  385. 2 + strlen(fcall->params.tattach.aname);
  386. break;
  387. case TWALK: /* fid[4] newfid[4] nwname[2] nwname*(wname[s]) */
  388. size += 4 + 4 + 2;
  389. /* now compute total for the array of names */
  390. for (i = 0; i < fcall->params.twalk.nwname; i++)
  391. size += 2 + strlen(fcall->params.twalk.wnames[i]);
  392. break;
  393. case TOPEN: /* fid[4] mode[1] */
  394. size += 4 + 1;
  395. break;
  396. case TCREATE: /* fid[4] name[s] perm[4] mode[1] */
  397. size += 4 + 2 + strlen(fcall->params.tcreate.name) + 4 + 1;
  398. break;
  399. case TREAD: /* fid[4] offset[8] count[4] */
  400. size += 4 + 8 + 4;
  401. break;
  402. case TWRITE: /* fid[4] offset[8] count[4] data[count] */
  403. size += 4 + 8 + 4 + fcall->params.twrite.count;
  404. break;
  405. case TCLUNK: /* fid[4] */
  406. size += 4;
  407. break;
  408. case TREMOVE: /* fid[4] */
  409. size += 4;
  410. break;
  411. case TSTAT: /* fid[4] */
  412. size += 4;
  413. break;
  414. case TWSTAT: /* fid[4] stat[n] */
  415. fcall->params.twstat.stat->size =
  416. v9fs_size_stat(v9ses, fcall->params.twstat.stat);
  417. size += 4 + 2 + 2 + fcall->params.twstat.stat->size;
  418. }
  419. return size;
  420. }
  421. /*
  422. * v9fs_serialize_fcall - marshall fcall struct into a packet
  423. * @v9ses: session information
  424. * @fcall: structure to convert
  425. * @data: buffer to serialize fcall into
  426. * @datalen: length of buffer to serialize fcall into
  427. *
  428. */
  429. int
  430. v9fs_serialize_fcall(struct v9fs_session_info *v9ses, struct v9fs_fcall *fcall,
  431. void *data, u32 datalen)
  432. {
  433. int i = 0;
  434. struct v9fs_stat *stat = NULL;
  435. struct cbuf buffer;
  436. struct cbuf *bufp = &buffer;
  437. buf_init(bufp, data, datalen);
  438. if (!fcall) {
  439. eprintk(KERN_ERR, "no fcall\n");
  440. return -EINVAL;
  441. }
  442. fcall->size = v9fs_size_fcall(v9ses, fcall);
  443. buf_put_int32(bufp, fcall->size);
  444. buf_put_int8(bufp, fcall->id);
  445. buf_put_int16(bufp, fcall->tag);
  446. dprintk(DEBUG_CONV, "size %d id %d tag %d\n", fcall->size, fcall->id,
  447. fcall->tag);
  448. /* now encode it */
  449. switch (fcall->id) {
  450. default:
  451. eprintk(KERN_ERR, "bad msg type: %d\n", fcall->id);
  452. return -EPROTO;
  453. case TVERSION:
  454. buf_put_int32(bufp, fcall->params.tversion.msize);
  455. buf_put_string(bufp, fcall->params.tversion.version);
  456. break;
  457. case TAUTH:
  458. buf_put_int32(bufp, fcall->params.tauth.afid);
  459. buf_put_string(bufp, fcall->params.tauth.uname);
  460. buf_put_string(bufp, fcall->params.tauth.aname);
  461. break;
  462. case TFLUSH:
  463. buf_put_int16(bufp, fcall->params.tflush.oldtag);
  464. break;
  465. case TATTACH:
  466. buf_put_int32(bufp, fcall->params.tattach.fid);
  467. buf_put_int32(bufp, fcall->params.tattach.afid);
  468. buf_put_string(bufp, fcall->params.tattach.uname);
  469. buf_put_string(bufp, fcall->params.tattach.aname);
  470. break;
  471. case TWALK:
  472. buf_put_int32(bufp, fcall->params.twalk.fid);
  473. buf_put_int32(bufp, fcall->params.twalk.newfid);
  474. buf_put_int16(bufp, fcall->params.twalk.nwname);
  475. for (i = 0; i < fcall->params.twalk.nwname; i++)
  476. buf_put_string(bufp, fcall->params.twalk.wnames[i]);
  477. break;
  478. case TOPEN:
  479. buf_put_int32(bufp, fcall->params.topen.fid);
  480. buf_put_int8(bufp, fcall->params.topen.mode);
  481. break;
  482. case TCREATE:
  483. buf_put_int32(bufp, fcall->params.tcreate.fid);
  484. buf_put_string(bufp, fcall->params.tcreate.name);
  485. buf_put_int32(bufp, fcall->params.tcreate.perm);
  486. buf_put_int8(bufp, fcall->params.tcreate.mode);
  487. break;
  488. case TREAD:
  489. buf_put_int32(bufp, fcall->params.tread.fid);
  490. buf_put_int64(bufp, fcall->params.tread.offset);
  491. buf_put_int32(bufp, fcall->params.tread.count);
  492. break;
  493. case TWRITE:
  494. buf_put_int32(bufp, fcall->params.twrite.fid);
  495. buf_put_int64(bufp, fcall->params.twrite.offset);
  496. buf_put_int32(bufp, fcall->params.twrite.count);
  497. buf_put_data(bufp, fcall->params.twrite.data,
  498. fcall->params.twrite.count);
  499. break;
  500. case TCLUNK:
  501. buf_put_int32(bufp, fcall->params.tclunk.fid);
  502. break;
  503. case TREMOVE:
  504. buf_put_int32(bufp, fcall->params.tremove.fid);
  505. break;
  506. case TSTAT:
  507. buf_put_int32(bufp, fcall->params.tstat.fid);
  508. break;
  509. case TWSTAT:
  510. buf_put_int32(bufp, fcall->params.twstat.fid);
  511. stat = fcall->params.twstat.stat;
  512. buf_put_int16(bufp, stat->size + 2);
  513. serialize_stat(v9ses, stat, bufp);
  514. break;
  515. }
  516. if (buf_check_overflow(bufp))
  517. return -EIO;
  518. return fcall->size;
  519. }
  520. /**
  521. * deserialize_fcall - unmarshal a response
  522. * @v9ses: session information
  523. * @msgsize: size of rcall message
  524. * @buf: recieved buffer
  525. * @buflen: length of received buffer
  526. * @rcall: fcall structure to populate
  527. * @rcalllen: length of fcall structure to populate
  528. *
  529. */
  530. int
  531. v9fs_deserialize_fcall(struct v9fs_session_info *v9ses, u32 msgsize,
  532. void *buf, u32 buflen, struct v9fs_fcall *rcall,
  533. int rcalllen)
  534. {
  535. struct cbuf buffer;
  536. struct cbuf *bufp = &buffer;
  537. struct cbuf dbuffer;
  538. struct cbuf *dbufp = &dbuffer;
  539. int i = 0;
  540. buf_init(bufp, buf, buflen);
  541. buf_init(dbufp, (char *)rcall + sizeof(struct v9fs_fcall),
  542. rcalllen - sizeof(struct v9fs_fcall));
  543. rcall->size = msgsize;
  544. rcall->id = buf_get_int8(bufp);
  545. rcall->tag = buf_get_int16(bufp);
  546. dprintk(DEBUG_CONV, "size %d id %d tag %d\n", rcall->size, rcall->id,
  547. rcall->tag);
  548. switch (rcall->id) {
  549. default:
  550. eprintk(KERN_ERR, "unknown message type: %d\n", rcall->id);
  551. return -EPROTO;
  552. case RVERSION:
  553. rcall->params.rversion.msize = buf_get_int32(bufp);
  554. rcall->params.rversion.version = buf_get_stringb(bufp, dbufp);
  555. break;
  556. case RFLUSH:
  557. break;
  558. case RATTACH:
  559. rcall->params.rattach.qid.type = buf_get_int8(bufp);
  560. rcall->params.rattach.qid.version = buf_get_int32(bufp);
  561. rcall->params.rattach.qid.path = buf_get_int64(bufp);
  562. break;
  563. case RWALK:
  564. rcall->params.rwalk.nwqid = buf_get_int16(bufp);
  565. rcall->params.rwalk.wqids = buf_alloc(dbufp,
  566. rcall->params.rwalk.nwqid * sizeof(struct v9fs_qid));
  567. if (rcall->params.rwalk.wqids)
  568. for (i = 0; i < rcall->params.rwalk.nwqid; i++) {
  569. rcall->params.rwalk.wqids[i].type =
  570. buf_get_int8(bufp);
  571. rcall->params.rwalk.wqids[i].version =
  572. buf_get_int16(bufp);
  573. rcall->params.rwalk.wqids[i].path =
  574. buf_get_int64(bufp);
  575. }
  576. break;
  577. case ROPEN:
  578. rcall->params.ropen.qid.type = buf_get_int8(bufp);
  579. rcall->params.ropen.qid.version = buf_get_int32(bufp);
  580. rcall->params.ropen.qid.path = buf_get_int64(bufp);
  581. rcall->params.ropen.iounit = buf_get_int32(bufp);
  582. break;
  583. case RCREATE:
  584. rcall->params.rcreate.qid.type = buf_get_int8(bufp);
  585. rcall->params.rcreate.qid.version = buf_get_int32(bufp);
  586. rcall->params.rcreate.qid.path = buf_get_int64(bufp);
  587. rcall->params.rcreate.iounit = buf_get_int32(bufp);
  588. break;
  589. case RREAD:
  590. rcall->params.rread.count = buf_get_int32(bufp);
  591. rcall->params.rread.data = buf_get_datab(bufp, dbufp,
  592. rcall->params.rread.count);
  593. break;
  594. case RWRITE:
  595. rcall->params.rwrite.count = buf_get_int32(bufp);
  596. break;
  597. case RCLUNK:
  598. break;
  599. case RREMOVE:
  600. break;
  601. case RSTAT:
  602. buf_get_int16(bufp);
  603. rcall->params.rstat.stat =
  604. deserialize_statb(v9ses, bufp, dbufp);
  605. break;
  606. case RWSTAT:
  607. break;
  608. case RERROR:
  609. rcall->params.rerror.error = buf_get_stringb(bufp, dbufp);
  610. if (v9ses->extended)
  611. rcall->params.rerror.errno = buf_get_int16(bufp);
  612. break;
  613. }
  614. if (buf_check_overflow(bufp) || buf_check_overflow(dbufp))
  615. return -EIO;
  616. return rcall->size;
  617. }