conv.c 16 KB

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