nfsxdr.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * XDR support for nfsd
  4. *
  5. * Copyright (C) 1995, 1996 Olaf Kirch <[email protected]>
  6. */
  7. #include "vfs.h"
  8. #include "xdr.h"
  9. #include "auth.h"
  10. /*
  11. * Mapping of S_IF* types to NFS file types
  12. */
  13. static const u32 nfs_ftypes[] = {
  14. NFNON, NFCHR, NFCHR, NFBAD,
  15. NFDIR, NFBAD, NFBLK, NFBAD,
  16. NFREG, NFBAD, NFLNK, NFBAD,
  17. NFSOCK, NFBAD, NFLNK, NFBAD,
  18. };
  19. /*
  20. * Basic NFSv2 data types (RFC 1094 Section 2.3)
  21. */
  22. /**
  23. * svcxdr_encode_stat - Encode an NFSv2 status code
  24. * @xdr: XDR stream
  25. * @status: status value to encode
  26. *
  27. * Return values:
  28. * %false: Send buffer space was exhausted
  29. * %true: Success
  30. */
  31. bool
  32. svcxdr_encode_stat(struct xdr_stream *xdr, __be32 status)
  33. {
  34. __be32 *p;
  35. p = xdr_reserve_space(xdr, sizeof(status));
  36. if (!p)
  37. return false;
  38. *p = status;
  39. return true;
  40. }
  41. /**
  42. * svcxdr_decode_fhandle - Decode an NFSv2 file handle
  43. * @xdr: XDR stream positioned at an encoded NFSv2 FH
  44. * @fhp: OUT: filled-in server file handle
  45. *
  46. * Return values:
  47. * %false: The encoded file handle was not valid
  48. * %true: @fhp has been initialized
  49. */
  50. bool
  51. svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp)
  52. {
  53. __be32 *p;
  54. p = xdr_inline_decode(xdr, NFS_FHSIZE);
  55. if (!p)
  56. return false;
  57. fh_init(fhp, NFS_FHSIZE);
  58. memcpy(&fhp->fh_handle.fh_raw, p, NFS_FHSIZE);
  59. fhp->fh_handle.fh_size = NFS_FHSIZE;
  60. return true;
  61. }
  62. static bool
  63. svcxdr_encode_fhandle(struct xdr_stream *xdr, const struct svc_fh *fhp)
  64. {
  65. __be32 *p;
  66. p = xdr_reserve_space(xdr, NFS_FHSIZE);
  67. if (!p)
  68. return false;
  69. memcpy(p, &fhp->fh_handle.fh_raw, NFS_FHSIZE);
  70. return true;
  71. }
  72. static __be32 *
  73. encode_timeval(__be32 *p, const struct timespec64 *time)
  74. {
  75. *p++ = cpu_to_be32((u32)time->tv_sec);
  76. if (time->tv_nsec)
  77. *p++ = cpu_to_be32(time->tv_nsec / NSEC_PER_USEC);
  78. else
  79. *p++ = xdr_zero;
  80. return p;
  81. }
  82. static bool
  83. svcxdr_decode_filename(struct xdr_stream *xdr, char **name, unsigned int *len)
  84. {
  85. u32 size, i;
  86. __be32 *p;
  87. char *c;
  88. if (xdr_stream_decode_u32(xdr, &size) < 0)
  89. return false;
  90. if (size == 0 || size > NFS_MAXNAMLEN)
  91. return false;
  92. p = xdr_inline_decode(xdr, size);
  93. if (!p)
  94. return false;
  95. *len = size;
  96. *name = (char *)p;
  97. for (i = 0, c = *name; i < size; i++, c++)
  98. if (*c == '\0' || *c == '/')
  99. return false;
  100. return true;
  101. }
  102. static bool
  103. svcxdr_decode_diropargs(struct xdr_stream *xdr, struct svc_fh *fhp,
  104. char **name, unsigned int *len)
  105. {
  106. return svcxdr_decode_fhandle(xdr, fhp) &&
  107. svcxdr_decode_filename(xdr, name, len);
  108. }
  109. static bool
  110. svcxdr_decode_sattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
  111. struct iattr *iap)
  112. {
  113. u32 tmp1, tmp2;
  114. __be32 *p;
  115. p = xdr_inline_decode(xdr, XDR_UNIT * 8);
  116. if (!p)
  117. return false;
  118. iap->ia_valid = 0;
  119. /*
  120. * Some Sun clients put 0xffff in the mode field when they
  121. * mean 0xffffffff.
  122. */
  123. tmp1 = be32_to_cpup(p++);
  124. if (tmp1 != (u32)-1 && tmp1 != 0xffff) {
  125. iap->ia_valid |= ATTR_MODE;
  126. iap->ia_mode = tmp1;
  127. }
  128. tmp1 = be32_to_cpup(p++);
  129. if (tmp1 != (u32)-1) {
  130. iap->ia_uid = make_kuid(nfsd_user_namespace(rqstp), tmp1);
  131. if (uid_valid(iap->ia_uid))
  132. iap->ia_valid |= ATTR_UID;
  133. }
  134. tmp1 = be32_to_cpup(p++);
  135. if (tmp1 != (u32)-1) {
  136. iap->ia_gid = make_kgid(nfsd_user_namespace(rqstp), tmp1);
  137. if (gid_valid(iap->ia_gid))
  138. iap->ia_valid |= ATTR_GID;
  139. }
  140. tmp1 = be32_to_cpup(p++);
  141. if (tmp1 != (u32)-1) {
  142. iap->ia_valid |= ATTR_SIZE;
  143. iap->ia_size = tmp1;
  144. }
  145. tmp1 = be32_to_cpup(p++);
  146. tmp2 = be32_to_cpup(p++);
  147. if (tmp1 != (u32)-1 && tmp2 != (u32)-1) {
  148. iap->ia_valid |= ATTR_ATIME | ATTR_ATIME_SET;
  149. iap->ia_atime.tv_sec = tmp1;
  150. iap->ia_atime.tv_nsec = tmp2 * NSEC_PER_USEC;
  151. }
  152. tmp1 = be32_to_cpup(p++);
  153. tmp2 = be32_to_cpup(p++);
  154. if (tmp1 != (u32)-1 && tmp2 != (u32)-1) {
  155. iap->ia_valid |= ATTR_MTIME | ATTR_MTIME_SET;
  156. iap->ia_mtime.tv_sec = tmp1;
  157. iap->ia_mtime.tv_nsec = tmp2 * NSEC_PER_USEC;
  158. /*
  159. * Passing the invalid value useconds=1000000 for mtime
  160. * is a Sun convention for "set both mtime and atime to
  161. * current server time". It's needed to make permissions
  162. * checks for the "touch" program across v2 mounts to
  163. * Solaris and Irix boxes work correctly. See description of
  164. * sattr in section 6.1 of "NFS Illustrated" by
  165. * Brent Callaghan, Addison-Wesley, ISBN 0-201-32750-5
  166. */
  167. if (tmp2 == 1000000)
  168. iap->ia_valid &= ~(ATTR_ATIME_SET|ATTR_MTIME_SET);
  169. }
  170. return true;
  171. }
  172. /**
  173. * svcxdr_encode_fattr - Encode NFSv2 file attributes
  174. * @rqstp: Context of a completed RPC transaction
  175. * @xdr: XDR stream
  176. * @fhp: File handle to encode
  177. * @stat: Attributes to encode
  178. *
  179. * Return values:
  180. * %false: Send buffer space was exhausted
  181. * %true: Success
  182. */
  183. bool
  184. svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
  185. const struct svc_fh *fhp, const struct kstat *stat)
  186. {
  187. struct user_namespace *userns = nfsd_user_namespace(rqstp);
  188. struct dentry *dentry = fhp->fh_dentry;
  189. int type = stat->mode & S_IFMT;
  190. struct timespec64 time;
  191. __be32 *p;
  192. u32 fsid;
  193. p = xdr_reserve_space(xdr, XDR_UNIT * 17);
  194. if (!p)
  195. return false;
  196. *p++ = cpu_to_be32(nfs_ftypes[type >> 12]);
  197. *p++ = cpu_to_be32((u32)stat->mode);
  198. *p++ = cpu_to_be32((u32)stat->nlink);
  199. *p++ = cpu_to_be32((u32)from_kuid_munged(userns, stat->uid));
  200. *p++ = cpu_to_be32((u32)from_kgid_munged(userns, stat->gid));
  201. if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN)
  202. *p++ = cpu_to_be32(NFS_MAXPATHLEN);
  203. else
  204. *p++ = cpu_to_be32((u32) stat->size);
  205. *p++ = cpu_to_be32((u32) stat->blksize);
  206. if (S_ISCHR(type) || S_ISBLK(type))
  207. *p++ = cpu_to_be32(new_encode_dev(stat->rdev));
  208. else
  209. *p++ = cpu_to_be32(0xffffffff);
  210. *p++ = cpu_to_be32((u32)stat->blocks);
  211. switch (fsid_source(fhp)) {
  212. case FSIDSOURCE_FSID:
  213. fsid = (u32)fhp->fh_export->ex_fsid;
  214. break;
  215. case FSIDSOURCE_UUID:
  216. fsid = ((u32 *)fhp->fh_export->ex_uuid)[0];
  217. fsid ^= ((u32 *)fhp->fh_export->ex_uuid)[1];
  218. fsid ^= ((u32 *)fhp->fh_export->ex_uuid)[2];
  219. fsid ^= ((u32 *)fhp->fh_export->ex_uuid)[3];
  220. break;
  221. default:
  222. fsid = new_encode_dev(stat->dev);
  223. break;
  224. }
  225. *p++ = cpu_to_be32(fsid);
  226. *p++ = cpu_to_be32((u32)stat->ino);
  227. p = encode_timeval(p, &stat->atime);
  228. time = stat->mtime;
  229. lease_get_mtime(d_inode(dentry), &time);
  230. p = encode_timeval(p, &time);
  231. encode_timeval(p, &stat->ctime);
  232. return true;
  233. }
  234. /*
  235. * XDR decode functions
  236. */
  237. bool
  238. nfssvc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  239. {
  240. struct nfsd_fhandle *args = rqstp->rq_argp;
  241. return svcxdr_decode_fhandle(xdr, &args->fh);
  242. }
  243. bool
  244. nfssvc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  245. {
  246. struct nfsd_sattrargs *args = rqstp->rq_argp;
  247. return svcxdr_decode_fhandle(xdr, &args->fh) &&
  248. svcxdr_decode_sattr(rqstp, xdr, &args->attrs);
  249. }
  250. bool
  251. nfssvc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  252. {
  253. struct nfsd_diropargs *args = rqstp->rq_argp;
  254. return svcxdr_decode_diropargs(xdr, &args->fh, &args->name, &args->len);
  255. }
  256. bool
  257. nfssvc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  258. {
  259. struct nfsd_readargs *args = rqstp->rq_argp;
  260. u32 totalcount;
  261. if (!svcxdr_decode_fhandle(xdr, &args->fh))
  262. return false;
  263. if (xdr_stream_decode_u32(xdr, &args->offset) < 0)
  264. return false;
  265. if (xdr_stream_decode_u32(xdr, &args->count) < 0)
  266. return false;
  267. /* totalcount is ignored */
  268. if (xdr_stream_decode_u32(xdr, &totalcount) < 0)
  269. return false;
  270. return true;
  271. }
  272. bool
  273. nfssvc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  274. {
  275. struct nfsd_writeargs *args = rqstp->rq_argp;
  276. u32 beginoffset, totalcount;
  277. if (!svcxdr_decode_fhandle(xdr, &args->fh))
  278. return false;
  279. /* beginoffset is ignored */
  280. if (xdr_stream_decode_u32(xdr, &beginoffset) < 0)
  281. return false;
  282. if (xdr_stream_decode_u32(xdr, &args->offset) < 0)
  283. return false;
  284. /* totalcount is ignored */
  285. if (xdr_stream_decode_u32(xdr, &totalcount) < 0)
  286. return false;
  287. /* opaque data */
  288. if (xdr_stream_decode_u32(xdr, &args->len) < 0)
  289. return false;
  290. if (args->len > NFSSVC_MAXBLKSIZE_V2)
  291. return false;
  292. return xdr_stream_subsegment(xdr, &args->payload, args->len);
  293. }
  294. bool
  295. nfssvc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  296. {
  297. struct nfsd_createargs *args = rqstp->rq_argp;
  298. return svcxdr_decode_diropargs(xdr, &args->fh,
  299. &args->name, &args->len) &&
  300. svcxdr_decode_sattr(rqstp, xdr, &args->attrs);
  301. }
  302. bool
  303. nfssvc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  304. {
  305. struct nfsd_renameargs *args = rqstp->rq_argp;
  306. return svcxdr_decode_diropargs(xdr, &args->ffh,
  307. &args->fname, &args->flen) &&
  308. svcxdr_decode_diropargs(xdr, &args->tfh,
  309. &args->tname, &args->tlen);
  310. }
  311. bool
  312. nfssvc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  313. {
  314. struct nfsd_linkargs *args = rqstp->rq_argp;
  315. return svcxdr_decode_fhandle(xdr, &args->ffh) &&
  316. svcxdr_decode_diropargs(xdr, &args->tfh,
  317. &args->tname, &args->tlen);
  318. }
  319. bool
  320. nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  321. {
  322. struct nfsd_symlinkargs *args = rqstp->rq_argp;
  323. struct kvec *head = rqstp->rq_arg.head;
  324. if (!svcxdr_decode_diropargs(xdr, &args->ffh, &args->fname, &args->flen))
  325. return false;
  326. if (xdr_stream_decode_u32(xdr, &args->tlen) < 0)
  327. return false;
  328. if (args->tlen == 0)
  329. return false;
  330. args->first.iov_len = head->iov_len - xdr_stream_pos(xdr);
  331. args->first.iov_base = xdr_inline_decode(xdr, args->tlen);
  332. if (!args->first.iov_base)
  333. return false;
  334. return svcxdr_decode_sattr(rqstp, xdr, &args->attrs);
  335. }
  336. bool
  337. nfssvc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  338. {
  339. struct nfsd_readdirargs *args = rqstp->rq_argp;
  340. if (!svcxdr_decode_fhandle(xdr, &args->fh))
  341. return false;
  342. if (xdr_stream_decode_u32(xdr, &args->cookie) < 0)
  343. return false;
  344. if (xdr_stream_decode_u32(xdr, &args->count) < 0)
  345. return false;
  346. return true;
  347. }
  348. /*
  349. * XDR encode functions
  350. */
  351. bool
  352. nfssvc_encode_statres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  353. {
  354. struct nfsd_stat *resp = rqstp->rq_resp;
  355. return svcxdr_encode_stat(xdr, resp->status);
  356. }
  357. bool
  358. nfssvc_encode_attrstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  359. {
  360. struct nfsd_attrstat *resp = rqstp->rq_resp;
  361. if (!svcxdr_encode_stat(xdr, resp->status))
  362. return false;
  363. switch (resp->status) {
  364. case nfs_ok:
  365. if (!svcxdr_encode_fattr(rqstp, xdr, &resp->fh, &resp->stat))
  366. return false;
  367. break;
  368. }
  369. return true;
  370. }
  371. bool
  372. nfssvc_encode_diropres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  373. {
  374. struct nfsd_diropres *resp = rqstp->rq_resp;
  375. if (!svcxdr_encode_stat(xdr, resp->status))
  376. return false;
  377. switch (resp->status) {
  378. case nfs_ok:
  379. if (!svcxdr_encode_fhandle(xdr, &resp->fh))
  380. return false;
  381. if (!svcxdr_encode_fattr(rqstp, xdr, &resp->fh, &resp->stat))
  382. return false;
  383. break;
  384. }
  385. return true;
  386. }
  387. bool
  388. nfssvc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  389. {
  390. struct nfsd_readlinkres *resp = rqstp->rq_resp;
  391. struct kvec *head = rqstp->rq_res.head;
  392. if (!svcxdr_encode_stat(xdr, resp->status))
  393. return false;
  394. switch (resp->status) {
  395. case nfs_ok:
  396. if (xdr_stream_encode_u32(xdr, resp->len) < 0)
  397. return false;
  398. xdr_write_pages(xdr, &resp->page, 0, resp->len);
  399. if (svc_encode_result_payload(rqstp, head->iov_len, resp->len) < 0)
  400. return false;
  401. break;
  402. }
  403. return true;
  404. }
  405. bool
  406. nfssvc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  407. {
  408. struct nfsd_readres *resp = rqstp->rq_resp;
  409. struct kvec *head = rqstp->rq_res.head;
  410. if (!svcxdr_encode_stat(xdr, resp->status))
  411. return false;
  412. switch (resp->status) {
  413. case nfs_ok:
  414. if (!svcxdr_encode_fattr(rqstp, xdr, &resp->fh, &resp->stat))
  415. return false;
  416. if (xdr_stream_encode_u32(xdr, resp->count) < 0)
  417. return false;
  418. xdr_write_pages(xdr, resp->pages, rqstp->rq_res.page_base,
  419. resp->count);
  420. if (svc_encode_result_payload(rqstp, head->iov_len, resp->count) < 0)
  421. return false;
  422. break;
  423. }
  424. return true;
  425. }
  426. bool
  427. nfssvc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  428. {
  429. struct nfsd_readdirres *resp = rqstp->rq_resp;
  430. struct xdr_buf *dirlist = &resp->dirlist;
  431. if (!svcxdr_encode_stat(xdr, resp->status))
  432. return false;
  433. switch (resp->status) {
  434. case nfs_ok:
  435. xdr_write_pages(xdr, dirlist->pages, 0, dirlist->len);
  436. /* no more entries */
  437. if (xdr_stream_encode_item_absent(xdr) < 0)
  438. return false;
  439. if (xdr_stream_encode_bool(xdr, resp->common.err == nfserr_eof) < 0)
  440. return false;
  441. break;
  442. }
  443. return true;
  444. }
  445. bool
  446. nfssvc_encode_statfsres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  447. {
  448. struct nfsd_statfsres *resp = rqstp->rq_resp;
  449. struct kstatfs *stat = &resp->stats;
  450. __be32 *p;
  451. if (!svcxdr_encode_stat(xdr, resp->status))
  452. return false;
  453. switch (resp->status) {
  454. case nfs_ok:
  455. p = xdr_reserve_space(xdr, XDR_UNIT * 5);
  456. if (!p)
  457. return false;
  458. *p++ = cpu_to_be32(NFSSVC_MAXBLKSIZE_V2);
  459. *p++ = cpu_to_be32(stat->f_bsize);
  460. *p++ = cpu_to_be32(stat->f_blocks);
  461. *p++ = cpu_to_be32(stat->f_bfree);
  462. *p = cpu_to_be32(stat->f_bavail);
  463. break;
  464. }
  465. return true;
  466. }
  467. /**
  468. * nfssvc_encode_nfscookie - Encode a directory offset cookie
  469. * @resp: readdir result context
  470. * @offset: offset cookie to encode
  471. *
  472. * The buffer space for the offset cookie has already been reserved
  473. * by svcxdr_encode_entry_common().
  474. */
  475. void nfssvc_encode_nfscookie(struct nfsd_readdirres *resp, u32 offset)
  476. {
  477. __be32 cookie = cpu_to_be32(offset);
  478. if (!resp->cookie_offset)
  479. return;
  480. write_bytes_to_xdr_buf(&resp->dirlist, resp->cookie_offset, &cookie,
  481. sizeof(cookie));
  482. resp->cookie_offset = 0;
  483. }
  484. static bool
  485. svcxdr_encode_entry_common(struct nfsd_readdirres *resp, const char *name,
  486. int namlen, loff_t offset, u64 ino)
  487. {
  488. struct xdr_buf *dirlist = &resp->dirlist;
  489. struct xdr_stream *xdr = &resp->xdr;
  490. if (xdr_stream_encode_item_present(xdr) < 0)
  491. return false;
  492. /* fileid */
  493. if (xdr_stream_encode_u32(xdr, (u32)ino) < 0)
  494. return false;
  495. /* name */
  496. if (xdr_stream_encode_opaque(xdr, name, min(namlen, NFS2_MAXNAMLEN)) < 0)
  497. return false;
  498. /* cookie */
  499. resp->cookie_offset = dirlist->len;
  500. if (xdr_stream_encode_u32(xdr, ~0U) < 0)
  501. return false;
  502. return true;
  503. }
  504. /**
  505. * nfssvc_encode_entry - encode one NFSv2 READDIR entry
  506. * @data: directory context
  507. * @name: name of the object to be encoded
  508. * @namlen: length of that name, in bytes
  509. * @offset: the offset of the previous entry
  510. * @ino: the fileid of this entry
  511. * @d_type: unused
  512. *
  513. * Return values:
  514. * %0: Entry was successfully encoded.
  515. * %-EINVAL: An encoding problem occured, secondary status code in resp->common.err
  516. *
  517. * On exit, the following fields are updated:
  518. * - resp->xdr
  519. * - resp->common.err
  520. * - resp->cookie_offset
  521. */
  522. int nfssvc_encode_entry(void *data, const char *name, int namlen,
  523. loff_t offset, u64 ino, unsigned int d_type)
  524. {
  525. struct readdir_cd *ccd = data;
  526. struct nfsd_readdirres *resp = container_of(ccd,
  527. struct nfsd_readdirres,
  528. common);
  529. unsigned int starting_length = resp->dirlist.len;
  530. /* The offset cookie for the previous entry */
  531. nfssvc_encode_nfscookie(resp, offset);
  532. if (!svcxdr_encode_entry_common(resp, name, namlen, offset, ino))
  533. goto out_toosmall;
  534. xdr_commit_encode(&resp->xdr);
  535. resp->common.err = nfs_ok;
  536. return 0;
  537. out_toosmall:
  538. resp->cookie_offset = 0;
  539. resp->common.err = nfserr_toosmall;
  540. resp->dirlist.len = starting_length;
  541. return -EINVAL;
  542. }
  543. /*
  544. * XDR release functions
  545. */
  546. void nfssvc_release_attrstat(struct svc_rqst *rqstp)
  547. {
  548. struct nfsd_attrstat *resp = rqstp->rq_resp;
  549. fh_put(&resp->fh);
  550. }
  551. void nfssvc_release_diropres(struct svc_rqst *rqstp)
  552. {
  553. struct nfsd_diropres *resp = rqstp->rq_resp;
  554. fh_put(&resp->fh);
  555. }
  556. void nfssvc_release_readres(struct svc_rqst *rqstp)
  557. {
  558. struct nfsd_readres *resp = rqstp->rq_resp;
  559. fh_put(&resp->fh);
  560. }