conv.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  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. * @stat: metadata (stat) structure
  212. * @extended: non-zero if 9P2000.u
  213. *
  214. */
  215. static int v9fs_size_stat(struct v9fs_stat *stat, int extended)
  216. {
  217. int size = 0;
  218. if (stat == NULL) {
  219. eprintk(KERN_ERR, "v9fs_size_stat: got a NULL stat pointer\n");
  220. return 0;
  221. }
  222. size = /* 2 + *//* size[2] */
  223. 2 + /* type[2] */
  224. 4 + /* dev[4] */
  225. 1 + /* qid.type[1] */
  226. 4 + /* qid.vers[4] */
  227. 8 + /* qid.path[8] */
  228. 4 + /* mode[4] */
  229. 4 + /* atime[4] */
  230. 4 + /* mtime[4] */
  231. 8 + /* length[8] */
  232. 8; /* minimum sum of string lengths */
  233. if (stat->name)
  234. size += strlen(stat->name);
  235. if (stat->uid)
  236. size += strlen(stat->uid);
  237. if (stat->gid)
  238. size += strlen(stat->gid);
  239. if (stat->muid)
  240. size += strlen(stat->muid);
  241. if (extended) {
  242. size += 4 + /* n_uid[4] */
  243. 4 + /* n_gid[4] */
  244. 4 + /* n_muid[4] */
  245. 2; /* string length of extension[4] */
  246. if (stat->extension)
  247. size += strlen(stat->extension);
  248. }
  249. return size;
  250. }
  251. /**
  252. * serialize_stat - safely format a stat structure for transmission
  253. * @stat: metadata (stat) structure
  254. * @bufp: buffer to serialize structure into
  255. * @extended: non-zero if 9P2000.u
  256. *
  257. */
  258. static int
  259. serialize_stat(struct v9fs_stat *stat, struct cbuf *bufp, int extended)
  260. {
  261. buf_put_int16(bufp, stat->size);
  262. buf_put_int16(bufp, stat->type);
  263. buf_put_int32(bufp, stat->dev);
  264. buf_put_int8(bufp, stat->qid.type);
  265. buf_put_int32(bufp, stat->qid.version);
  266. buf_put_int64(bufp, stat->qid.path);
  267. buf_put_int32(bufp, stat->mode);
  268. buf_put_int32(bufp, stat->atime);
  269. buf_put_int32(bufp, stat->mtime);
  270. buf_put_int64(bufp, stat->length);
  271. buf_put_string(bufp, stat->name);
  272. buf_put_string(bufp, stat->uid);
  273. buf_put_string(bufp, stat->gid);
  274. buf_put_string(bufp, stat->muid);
  275. if (extended) {
  276. buf_put_string(bufp, stat->extension);
  277. buf_put_int32(bufp, stat->n_uid);
  278. buf_put_int32(bufp, stat->n_gid);
  279. buf_put_int32(bufp, stat->n_muid);
  280. }
  281. if (buf_check_overflow(bufp))
  282. return 0;
  283. return stat->size;
  284. }
  285. /**
  286. * deserialize_stat - safely decode a recieved metadata (stat) structure
  287. * @bufp: buffer to deserialize
  288. * @stat: metadata (stat) structure
  289. * @dbufp: buffer to deserialize variable strings into
  290. * @extended: non-zero if 9P2000.u
  291. *
  292. */
  293. static inline int
  294. deserialize_stat(struct cbuf *bufp, struct v9fs_stat *stat,
  295. struct cbuf *dbufp, int extended)
  296. {
  297. stat->size = buf_get_int16(bufp);
  298. stat->type = buf_get_int16(bufp);
  299. stat->dev = buf_get_int32(bufp);
  300. stat->qid.type = buf_get_int8(bufp);
  301. stat->qid.version = buf_get_int32(bufp);
  302. stat->qid.path = buf_get_int64(bufp);
  303. stat->mode = buf_get_int32(bufp);
  304. stat->atime = buf_get_int32(bufp);
  305. stat->mtime = buf_get_int32(bufp);
  306. stat->length = buf_get_int64(bufp);
  307. stat->name = buf_get_stringb(bufp, dbufp);
  308. stat->uid = buf_get_stringb(bufp, dbufp);
  309. stat->gid = buf_get_stringb(bufp, dbufp);
  310. stat->muid = buf_get_stringb(bufp, dbufp);
  311. if (extended) {
  312. stat->extension = buf_get_stringb(bufp, dbufp);
  313. stat->n_uid = buf_get_int32(bufp);
  314. stat->n_gid = buf_get_int32(bufp);
  315. stat->n_muid = buf_get_int32(bufp);
  316. }
  317. if (buf_check_overflow(bufp) || buf_check_overflow(dbufp))
  318. return 0;
  319. return stat->size + 2;
  320. }
  321. /**
  322. * deserialize_statb - wrapper for decoding a received metadata structure
  323. * @bufp: buffer to deserialize
  324. * @dbufp: buffer to deserialize variable strings into
  325. * @extended: non-zero if 9P2000.u
  326. *
  327. */
  328. static inline struct v9fs_stat *deserialize_statb(struct cbuf *bufp,
  329. struct cbuf *dbufp,
  330. int extended)
  331. {
  332. struct v9fs_stat *ret = buf_alloc(dbufp, sizeof(struct v9fs_stat));
  333. if (ret) {
  334. int n = deserialize_stat(bufp, ret, dbufp, extended);
  335. if (n <= 0)
  336. return NULL;
  337. }
  338. return ret;
  339. }
  340. /**
  341. * v9fs_deserialize_stat - decode a received metadata structure
  342. * @buf: buffer to deserialize
  343. * @buflen: length of received buffer
  344. * @stat: metadata structure to decode into
  345. * @statlen: length of destination metadata structure
  346. * @extended: non-zero if 9P2000.u
  347. *
  348. */
  349. int v9fs_deserialize_stat(void *buf, u32 buflen, struct v9fs_stat *stat,
  350. u32 statlen, int extended)
  351. {
  352. struct cbuf buffer;
  353. struct cbuf *bufp = &buffer;
  354. struct cbuf dbuffer;
  355. struct cbuf *dbufp = &dbuffer;
  356. buf_init(bufp, buf, buflen);
  357. buf_init(dbufp, (char *)stat + sizeof(struct v9fs_stat),
  358. statlen - sizeof(struct v9fs_stat));
  359. return deserialize_stat(bufp, stat, dbufp, extended);
  360. }
  361. static inline int v9fs_size_fcall(struct v9fs_fcall *fcall, int extended)
  362. {
  363. int size = 4 + 1 + 2; /* size[4] msg[1] tag[2] */
  364. int i = 0;
  365. switch (fcall->id) {
  366. default:
  367. eprintk(KERN_ERR, "bad msg type %d\n", fcall->id);
  368. return 0;
  369. case TVERSION: /* msize[4] version[s] */
  370. size += 4 + 2 + strlen(fcall->params.tversion.version);
  371. break;
  372. case TAUTH: /* afid[4] uname[s] aname[s] */
  373. size += 4 + 2 + strlen(fcall->params.tauth.uname) +
  374. 2 + strlen(fcall->params.tauth.aname);
  375. break;
  376. case TFLUSH: /* oldtag[2] */
  377. size += 2;
  378. break;
  379. case TATTACH: /* fid[4] afid[4] uname[s] aname[s] */
  380. size += 4 + 4 + 2 + strlen(fcall->params.tattach.uname) +
  381. 2 + strlen(fcall->params.tattach.aname);
  382. break;
  383. case TWALK: /* fid[4] newfid[4] nwname[2] nwname*(wname[s]) */
  384. size += 4 + 4 + 2;
  385. /* now compute total for the array of names */
  386. for (i = 0; i < fcall->params.twalk.nwname; i++)
  387. size += 2 + strlen(fcall->params.twalk.wnames[i]);
  388. break;
  389. case TOPEN: /* fid[4] mode[1] */
  390. size += 4 + 1;
  391. break;
  392. case TCREATE: /* fid[4] name[s] perm[4] mode[1] */
  393. size += 4 + 2 + strlen(fcall->params.tcreate.name) + 4 + 1;
  394. break;
  395. case TREAD: /* fid[4] offset[8] count[4] */
  396. size += 4 + 8 + 4;
  397. break;
  398. case TWRITE: /* fid[4] offset[8] count[4] data[count] */
  399. size += 4 + 8 + 4 + fcall->params.twrite.count;
  400. break;
  401. case TCLUNK: /* fid[4] */
  402. size += 4;
  403. break;
  404. case TREMOVE: /* fid[4] */
  405. size += 4;
  406. break;
  407. case TSTAT: /* fid[4] */
  408. size += 4;
  409. break;
  410. case TWSTAT: /* fid[4] stat[n] */
  411. fcall->params.twstat.stat->size =
  412. v9fs_size_stat(fcall->params.twstat.stat, extended);
  413. size += 4 + 2 + 2 + fcall->params.twstat.stat->size;
  414. }
  415. return size;
  416. }
  417. /*
  418. * v9fs_serialize_fcall - marshall fcall struct into a packet
  419. * @fcall: structure to convert
  420. * @data: buffer to serialize fcall into
  421. * @datalen: length of buffer to serialize fcall into
  422. * @extended: non-zero if 9P2000.u
  423. *
  424. */
  425. int
  426. v9fs_serialize_fcall(struct v9fs_fcall *fcall, void *data, u32 datalen,
  427. int extended)
  428. {
  429. int i = 0;
  430. struct v9fs_stat *stat = NULL;
  431. struct cbuf buffer;
  432. struct cbuf *bufp = &buffer;
  433. buf_init(bufp, data, datalen);
  434. if (!fcall) {
  435. eprintk(KERN_ERR, "no fcall\n");
  436. return -EINVAL;
  437. }
  438. fcall->size = v9fs_size_fcall(fcall, extended);
  439. buf_put_int32(bufp, fcall->size);
  440. buf_put_int8(bufp, fcall->id);
  441. buf_put_int16(bufp, fcall->tag);
  442. dprintk(DEBUG_CONV, "size %d id %d tag %d\n", fcall->size, fcall->id,
  443. fcall->tag);
  444. /* now encode it */
  445. switch (fcall->id) {
  446. default:
  447. eprintk(KERN_ERR, "bad msg type: %d\n", fcall->id);
  448. return -EPROTO;
  449. case TVERSION:
  450. buf_put_int32(bufp, fcall->params.tversion.msize);
  451. buf_put_string(bufp, fcall->params.tversion.version);
  452. break;
  453. case TAUTH:
  454. buf_put_int32(bufp, fcall->params.tauth.afid);
  455. buf_put_string(bufp, fcall->params.tauth.uname);
  456. buf_put_string(bufp, fcall->params.tauth.aname);
  457. break;
  458. case TFLUSH:
  459. buf_put_int16(bufp, fcall->params.tflush.oldtag);
  460. break;
  461. case TATTACH:
  462. buf_put_int32(bufp, fcall->params.tattach.fid);
  463. buf_put_int32(bufp, fcall->params.tattach.afid);
  464. buf_put_string(bufp, fcall->params.tattach.uname);
  465. buf_put_string(bufp, fcall->params.tattach.aname);
  466. break;
  467. case TWALK:
  468. buf_put_int32(bufp, fcall->params.twalk.fid);
  469. buf_put_int32(bufp, fcall->params.twalk.newfid);
  470. buf_put_int16(bufp, fcall->params.twalk.nwname);
  471. for (i = 0; i < fcall->params.twalk.nwname; i++)
  472. buf_put_string(bufp, fcall->params.twalk.wnames[i]);
  473. break;
  474. case TOPEN:
  475. buf_put_int32(bufp, fcall->params.topen.fid);
  476. buf_put_int8(bufp, fcall->params.topen.mode);
  477. break;
  478. case TCREATE:
  479. buf_put_int32(bufp, fcall->params.tcreate.fid);
  480. buf_put_string(bufp, fcall->params.tcreate.name);
  481. buf_put_int32(bufp, fcall->params.tcreate.perm);
  482. buf_put_int8(bufp, fcall->params.tcreate.mode);
  483. break;
  484. case TREAD:
  485. buf_put_int32(bufp, fcall->params.tread.fid);
  486. buf_put_int64(bufp, fcall->params.tread.offset);
  487. buf_put_int32(bufp, fcall->params.tread.count);
  488. break;
  489. case TWRITE:
  490. buf_put_int32(bufp, fcall->params.twrite.fid);
  491. buf_put_int64(bufp, fcall->params.twrite.offset);
  492. buf_put_int32(bufp, fcall->params.twrite.count);
  493. buf_put_data(bufp, fcall->params.twrite.data,
  494. fcall->params.twrite.count);
  495. break;
  496. case TCLUNK:
  497. buf_put_int32(bufp, fcall->params.tclunk.fid);
  498. break;
  499. case TREMOVE:
  500. buf_put_int32(bufp, fcall->params.tremove.fid);
  501. break;
  502. case TSTAT:
  503. buf_put_int32(bufp, fcall->params.tstat.fid);
  504. break;
  505. case TWSTAT:
  506. buf_put_int32(bufp, fcall->params.twstat.fid);
  507. stat = fcall->params.twstat.stat;
  508. buf_put_int16(bufp, stat->size + 2);
  509. serialize_stat(stat, bufp, extended);
  510. break;
  511. }
  512. if (buf_check_overflow(bufp)) {
  513. dprintk(DEBUG_ERROR, "buffer overflow\n");
  514. return -EIO;
  515. }
  516. return fcall->size;
  517. }
  518. /**
  519. * deserialize_fcall - unmarshal a response
  520. * @buf: recieved buffer
  521. * @buflen: length of received buffer
  522. * @rcall: fcall structure to populate
  523. * @rcalllen: length of fcall structure to populate
  524. * @extended: non-zero if 9P2000.u
  525. *
  526. */
  527. int
  528. v9fs_deserialize_fcall(void *buf, u32 buflen, struct v9fs_fcall *rcall,
  529. int rcalllen, int extended)
  530. {
  531. struct cbuf buffer;
  532. struct cbuf *bufp = &buffer;
  533. struct cbuf dbuffer;
  534. struct cbuf *dbufp = &dbuffer;
  535. int i = 0;
  536. buf_init(bufp, buf, buflen);
  537. buf_init(dbufp, (char *)rcall + sizeof(struct v9fs_fcall),
  538. rcalllen - sizeof(struct v9fs_fcall));
  539. rcall->size = buf_get_int32(bufp);
  540. rcall->id = buf_get_int8(bufp);
  541. rcall->tag = buf_get_int16(bufp);
  542. dprintk(DEBUG_CONV, "size %d id %d tag %d\n", rcall->size, rcall->id,
  543. rcall->tag);
  544. switch (rcall->id) {
  545. default:
  546. eprintk(KERN_ERR, "unknown message type: %d\n", rcall->id);
  547. return -EPROTO;
  548. case RVERSION:
  549. rcall->params.rversion.msize = buf_get_int32(bufp);
  550. rcall->params.rversion.version = buf_get_stringb(bufp, dbufp);
  551. break;
  552. case RFLUSH:
  553. break;
  554. case RATTACH:
  555. rcall->params.rattach.qid.type = buf_get_int8(bufp);
  556. rcall->params.rattach.qid.version = buf_get_int32(bufp);
  557. rcall->params.rattach.qid.path = buf_get_int64(bufp);
  558. break;
  559. case RWALK:
  560. rcall->params.rwalk.nwqid = buf_get_int16(bufp);
  561. if (rcall->params.rwalk.nwqid > 16) {
  562. eprintk(KERN_ERR, "Rwalk with more than 16 qids: %d\n",
  563. rcall->params.rwalk.nwqid);
  564. return -EPROTO;
  565. }
  566. rcall->params.rwalk.wqids = buf_alloc(dbufp,
  567. rcall->params.rwalk.nwqid * sizeof(struct v9fs_qid));
  568. if (rcall->params.rwalk.wqids)
  569. for (i = 0; i < rcall->params.rwalk.nwqid; i++) {
  570. rcall->params.rwalk.wqids[i].type =
  571. buf_get_int8(bufp);
  572. rcall->params.rwalk.wqids[i].version =
  573. buf_get_int16(bufp);
  574. rcall->params.rwalk.wqids[i].path =
  575. buf_get_int64(bufp);
  576. }
  577. break;
  578. case ROPEN:
  579. rcall->params.ropen.qid.type = buf_get_int8(bufp);
  580. rcall->params.ropen.qid.version = buf_get_int32(bufp);
  581. rcall->params.ropen.qid.path = buf_get_int64(bufp);
  582. rcall->params.ropen.iounit = buf_get_int32(bufp);
  583. break;
  584. case RCREATE:
  585. rcall->params.rcreate.qid.type = buf_get_int8(bufp);
  586. rcall->params.rcreate.qid.version = buf_get_int32(bufp);
  587. rcall->params.rcreate.qid.path = buf_get_int64(bufp);
  588. rcall->params.rcreate.iounit = buf_get_int32(bufp);
  589. break;
  590. case RREAD:
  591. rcall->params.rread.count = buf_get_int32(bufp);
  592. rcall->params.rread.data = buf_get_datab(bufp, dbufp,
  593. rcall->params.rread.count);
  594. break;
  595. case RWRITE:
  596. rcall->params.rwrite.count = buf_get_int32(bufp);
  597. break;
  598. case RCLUNK:
  599. break;
  600. case RREMOVE:
  601. break;
  602. case RSTAT:
  603. buf_get_int16(bufp);
  604. rcall->params.rstat.stat =
  605. deserialize_statb(bufp, dbufp, extended);
  606. break;
  607. case RWSTAT:
  608. break;
  609. case RERROR:
  610. rcall->params.rerror.error = buf_get_stringb(bufp, dbufp);
  611. if (extended)
  612. rcall->params.rerror.errno = buf_get_int16(bufp);
  613. break;
  614. }
  615. if (buf_check_overflow(bufp) || buf_check_overflow(dbufp)) {
  616. dprintk(DEBUG_ERROR, "buffer overflow\n");
  617. return -EIO;
  618. }
  619. return rcall->size;
  620. }