nfs3xdr.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. /*
  2. * linux/fs/nfs/nfs3xdr.c
  3. *
  4. * XDR functions to encode/decode NFSv3 RPC arguments and results.
  5. *
  6. * Copyright (C) 1996, 1997 Olaf Kirch
  7. */
  8. #include <linux/param.h>
  9. #include <linux/time.h>
  10. #include <linux/mm.h>
  11. #include <linux/slab.h>
  12. #include <linux/utsname.h>
  13. #include <linux/errno.h>
  14. #include <linux/string.h>
  15. #include <linux/in.h>
  16. #include <linux/pagemap.h>
  17. #include <linux/proc_fs.h>
  18. #include <linux/kdev_t.h>
  19. #include <linux/sunrpc/clnt.h>
  20. #include <linux/nfs.h>
  21. #include <linux/nfs3.h>
  22. #include <linux/nfs_fs.h>
  23. #include <linux/nfsacl.h>
  24. #include "internal.h"
  25. #define NFSDBG_FACILITY NFSDBG_XDR
  26. /* Mapping from NFS error code to "errno" error code. */
  27. #define errno_NFSERR_IO EIO
  28. /*
  29. * Declare the space requirements for NFS arguments and replies as
  30. * number of 32bit-words
  31. */
  32. #define NFS3_fhandle_sz (1+16)
  33. #define NFS3_fh_sz (NFS3_fhandle_sz) /* shorthand */
  34. #define NFS3_sattr_sz (15)
  35. #define NFS3_filename_sz (1+(NFS3_MAXNAMLEN>>2))
  36. #define NFS3_path_sz (1+(NFS3_MAXPATHLEN>>2))
  37. #define NFS3_fattr_sz (21)
  38. #define NFS3_wcc_attr_sz (6)
  39. #define NFS3_pre_op_attr_sz (1+NFS3_wcc_attr_sz)
  40. #define NFS3_post_op_attr_sz (1+NFS3_fattr_sz)
  41. #define NFS3_wcc_data_sz (NFS3_pre_op_attr_sz+NFS3_post_op_attr_sz)
  42. #define NFS3_fsstat_sz
  43. #define NFS3_fsinfo_sz
  44. #define NFS3_pathconf_sz
  45. #define NFS3_entry_sz (NFS3_filename_sz+3)
  46. #define NFS3_sattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3)
  47. #define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz)
  48. #define NFS3_removeargs_sz (NFS3_fh_sz+NFS3_filename_sz)
  49. #define NFS3_accessargs_sz (NFS3_fh_sz+1)
  50. #define NFS3_readlinkargs_sz (NFS3_fh_sz)
  51. #define NFS3_readargs_sz (NFS3_fh_sz+3)
  52. #define NFS3_writeargs_sz (NFS3_fh_sz+5)
  53. #define NFS3_createargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
  54. #define NFS3_mkdirargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
  55. #define NFS3_symlinkargs_sz (NFS3_diropargs_sz+1+NFS3_sattr_sz)
  56. #define NFS3_mknodargs_sz (NFS3_diropargs_sz+2+NFS3_sattr_sz)
  57. #define NFS3_renameargs_sz (NFS3_diropargs_sz+NFS3_diropargs_sz)
  58. #define NFS3_linkargs_sz (NFS3_fh_sz+NFS3_diropargs_sz)
  59. #define NFS3_readdirargs_sz (NFS3_fh_sz+2)
  60. #define NFS3_commitargs_sz (NFS3_fh_sz+3)
  61. #define NFS3_attrstat_sz (1+NFS3_fattr_sz)
  62. #define NFS3_wccstat_sz (1+NFS3_wcc_data_sz)
  63. #define NFS3_removeres_sz (NFS3_wccstat_sz)
  64. #define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz))
  65. #define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1)
  66. #define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1)
  67. #define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3)
  68. #define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4)
  69. #define NFS3_createres_sz (1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
  70. #define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz))
  71. #define NFS3_linkres_sz (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
  72. #define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2)
  73. #define NFS3_fsstatres_sz (1+NFS3_post_op_attr_sz+13)
  74. #define NFS3_fsinfores_sz (1+NFS3_post_op_attr_sz+12)
  75. #define NFS3_pathconfres_sz (1+NFS3_post_op_attr_sz+6)
  76. #define NFS3_commitres_sz (1+NFS3_wcc_data_sz+2)
  77. #define ACL3_getaclargs_sz (NFS3_fh_sz+1)
  78. #define ACL3_setaclargs_sz (NFS3_fh_sz+1+2*(2+5*3))
  79. #define ACL3_getaclres_sz (1+NFS3_post_op_attr_sz+1+2*(2+5*3))
  80. #define ACL3_setaclres_sz (1+NFS3_post_op_attr_sz)
  81. /*
  82. * Map file type to S_IFMT bits
  83. */
  84. static struct {
  85. unsigned int mode;
  86. unsigned int nfs2type;
  87. } nfs_type2fmt[] = {
  88. { 0, NFNON },
  89. { S_IFREG, NFREG },
  90. { S_IFDIR, NFDIR },
  91. { S_IFBLK, NFBLK },
  92. { S_IFCHR, NFCHR },
  93. { S_IFLNK, NFLNK },
  94. { S_IFSOCK, NFSOCK },
  95. { S_IFIFO, NFFIFO },
  96. { 0, NFBAD }
  97. };
  98. /*
  99. * Common NFS XDR functions as inlines
  100. */
  101. static inline __be32 *
  102. xdr_encode_fhandle(__be32 *p, const struct nfs_fh *fh)
  103. {
  104. return xdr_encode_array(p, fh->data, fh->size);
  105. }
  106. static inline __be32 *
  107. xdr_decode_fhandle(__be32 *p, struct nfs_fh *fh)
  108. {
  109. if ((fh->size = ntohl(*p++)) <= NFS3_FHSIZE) {
  110. memcpy(fh->data, p, fh->size);
  111. return p + XDR_QUADLEN(fh->size);
  112. }
  113. return NULL;
  114. }
  115. /*
  116. * Encode/decode time.
  117. */
  118. static inline __be32 *
  119. xdr_encode_time3(__be32 *p, struct timespec *timep)
  120. {
  121. *p++ = htonl(timep->tv_sec);
  122. *p++ = htonl(timep->tv_nsec);
  123. return p;
  124. }
  125. static inline __be32 *
  126. xdr_decode_time3(__be32 *p, struct timespec *timep)
  127. {
  128. timep->tv_sec = ntohl(*p++);
  129. timep->tv_nsec = ntohl(*p++);
  130. return p;
  131. }
  132. static __be32 *
  133. xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
  134. {
  135. unsigned int type, major, minor;
  136. int fmode;
  137. type = ntohl(*p++);
  138. if (type >= NF3BAD)
  139. type = NF3BAD;
  140. fmode = nfs_type2fmt[type].mode;
  141. fattr->type = nfs_type2fmt[type].nfs2type;
  142. fattr->mode = (ntohl(*p++) & ~S_IFMT) | fmode;
  143. fattr->nlink = ntohl(*p++);
  144. fattr->uid = ntohl(*p++);
  145. fattr->gid = ntohl(*p++);
  146. p = xdr_decode_hyper(p, &fattr->size);
  147. p = xdr_decode_hyper(p, &fattr->du.nfs3.used);
  148. /* Turn remote device info into Linux-specific dev_t */
  149. major = ntohl(*p++);
  150. minor = ntohl(*p++);
  151. fattr->rdev = MKDEV(major, minor);
  152. if (MAJOR(fattr->rdev) != major || MINOR(fattr->rdev) != minor)
  153. fattr->rdev = 0;
  154. p = xdr_decode_hyper(p, &fattr->fsid.major);
  155. fattr->fsid.minor = 0;
  156. p = xdr_decode_hyper(p, &fattr->fileid);
  157. p = xdr_decode_time3(p, &fattr->atime);
  158. p = xdr_decode_time3(p, &fattr->mtime);
  159. p = xdr_decode_time3(p, &fattr->ctime);
  160. /* Update the mode bits */
  161. fattr->valid |= (NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3);
  162. return p;
  163. }
  164. static inline __be32 *
  165. xdr_encode_sattr(__be32 *p, struct iattr *attr)
  166. {
  167. if (attr->ia_valid & ATTR_MODE) {
  168. *p++ = xdr_one;
  169. *p++ = htonl(attr->ia_mode & S_IALLUGO);
  170. } else {
  171. *p++ = xdr_zero;
  172. }
  173. if (attr->ia_valid & ATTR_UID) {
  174. *p++ = xdr_one;
  175. *p++ = htonl(attr->ia_uid);
  176. } else {
  177. *p++ = xdr_zero;
  178. }
  179. if (attr->ia_valid & ATTR_GID) {
  180. *p++ = xdr_one;
  181. *p++ = htonl(attr->ia_gid);
  182. } else {
  183. *p++ = xdr_zero;
  184. }
  185. if (attr->ia_valid & ATTR_SIZE) {
  186. *p++ = xdr_one;
  187. p = xdr_encode_hyper(p, (__u64) attr->ia_size);
  188. } else {
  189. *p++ = xdr_zero;
  190. }
  191. if (attr->ia_valid & ATTR_ATIME_SET) {
  192. *p++ = xdr_two;
  193. p = xdr_encode_time3(p, &attr->ia_atime);
  194. } else if (attr->ia_valid & ATTR_ATIME) {
  195. *p++ = xdr_one;
  196. } else {
  197. *p++ = xdr_zero;
  198. }
  199. if (attr->ia_valid & ATTR_MTIME_SET) {
  200. *p++ = xdr_two;
  201. p = xdr_encode_time3(p, &attr->ia_mtime);
  202. } else if (attr->ia_valid & ATTR_MTIME) {
  203. *p++ = xdr_one;
  204. } else {
  205. *p++ = xdr_zero;
  206. }
  207. return p;
  208. }
  209. static inline __be32 *
  210. xdr_decode_wcc_attr(__be32 *p, struct nfs_fattr *fattr)
  211. {
  212. p = xdr_decode_hyper(p, &fattr->pre_size);
  213. p = xdr_decode_time3(p, &fattr->pre_mtime);
  214. p = xdr_decode_time3(p, &fattr->pre_ctime);
  215. fattr->valid |= NFS_ATTR_WCC;
  216. return p;
  217. }
  218. static inline __be32 *
  219. xdr_decode_post_op_attr(__be32 *p, struct nfs_fattr *fattr)
  220. {
  221. if (*p++)
  222. p = xdr_decode_fattr(p, fattr);
  223. return p;
  224. }
  225. static inline __be32 *
  226. xdr_decode_pre_op_attr(__be32 *p, struct nfs_fattr *fattr)
  227. {
  228. if (*p++)
  229. return xdr_decode_wcc_attr(p, fattr);
  230. return p;
  231. }
  232. static inline __be32 *
  233. xdr_decode_wcc_data(__be32 *p, struct nfs_fattr *fattr)
  234. {
  235. p = xdr_decode_pre_op_attr(p, fattr);
  236. return xdr_decode_post_op_attr(p, fattr);
  237. }
  238. /*
  239. * NFS encode functions
  240. */
  241. /*
  242. * Encode file handle argument
  243. */
  244. static int
  245. nfs3_xdr_fhandle(struct rpc_rqst *req, __be32 *p, struct nfs_fh *fh)
  246. {
  247. p = xdr_encode_fhandle(p, fh);
  248. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  249. return 0;
  250. }
  251. /*
  252. * Encode SETATTR arguments
  253. */
  254. static int
  255. nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
  256. {
  257. p = xdr_encode_fhandle(p, args->fh);
  258. p = xdr_encode_sattr(p, args->sattr);
  259. *p++ = htonl(args->guard);
  260. if (args->guard)
  261. p = xdr_encode_time3(p, &args->guardtime);
  262. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  263. return 0;
  264. }
  265. /*
  266. * Encode directory ops argument
  267. */
  268. static int
  269. nfs3_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs3_diropargs *args)
  270. {
  271. p = xdr_encode_fhandle(p, args->fh);
  272. p = xdr_encode_array(p, args->name, args->len);
  273. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  274. return 0;
  275. }
  276. /*
  277. * Encode REMOVE argument
  278. */
  279. static int
  280. nfs3_xdr_removeargs(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args)
  281. {
  282. p = xdr_encode_fhandle(p, args->fh);
  283. p = xdr_encode_array(p, args->name.name, args->name.len);
  284. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  285. return 0;
  286. }
  287. /*
  288. * Encode access() argument
  289. */
  290. static int
  291. nfs3_xdr_accessargs(struct rpc_rqst *req, __be32 *p, struct nfs3_accessargs *args)
  292. {
  293. p = xdr_encode_fhandle(p, args->fh);
  294. *p++ = htonl(args->access);
  295. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  296. return 0;
  297. }
  298. /*
  299. * Arguments to a READ call. Since we read data directly into the page
  300. * cache, we also set up the reply iovec here so that iov[1] points
  301. * exactly to the page we want to fetch.
  302. */
  303. static int
  304. nfs3_xdr_readargs(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
  305. {
  306. struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
  307. unsigned int replen;
  308. u32 count = args->count;
  309. p = xdr_encode_fhandle(p, args->fh);
  310. p = xdr_encode_hyper(p, args->offset);
  311. *p++ = htonl(count);
  312. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  313. /* Inline the page array */
  314. replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS3_readres_sz) << 2;
  315. xdr_inline_pages(&req->rq_rcv_buf, replen,
  316. args->pages, args->pgbase, count);
  317. req->rq_rcv_buf.flags |= XDRBUF_READ;
  318. return 0;
  319. }
  320. /*
  321. * Write arguments. Splice the buffer to be written into the iovec.
  322. */
  323. static int
  324. nfs3_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
  325. {
  326. struct xdr_buf *sndbuf = &req->rq_snd_buf;
  327. u32 count = args->count;
  328. p = xdr_encode_fhandle(p, args->fh);
  329. p = xdr_encode_hyper(p, args->offset);
  330. *p++ = htonl(count);
  331. *p++ = htonl(args->stable);
  332. *p++ = htonl(count);
  333. sndbuf->len = xdr_adjust_iovec(sndbuf->head, p);
  334. /* Copy the page array */
  335. xdr_encode_pages(sndbuf, args->pages, args->pgbase, count);
  336. sndbuf->flags |= XDRBUF_WRITE;
  337. return 0;
  338. }
  339. /*
  340. * Encode CREATE arguments
  341. */
  342. static int
  343. nfs3_xdr_createargs(struct rpc_rqst *req, __be32 *p, struct nfs3_createargs *args)
  344. {
  345. p = xdr_encode_fhandle(p, args->fh);
  346. p = xdr_encode_array(p, args->name, args->len);
  347. *p++ = htonl(args->createmode);
  348. if (args->createmode == NFS3_CREATE_EXCLUSIVE) {
  349. *p++ = args->verifier[0];
  350. *p++ = args->verifier[1];
  351. } else
  352. p = xdr_encode_sattr(p, args->sattr);
  353. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  354. return 0;
  355. }
  356. /*
  357. * Encode MKDIR arguments
  358. */
  359. static int
  360. nfs3_xdr_mkdirargs(struct rpc_rqst *req, __be32 *p, struct nfs3_mkdirargs *args)
  361. {
  362. p = xdr_encode_fhandle(p, args->fh);
  363. p = xdr_encode_array(p, args->name, args->len);
  364. p = xdr_encode_sattr(p, args->sattr);
  365. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  366. return 0;
  367. }
  368. /*
  369. * Encode SYMLINK arguments
  370. */
  371. static int
  372. nfs3_xdr_symlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_symlinkargs *args)
  373. {
  374. p = xdr_encode_fhandle(p, args->fromfh);
  375. p = xdr_encode_array(p, args->fromname, args->fromlen);
  376. p = xdr_encode_sattr(p, args->sattr);
  377. *p++ = htonl(args->pathlen);
  378. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  379. /* Copy the page */
  380. xdr_encode_pages(&req->rq_snd_buf, args->pages, 0, args->pathlen);
  381. return 0;
  382. }
  383. /*
  384. * Encode MKNOD arguments
  385. */
  386. static int
  387. nfs3_xdr_mknodargs(struct rpc_rqst *req, __be32 *p, struct nfs3_mknodargs *args)
  388. {
  389. p = xdr_encode_fhandle(p, args->fh);
  390. p = xdr_encode_array(p, args->name, args->len);
  391. *p++ = htonl(args->type);
  392. p = xdr_encode_sattr(p, args->sattr);
  393. if (args->type == NF3CHR || args->type == NF3BLK) {
  394. *p++ = htonl(MAJOR(args->rdev));
  395. *p++ = htonl(MINOR(args->rdev));
  396. }
  397. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  398. return 0;
  399. }
  400. /*
  401. * Encode RENAME arguments
  402. */
  403. static int
  404. nfs3_xdr_renameargs(struct rpc_rqst *req, __be32 *p, struct nfs3_renameargs *args)
  405. {
  406. p = xdr_encode_fhandle(p, args->fromfh);
  407. p = xdr_encode_array(p, args->fromname, args->fromlen);
  408. p = xdr_encode_fhandle(p, args->tofh);
  409. p = xdr_encode_array(p, args->toname, args->tolen);
  410. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  411. return 0;
  412. }
  413. /*
  414. * Encode LINK arguments
  415. */
  416. static int
  417. nfs3_xdr_linkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_linkargs *args)
  418. {
  419. p = xdr_encode_fhandle(p, args->fromfh);
  420. p = xdr_encode_fhandle(p, args->tofh);
  421. p = xdr_encode_array(p, args->toname, args->tolen);
  422. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  423. return 0;
  424. }
  425. /*
  426. * Encode arguments to readdir call
  427. */
  428. static int
  429. nfs3_xdr_readdirargs(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirargs *args)
  430. {
  431. struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
  432. unsigned int replen;
  433. u32 count = args->count;
  434. p = xdr_encode_fhandle(p, args->fh);
  435. p = xdr_encode_hyper(p, args->cookie);
  436. *p++ = args->verf[0];
  437. *p++ = args->verf[1];
  438. if (args->plus) {
  439. /* readdirplus: need dircount + buffer size.
  440. * We just make sure we make dircount big enough */
  441. *p++ = htonl(count >> 3);
  442. }
  443. *p++ = htonl(count);
  444. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  445. /* Inline the page array */
  446. replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS3_readdirres_sz) << 2;
  447. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, 0, count);
  448. return 0;
  449. }
  450. /*
  451. * Decode the result of a readdir call.
  452. * We just check for syntactical correctness.
  453. */
  454. static int
  455. nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res)
  456. {
  457. struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
  458. struct kvec *iov = rcvbuf->head;
  459. struct page **page;
  460. int hdrlen, recvd;
  461. int status, nr;
  462. unsigned int len, pglen;
  463. __be32 *entry, *end, *kaddr;
  464. status = ntohl(*p++);
  465. /* Decode post_op_attrs */
  466. p = xdr_decode_post_op_attr(p, res->dir_attr);
  467. if (status)
  468. return -nfs_stat_to_errno(status);
  469. /* Decode verifier cookie */
  470. if (res->verf) {
  471. res->verf[0] = *p++;
  472. res->verf[1] = *p++;
  473. } else {
  474. p += 2;
  475. }
  476. hdrlen = (u8 *) p - (u8 *) iov->iov_base;
  477. if (iov->iov_len < hdrlen) {
  478. dprintk("NFS: READDIR reply header overflowed:"
  479. "length %d > %Zu\n", hdrlen, iov->iov_len);
  480. return -errno_NFSERR_IO;
  481. } else if (iov->iov_len != hdrlen) {
  482. dprintk("NFS: READDIR header is short. iovec will be shifted.\n");
  483. xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen);
  484. }
  485. pglen = rcvbuf->page_len;
  486. recvd = rcvbuf->len - hdrlen;
  487. if (pglen > recvd)
  488. pglen = recvd;
  489. page = rcvbuf->pages;
  490. kaddr = p = kmap_atomic(*page, KM_USER0);
  491. end = (__be32 *)((char *)p + pglen);
  492. entry = p;
  493. for (nr = 0; *p++; nr++) {
  494. if (p + 3 > end)
  495. goto short_pkt;
  496. p += 2; /* inode # */
  497. len = ntohl(*p++); /* string length */
  498. p += XDR_QUADLEN(len) + 2; /* name + cookie */
  499. if (len > NFS3_MAXNAMLEN) {
  500. dprintk("NFS: giant filename in readdir (len %x)!\n",
  501. len);
  502. goto err_unmap;
  503. }
  504. if (res->plus) {
  505. /* post_op_attr */
  506. if (p + 2 > end)
  507. goto short_pkt;
  508. if (*p++) {
  509. p += 21;
  510. if (p + 1 > end)
  511. goto short_pkt;
  512. }
  513. /* post_op_fh3 */
  514. if (*p++) {
  515. if (p + 1 > end)
  516. goto short_pkt;
  517. len = ntohl(*p++);
  518. if (len > NFS3_FHSIZE) {
  519. dprintk("NFS: giant filehandle in "
  520. "readdir (len %x)!\n", len);
  521. goto err_unmap;
  522. }
  523. p += XDR_QUADLEN(len);
  524. }
  525. }
  526. if (p + 2 > end)
  527. goto short_pkt;
  528. entry = p;
  529. }
  530. if (!nr && (entry[0] != 0 || entry[1] == 0))
  531. goto short_pkt;
  532. out:
  533. kunmap_atomic(kaddr, KM_USER0);
  534. return nr;
  535. short_pkt:
  536. entry[0] = entry[1] = 0;
  537. /* truncate listing ? */
  538. if (!nr) {
  539. dprintk("NFS: readdir reply truncated!\n");
  540. entry[1] = 1;
  541. }
  542. goto out;
  543. err_unmap:
  544. nr = -errno_NFSERR_IO;
  545. goto out;
  546. }
  547. __be32 *
  548. nfs3_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus)
  549. {
  550. struct nfs_entry old = *entry;
  551. if (!*p++) {
  552. if (!*p)
  553. return ERR_PTR(-EAGAIN);
  554. entry->eof = 1;
  555. return ERR_PTR(-EBADCOOKIE);
  556. }
  557. p = xdr_decode_hyper(p, &entry->ino);
  558. entry->len = ntohl(*p++);
  559. entry->name = (const char *) p;
  560. p += XDR_QUADLEN(entry->len);
  561. entry->prev_cookie = entry->cookie;
  562. p = xdr_decode_hyper(p, &entry->cookie);
  563. if (plus) {
  564. entry->fattr->valid = 0;
  565. p = xdr_decode_post_op_attr(p, entry->fattr);
  566. /* In fact, a post_op_fh3: */
  567. if (*p++) {
  568. p = xdr_decode_fhandle(p, entry->fh);
  569. /* Ugh -- server reply was truncated */
  570. if (p == NULL) {
  571. dprintk("NFS: FH truncated\n");
  572. *entry = old;
  573. return ERR_PTR(-EAGAIN);
  574. }
  575. } else
  576. memset((u8*)(entry->fh), 0, sizeof(*entry->fh));
  577. }
  578. entry->eof = !p[0] && p[1];
  579. return p;
  580. }
  581. /*
  582. * Encode COMMIT arguments
  583. */
  584. static int
  585. nfs3_xdr_commitargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
  586. {
  587. p = xdr_encode_fhandle(p, args->fh);
  588. p = xdr_encode_hyper(p, args->offset);
  589. *p++ = htonl(args->count);
  590. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  591. return 0;
  592. }
  593. #ifdef CONFIG_NFS_V3_ACL
  594. /*
  595. * Encode GETACL arguments
  596. */
  597. static int
  598. nfs3_xdr_getaclargs(struct rpc_rqst *req, __be32 *p,
  599. struct nfs3_getaclargs *args)
  600. {
  601. struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
  602. unsigned int replen;
  603. p = xdr_encode_fhandle(p, args->fh);
  604. *p++ = htonl(args->mask);
  605. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  606. if (args->mask & (NFS_ACL | NFS_DFACL)) {
  607. /* Inline the page array */
  608. replen = (RPC_REPHDRSIZE + auth->au_rslack +
  609. ACL3_getaclres_sz) << 2;
  610. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, 0,
  611. NFSACL_MAXPAGES << PAGE_SHIFT);
  612. }
  613. return 0;
  614. }
  615. /*
  616. * Encode SETACL arguments
  617. */
  618. static int
  619. nfs3_xdr_setaclargs(struct rpc_rqst *req, __be32 *p,
  620. struct nfs3_setaclargs *args)
  621. {
  622. struct xdr_buf *buf = &req->rq_snd_buf;
  623. unsigned int base, len_in_head, len = nfsacl_size(
  624. (args->mask & NFS_ACL) ? args->acl_access : NULL,
  625. (args->mask & NFS_DFACL) ? args->acl_default : NULL);
  626. int count, err;
  627. p = xdr_encode_fhandle(p, NFS_FH(args->inode));
  628. *p++ = htonl(args->mask);
  629. base = (char *)p - (char *)buf->head->iov_base;
  630. /* put as much of the acls into head as possible. */
  631. len_in_head = min_t(unsigned int, buf->head->iov_len - base, len);
  632. len -= len_in_head;
  633. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p + (len_in_head >> 2));
  634. for (count = 0; (count << PAGE_SHIFT) < len; count++) {
  635. args->pages[count] = alloc_page(GFP_KERNEL);
  636. if (!args->pages[count]) {
  637. while (count)
  638. __free_page(args->pages[--count]);
  639. return -ENOMEM;
  640. }
  641. }
  642. xdr_encode_pages(buf, args->pages, 0, len);
  643. err = nfsacl_encode(buf, base, args->inode,
  644. (args->mask & NFS_ACL) ?
  645. args->acl_access : NULL, 1, 0);
  646. if (err > 0)
  647. err = nfsacl_encode(buf, base + err, args->inode,
  648. (args->mask & NFS_DFACL) ?
  649. args->acl_default : NULL, 1,
  650. NFS_ACL_DEFAULT);
  651. return (err > 0) ? 0 : err;
  652. }
  653. #endif /* CONFIG_NFS_V3_ACL */
  654. /*
  655. * NFS XDR decode functions
  656. */
  657. /*
  658. * Decode attrstat reply.
  659. */
  660. static int
  661. nfs3_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  662. {
  663. int status;
  664. if ((status = ntohl(*p++)))
  665. return -nfs_stat_to_errno(status);
  666. xdr_decode_fattr(p, fattr);
  667. return 0;
  668. }
  669. /*
  670. * Decode status+wcc_data reply
  671. * SATTR, REMOVE, RMDIR
  672. */
  673. static int
  674. nfs3_xdr_wccstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  675. {
  676. int status;
  677. if ((status = ntohl(*p++)))
  678. status = -nfs_stat_to_errno(status);
  679. xdr_decode_wcc_data(p, fattr);
  680. return status;
  681. }
  682. static int
  683. nfs3_xdr_removeres(struct rpc_rqst *req, __be32 *p, struct nfs_removeres *res)
  684. {
  685. return nfs3_xdr_wccstat(req, p, &res->dir_attr);
  686. }
  687. /*
  688. * Decode LOOKUP reply
  689. */
  690. static int
  691. nfs3_xdr_lookupres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
  692. {
  693. int status;
  694. if ((status = ntohl(*p++))) {
  695. status = -nfs_stat_to_errno(status);
  696. } else {
  697. if (!(p = xdr_decode_fhandle(p, res->fh)))
  698. return -errno_NFSERR_IO;
  699. p = xdr_decode_post_op_attr(p, res->fattr);
  700. }
  701. xdr_decode_post_op_attr(p, res->dir_attr);
  702. return status;
  703. }
  704. /*
  705. * Decode ACCESS reply
  706. */
  707. static int
  708. nfs3_xdr_accessres(struct rpc_rqst *req, __be32 *p, struct nfs3_accessres *res)
  709. {
  710. int status = ntohl(*p++);
  711. p = xdr_decode_post_op_attr(p, res->fattr);
  712. if (status)
  713. return -nfs_stat_to_errno(status);
  714. res->access = ntohl(*p++);
  715. return 0;
  716. }
  717. static int
  718. nfs3_xdr_readlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_readlinkargs *args)
  719. {
  720. struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
  721. unsigned int replen;
  722. p = xdr_encode_fhandle(p, args->fh);
  723. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  724. /* Inline the page array */
  725. replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS3_readlinkres_sz) << 2;
  726. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, args->pgbase, args->pglen);
  727. return 0;
  728. }
  729. /*
  730. * Decode READLINK reply
  731. */
  732. static int
  733. nfs3_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  734. {
  735. struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
  736. struct kvec *iov = rcvbuf->head;
  737. int hdrlen, len, recvd;
  738. char *kaddr;
  739. int status;
  740. status = ntohl(*p++);
  741. p = xdr_decode_post_op_attr(p, fattr);
  742. if (status != 0)
  743. return -nfs_stat_to_errno(status);
  744. /* Convert length of symlink */
  745. len = ntohl(*p++);
  746. if (len >= rcvbuf->page_len || len <= 0) {
  747. dprintk("nfs: server returned giant symlink!\n");
  748. return -ENAMETOOLONG;
  749. }
  750. hdrlen = (u8 *) p - (u8 *) iov->iov_base;
  751. if (iov->iov_len < hdrlen) {
  752. dprintk("NFS: READLINK reply header overflowed:"
  753. "length %d > %Zu\n", hdrlen, iov->iov_len);
  754. return -errno_NFSERR_IO;
  755. } else if (iov->iov_len != hdrlen) {
  756. dprintk("NFS: READLINK header is short. "
  757. "iovec will be shifted.\n");
  758. xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen);
  759. }
  760. recvd = req->rq_rcv_buf.len - hdrlen;
  761. if (recvd < len) {
  762. dprintk("NFS: server cheating in readlink reply: "
  763. "count %u > recvd %u\n", len, recvd);
  764. return -EIO;
  765. }
  766. /* NULL terminate the string we got */
  767. kaddr = (char*)kmap_atomic(rcvbuf->pages[0], KM_USER0);
  768. kaddr[len+rcvbuf->page_base] = '\0';
  769. kunmap_atomic(kaddr, KM_USER0);
  770. return 0;
  771. }
  772. /*
  773. * Decode READ reply
  774. */
  775. static int
  776. nfs3_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
  777. {
  778. struct kvec *iov = req->rq_rcv_buf.head;
  779. int status, count, ocount, recvd, hdrlen;
  780. status = ntohl(*p++);
  781. p = xdr_decode_post_op_attr(p, res->fattr);
  782. if (status != 0)
  783. return -nfs_stat_to_errno(status);
  784. /* Decode reply could and EOF flag. NFSv3 is somewhat redundant
  785. * in that it puts the count both in the res struct and in the
  786. * opaque data count. */
  787. count = ntohl(*p++);
  788. res->eof = ntohl(*p++);
  789. ocount = ntohl(*p++);
  790. if (ocount != count) {
  791. dprintk("NFS: READ count doesn't match RPC opaque count.\n");
  792. return -errno_NFSERR_IO;
  793. }
  794. hdrlen = (u8 *) p - (u8 *) iov->iov_base;
  795. if (iov->iov_len < hdrlen) {
  796. dprintk("NFS: READ reply header overflowed:"
  797. "length %d > %Zu\n", hdrlen, iov->iov_len);
  798. return -errno_NFSERR_IO;
  799. } else if (iov->iov_len != hdrlen) {
  800. dprintk("NFS: READ header is short. iovec will be shifted.\n");
  801. xdr_shift_buf(&req->rq_rcv_buf, iov->iov_len - hdrlen);
  802. }
  803. recvd = req->rq_rcv_buf.len - hdrlen;
  804. if (count > recvd) {
  805. dprintk("NFS: server cheating in read reply: "
  806. "count %d > recvd %d\n", count, recvd);
  807. count = recvd;
  808. res->eof = 0;
  809. }
  810. if (count < res->count)
  811. res->count = count;
  812. return count;
  813. }
  814. /*
  815. * Decode WRITE response
  816. */
  817. static int
  818. nfs3_xdr_writeres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
  819. {
  820. int status;
  821. status = ntohl(*p++);
  822. p = xdr_decode_wcc_data(p, res->fattr);
  823. if (status != 0)
  824. return -nfs_stat_to_errno(status);
  825. res->count = ntohl(*p++);
  826. res->verf->committed = (enum nfs3_stable_how)ntohl(*p++);
  827. res->verf->verifier[0] = *p++;
  828. res->verf->verifier[1] = *p++;
  829. return res->count;
  830. }
  831. /*
  832. * Decode a CREATE response
  833. */
  834. static int
  835. nfs3_xdr_createres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
  836. {
  837. int status;
  838. status = ntohl(*p++);
  839. if (status == 0) {
  840. if (*p++) {
  841. if (!(p = xdr_decode_fhandle(p, res->fh)))
  842. return -errno_NFSERR_IO;
  843. p = xdr_decode_post_op_attr(p, res->fattr);
  844. } else {
  845. memset(res->fh, 0, sizeof(*res->fh));
  846. /* Do decode post_op_attr but set it to NULL */
  847. p = xdr_decode_post_op_attr(p, res->fattr);
  848. res->fattr->valid = 0;
  849. }
  850. } else {
  851. status = -nfs_stat_to_errno(status);
  852. }
  853. p = xdr_decode_wcc_data(p, res->dir_attr);
  854. return status;
  855. }
  856. /*
  857. * Decode RENAME reply
  858. */
  859. static int
  860. nfs3_xdr_renameres(struct rpc_rqst *req, __be32 *p, struct nfs3_renameres *res)
  861. {
  862. int status;
  863. if ((status = ntohl(*p++)) != 0)
  864. status = -nfs_stat_to_errno(status);
  865. p = xdr_decode_wcc_data(p, res->fromattr);
  866. p = xdr_decode_wcc_data(p, res->toattr);
  867. return status;
  868. }
  869. /*
  870. * Decode LINK reply
  871. */
  872. static int
  873. nfs3_xdr_linkres(struct rpc_rqst *req, __be32 *p, struct nfs3_linkres *res)
  874. {
  875. int status;
  876. if ((status = ntohl(*p++)) != 0)
  877. status = -nfs_stat_to_errno(status);
  878. p = xdr_decode_post_op_attr(p, res->fattr);
  879. p = xdr_decode_wcc_data(p, res->dir_attr);
  880. return status;
  881. }
  882. /*
  883. * Decode FSSTAT reply
  884. */
  885. static int
  886. nfs3_xdr_fsstatres(struct rpc_rqst *req, __be32 *p, struct nfs_fsstat *res)
  887. {
  888. int status;
  889. status = ntohl(*p++);
  890. p = xdr_decode_post_op_attr(p, res->fattr);
  891. if (status != 0)
  892. return -nfs_stat_to_errno(status);
  893. p = xdr_decode_hyper(p, &res->tbytes);
  894. p = xdr_decode_hyper(p, &res->fbytes);
  895. p = xdr_decode_hyper(p, &res->abytes);
  896. p = xdr_decode_hyper(p, &res->tfiles);
  897. p = xdr_decode_hyper(p, &res->ffiles);
  898. p = xdr_decode_hyper(p, &res->afiles);
  899. /* ignore invarsec */
  900. return 0;
  901. }
  902. /*
  903. * Decode FSINFO reply
  904. */
  905. static int
  906. nfs3_xdr_fsinfores(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *res)
  907. {
  908. int status;
  909. status = ntohl(*p++);
  910. p = xdr_decode_post_op_attr(p, res->fattr);
  911. if (status != 0)
  912. return -nfs_stat_to_errno(status);
  913. res->rtmax = ntohl(*p++);
  914. res->rtpref = ntohl(*p++);
  915. res->rtmult = ntohl(*p++);
  916. res->wtmax = ntohl(*p++);
  917. res->wtpref = ntohl(*p++);
  918. res->wtmult = ntohl(*p++);
  919. res->dtpref = ntohl(*p++);
  920. p = xdr_decode_hyper(p, &res->maxfilesize);
  921. /* ignore time_delta and properties */
  922. res->lease_time = 0;
  923. return 0;
  924. }
  925. /*
  926. * Decode PATHCONF reply
  927. */
  928. static int
  929. nfs3_xdr_pathconfres(struct rpc_rqst *req, __be32 *p, struct nfs_pathconf *res)
  930. {
  931. int status;
  932. status = ntohl(*p++);
  933. p = xdr_decode_post_op_attr(p, res->fattr);
  934. if (status != 0)
  935. return -nfs_stat_to_errno(status);
  936. res->max_link = ntohl(*p++);
  937. res->max_namelen = ntohl(*p++);
  938. /* ignore remaining fields */
  939. return 0;
  940. }
  941. /*
  942. * Decode COMMIT reply
  943. */
  944. static int
  945. nfs3_xdr_commitres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
  946. {
  947. int status;
  948. status = ntohl(*p++);
  949. p = xdr_decode_wcc_data(p, res->fattr);
  950. if (status != 0)
  951. return -nfs_stat_to_errno(status);
  952. res->verf->verifier[0] = *p++;
  953. res->verf->verifier[1] = *p++;
  954. return 0;
  955. }
  956. #ifdef CONFIG_NFS_V3_ACL
  957. /*
  958. * Decode GETACL reply
  959. */
  960. static int
  961. nfs3_xdr_getaclres(struct rpc_rqst *req, __be32 *p,
  962. struct nfs3_getaclres *res)
  963. {
  964. struct xdr_buf *buf = &req->rq_rcv_buf;
  965. int status = ntohl(*p++);
  966. struct posix_acl **acl;
  967. unsigned int *aclcnt;
  968. int err, base;
  969. if (status != 0)
  970. return -nfs_stat_to_errno(status);
  971. p = xdr_decode_post_op_attr(p, res->fattr);
  972. res->mask = ntohl(*p++);
  973. if (res->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
  974. return -EINVAL;
  975. base = (char *)p - (char *)req->rq_rcv_buf.head->iov_base;
  976. acl = (res->mask & NFS_ACL) ? &res->acl_access : NULL;
  977. aclcnt = (res->mask & NFS_ACLCNT) ? &res->acl_access_count : NULL;
  978. err = nfsacl_decode(buf, base, aclcnt, acl);
  979. acl = (res->mask & NFS_DFACL) ? &res->acl_default : NULL;
  980. aclcnt = (res->mask & NFS_DFACLCNT) ? &res->acl_default_count : NULL;
  981. if (err > 0)
  982. err = nfsacl_decode(buf, base + err, aclcnt, acl);
  983. return (err > 0) ? 0 : err;
  984. }
  985. /*
  986. * Decode setacl reply.
  987. */
  988. static int
  989. nfs3_xdr_setaclres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  990. {
  991. int status = ntohl(*p++);
  992. if (status)
  993. return -nfs_stat_to_errno(status);
  994. xdr_decode_post_op_attr(p, fattr);
  995. return 0;
  996. }
  997. #endif /* CONFIG_NFS_V3_ACL */
  998. #define PROC(proc, argtype, restype, timer) \
  999. [NFS3PROC_##proc] = { \
  1000. .p_proc = NFS3PROC_##proc, \
  1001. .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \
  1002. .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \
  1003. .p_arglen = NFS3_##argtype##_sz, \
  1004. .p_replen = NFS3_##restype##_sz, \
  1005. .p_timer = timer, \
  1006. .p_statidx = NFS3PROC_##proc, \
  1007. .p_name = #proc, \
  1008. }
  1009. struct rpc_procinfo nfs3_procedures[] = {
  1010. PROC(GETATTR, fhandle, attrstat, 1),
  1011. PROC(SETATTR, sattrargs, wccstat, 0),
  1012. PROC(LOOKUP, diropargs, lookupres, 2),
  1013. PROC(ACCESS, accessargs, accessres, 1),
  1014. PROC(READLINK, readlinkargs, readlinkres, 3),
  1015. PROC(READ, readargs, readres, 3),
  1016. PROC(WRITE, writeargs, writeres, 4),
  1017. PROC(CREATE, createargs, createres, 0),
  1018. PROC(MKDIR, mkdirargs, createres, 0),
  1019. PROC(SYMLINK, symlinkargs, createres, 0),
  1020. PROC(MKNOD, mknodargs, createres, 0),
  1021. PROC(REMOVE, removeargs, removeres, 0),
  1022. PROC(RMDIR, diropargs, wccstat, 0),
  1023. PROC(RENAME, renameargs, renameres, 0),
  1024. PROC(LINK, linkargs, linkres, 0),
  1025. PROC(READDIR, readdirargs, readdirres, 3),
  1026. PROC(READDIRPLUS, readdirargs, readdirres, 3),
  1027. PROC(FSSTAT, fhandle, fsstatres, 0),
  1028. PROC(FSINFO, fhandle, fsinfores, 0),
  1029. PROC(PATHCONF, fhandle, pathconfres, 0),
  1030. PROC(COMMIT, commitargs, commitres, 5),
  1031. };
  1032. struct rpc_version nfs_version3 = {
  1033. .number = 3,
  1034. .nrprocs = ARRAY_SIZE(nfs3_procedures),
  1035. .procs = nfs3_procedures
  1036. };
  1037. #ifdef CONFIG_NFS_V3_ACL
  1038. static struct rpc_procinfo nfs3_acl_procedures[] = {
  1039. [ACLPROC3_GETACL] = {
  1040. .p_proc = ACLPROC3_GETACL,
  1041. .p_encode = (kxdrproc_t) nfs3_xdr_getaclargs,
  1042. .p_decode = (kxdrproc_t) nfs3_xdr_getaclres,
  1043. .p_arglen = ACL3_getaclargs_sz,
  1044. .p_replen = ACL3_getaclres_sz,
  1045. .p_timer = 1,
  1046. .p_name = "GETACL",
  1047. },
  1048. [ACLPROC3_SETACL] = {
  1049. .p_proc = ACLPROC3_SETACL,
  1050. .p_encode = (kxdrproc_t) nfs3_xdr_setaclargs,
  1051. .p_decode = (kxdrproc_t) nfs3_xdr_setaclres,
  1052. .p_arglen = ACL3_setaclargs_sz,
  1053. .p_replen = ACL3_setaclres_sz,
  1054. .p_timer = 0,
  1055. .p_name = "SETACL",
  1056. },
  1057. };
  1058. struct rpc_version nfsacl_version3 = {
  1059. .number = 3,
  1060. .nrprocs = sizeof(nfs3_acl_procedures)/
  1061. sizeof(nfs3_acl_procedures[0]),
  1062. .procs = nfs3_acl_procedures,
  1063. };
  1064. #endif /* CONFIG_NFS_V3_ACL */