nfs3xdr.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  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. return 0;
  318. }
  319. /*
  320. * Write arguments. Splice the buffer to be written into the iovec.
  321. */
  322. static int
  323. nfs3_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
  324. {
  325. struct xdr_buf *sndbuf = &req->rq_snd_buf;
  326. u32 count = args->count;
  327. p = xdr_encode_fhandle(p, args->fh);
  328. p = xdr_encode_hyper(p, args->offset);
  329. *p++ = htonl(count);
  330. *p++ = htonl(args->stable);
  331. *p++ = htonl(count);
  332. sndbuf->len = xdr_adjust_iovec(sndbuf->head, p);
  333. /* Copy the page array */
  334. xdr_encode_pages(sndbuf, args->pages, args->pgbase, count);
  335. return 0;
  336. }
  337. /*
  338. * Encode CREATE arguments
  339. */
  340. static int
  341. nfs3_xdr_createargs(struct rpc_rqst *req, __be32 *p, struct nfs3_createargs *args)
  342. {
  343. p = xdr_encode_fhandle(p, args->fh);
  344. p = xdr_encode_array(p, args->name, args->len);
  345. *p++ = htonl(args->createmode);
  346. if (args->createmode == NFS3_CREATE_EXCLUSIVE) {
  347. *p++ = args->verifier[0];
  348. *p++ = args->verifier[1];
  349. } else
  350. p = xdr_encode_sattr(p, args->sattr);
  351. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  352. return 0;
  353. }
  354. /*
  355. * Encode MKDIR arguments
  356. */
  357. static int
  358. nfs3_xdr_mkdirargs(struct rpc_rqst *req, __be32 *p, struct nfs3_mkdirargs *args)
  359. {
  360. p = xdr_encode_fhandle(p, args->fh);
  361. p = xdr_encode_array(p, args->name, args->len);
  362. p = xdr_encode_sattr(p, args->sattr);
  363. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  364. return 0;
  365. }
  366. /*
  367. * Encode SYMLINK arguments
  368. */
  369. static int
  370. nfs3_xdr_symlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_symlinkargs *args)
  371. {
  372. p = xdr_encode_fhandle(p, args->fromfh);
  373. p = xdr_encode_array(p, args->fromname, args->fromlen);
  374. p = xdr_encode_sattr(p, args->sattr);
  375. *p++ = htonl(args->pathlen);
  376. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  377. /* Copy the page */
  378. xdr_encode_pages(&req->rq_snd_buf, args->pages, 0, args->pathlen);
  379. return 0;
  380. }
  381. /*
  382. * Encode MKNOD arguments
  383. */
  384. static int
  385. nfs3_xdr_mknodargs(struct rpc_rqst *req, __be32 *p, struct nfs3_mknodargs *args)
  386. {
  387. p = xdr_encode_fhandle(p, args->fh);
  388. p = xdr_encode_array(p, args->name, args->len);
  389. *p++ = htonl(args->type);
  390. p = xdr_encode_sattr(p, args->sattr);
  391. if (args->type == NF3CHR || args->type == NF3BLK) {
  392. *p++ = htonl(MAJOR(args->rdev));
  393. *p++ = htonl(MINOR(args->rdev));
  394. }
  395. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  396. return 0;
  397. }
  398. /*
  399. * Encode RENAME arguments
  400. */
  401. static int
  402. nfs3_xdr_renameargs(struct rpc_rqst *req, __be32 *p, struct nfs3_renameargs *args)
  403. {
  404. p = xdr_encode_fhandle(p, args->fromfh);
  405. p = xdr_encode_array(p, args->fromname, args->fromlen);
  406. p = xdr_encode_fhandle(p, args->tofh);
  407. p = xdr_encode_array(p, args->toname, args->tolen);
  408. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  409. return 0;
  410. }
  411. /*
  412. * Encode LINK arguments
  413. */
  414. static int
  415. nfs3_xdr_linkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_linkargs *args)
  416. {
  417. p = xdr_encode_fhandle(p, args->fromfh);
  418. p = xdr_encode_fhandle(p, args->tofh);
  419. p = xdr_encode_array(p, args->toname, args->tolen);
  420. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  421. return 0;
  422. }
  423. /*
  424. * Encode arguments to readdir call
  425. */
  426. static int
  427. nfs3_xdr_readdirargs(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirargs *args)
  428. {
  429. struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
  430. unsigned int replen;
  431. u32 count = args->count;
  432. p = xdr_encode_fhandle(p, args->fh);
  433. p = xdr_encode_hyper(p, args->cookie);
  434. *p++ = args->verf[0];
  435. *p++ = args->verf[1];
  436. if (args->plus) {
  437. /* readdirplus: need dircount + buffer size.
  438. * We just make sure we make dircount big enough */
  439. *p++ = htonl(count >> 3);
  440. }
  441. *p++ = htonl(count);
  442. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  443. /* Inline the page array */
  444. replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS3_readdirres_sz) << 2;
  445. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, 0, count);
  446. return 0;
  447. }
  448. /*
  449. * Decode the result of a readdir call.
  450. * We just check for syntactical correctness.
  451. */
  452. static int
  453. nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res)
  454. {
  455. struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
  456. struct kvec *iov = rcvbuf->head;
  457. struct page **page;
  458. int hdrlen, recvd;
  459. int status, nr;
  460. unsigned int len, pglen;
  461. __be32 *entry, *end, *kaddr;
  462. status = ntohl(*p++);
  463. /* Decode post_op_attrs */
  464. p = xdr_decode_post_op_attr(p, res->dir_attr);
  465. if (status)
  466. return -nfs_stat_to_errno(status);
  467. /* Decode verifier cookie */
  468. if (res->verf) {
  469. res->verf[0] = *p++;
  470. res->verf[1] = *p++;
  471. } else {
  472. p += 2;
  473. }
  474. hdrlen = (u8 *) p - (u8 *) iov->iov_base;
  475. if (iov->iov_len < hdrlen) {
  476. printk(KERN_WARNING "NFS: READDIR reply header overflowed:"
  477. "length %d > %Zu\n", hdrlen, iov->iov_len);
  478. return -errno_NFSERR_IO;
  479. } else if (iov->iov_len != hdrlen) {
  480. dprintk("NFS: READDIR header is short. iovec will be shifted.\n");
  481. xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen);
  482. }
  483. pglen = rcvbuf->page_len;
  484. recvd = rcvbuf->len - hdrlen;
  485. if (pglen > recvd)
  486. pglen = recvd;
  487. page = rcvbuf->pages;
  488. kaddr = p = kmap_atomic(*page, KM_USER0);
  489. end = (__be32 *)((char *)p + pglen);
  490. entry = p;
  491. for (nr = 0; *p++; nr++) {
  492. if (p + 3 > end)
  493. goto short_pkt;
  494. p += 2; /* inode # */
  495. len = ntohl(*p++); /* string length */
  496. p += XDR_QUADLEN(len) + 2; /* name + cookie */
  497. if (len > NFS3_MAXNAMLEN) {
  498. printk(KERN_WARNING "NFS: giant filename in readdir (len %x)!\n",
  499. len);
  500. goto err_unmap;
  501. }
  502. if (res->plus) {
  503. /* post_op_attr */
  504. if (p + 2 > end)
  505. goto short_pkt;
  506. if (*p++) {
  507. p += 21;
  508. if (p + 1 > end)
  509. goto short_pkt;
  510. }
  511. /* post_op_fh3 */
  512. if (*p++) {
  513. if (p + 1 > end)
  514. goto short_pkt;
  515. len = ntohl(*p++);
  516. if (len > NFS3_FHSIZE) {
  517. printk(KERN_WARNING "NFS: giant filehandle in "
  518. "readdir (len %x)!\n", len);
  519. goto err_unmap;
  520. }
  521. p += XDR_QUADLEN(len);
  522. }
  523. }
  524. if (p + 2 > end)
  525. goto short_pkt;
  526. entry = p;
  527. }
  528. if (!nr && (entry[0] != 0 || entry[1] == 0))
  529. goto short_pkt;
  530. out:
  531. kunmap_atomic(kaddr, KM_USER0);
  532. return nr;
  533. short_pkt:
  534. entry[0] = entry[1] = 0;
  535. /* truncate listing ? */
  536. if (!nr) {
  537. printk(KERN_NOTICE "NFS: readdir reply truncated!\n");
  538. entry[1] = 1;
  539. }
  540. goto out;
  541. err_unmap:
  542. nr = -errno_NFSERR_IO;
  543. goto out;
  544. }
  545. __be32 *
  546. nfs3_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus)
  547. {
  548. struct nfs_entry old = *entry;
  549. if (!*p++) {
  550. if (!*p)
  551. return ERR_PTR(-EAGAIN);
  552. entry->eof = 1;
  553. return ERR_PTR(-EBADCOOKIE);
  554. }
  555. p = xdr_decode_hyper(p, &entry->ino);
  556. entry->len = ntohl(*p++);
  557. entry->name = (const char *) p;
  558. p += XDR_QUADLEN(entry->len);
  559. entry->prev_cookie = entry->cookie;
  560. p = xdr_decode_hyper(p, &entry->cookie);
  561. if (plus) {
  562. entry->fattr->valid = 0;
  563. p = xdr_decode_post_op_attr(p, entry->fattr);
  564. /* In fact, a post_op_fh3: */
  565. if (*p++) {
  566. p = xdr_decode_fhandle(p, entry->fh);
  567. /* Ugh -- server reply was truncated */
  568. if (p == NULL) {
  569. dprintk("NFS: FH truncated\n");
  570. *entry = old;
  571. return ERR_PTR(-EAGAIN);
  572. }
  573. } else
  574. memset((u8*)(entry->fh), 0, sizeof(*entry->fh));
  575. }
  576. entry->eof = !p[0] && p[1];
  577. return p;
  578. }
  579. /*
  580. * Encode COMMIT arguments
  581. */
  582. static int
  583. nfs3_xdr_commitargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
  584. {
  585. p = xdr_encode_fhandle(p, args->fh);
  586. p = xdr_encode_hyper(p, args->offset);
  587. *p++ = htonl(args->count);
  588. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  589. return 0;
  590. }
  591. #ifdef CONFIG_NFS_V3_ACL
  592. /*
  593. * Encode GETACL arguments
  594. */
  595. static int
  596. nfs3_xdr_getaclargs(struct rpc_rqst *req, __be32 *p,
  597. struct nfs3_getaclargs *args)
  598. {
  599. struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
  600. unsigned int replen;
  601. p = xdr_encode_fhandle(p, args->fh);
  602. *p++ = htonl(args->mask);
  603. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  604. if (args->mask & (NFS_ACL | NFS_DFACL)) {
  605. /* Inline the page array */
  606. replen = (RPC_REPHDRSIZE + auth->au_rslack +
  607. ACL3_getaclres_sz) << 2;
  608. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, 0,
  609. NFSACL_MAXPAGES << PAGE_SHIFT);
  610. }
  611. return 0;
  612. }
  613. /*
  614. * Encode SETACL arguments
  615. */
  616. static int
  617. nfs3_xdr_setaclargs(struct rpc_rqst *req, __be32 *p,
  618. struct nfs3_setaclargs *args)
  619. {
  620. struct xdr_buf *buf = &req->rq_snd_buf;
  621. unsigned int base, len_in_head, len = nfsacl_size(
  622. (args->mask & NFS_ACL) ? args->acl_access : NULL,
  623. (args->mask & NFS_DFACL) ? args->acl_default : NULL);
  624. int count, err;
  625. p = xdr_encode_fhandle(p, NFS_FH(args->inode));
  626. *p++ = htonl(args->mask);
  627. base = (char *)p - (char *)buf->head->iov_base;
  628. /* put as much of the acls into head as possible. */
  629. len_in_head = min_t(unsigned int, buf->head->iov_len - base, len);
  630. len -= len_in_head;
  631. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p + (len_in_head >> 2));
  632. for (count = 0; (count << PAGE_SHIFT) < len; count++) {
  633. args->pages[count] = alloc_page(GFP_KERNEL);
  634. if (!args->pages[count]) {
  635. while (count)
  636. __free_page(args->pages[--count]);
  637. return -ENOMEM;
  638. }
  639. }
  640. xdr_encode_pages(buf, args->pages, 0, len);
  641. err = nfsacl_encode(buf, base, args->inode,
  642. (args->mask & NFS_ACL) ?
  643. args->acl_access : NULL, 1, 0);
  644. if (err > 0)
  645. err = nfsacl_encode(buf, base + err, args->inode,
  646. (args->mask & NFS_DFACL) ?
  647. args->acl_default : NULL, 1,
  648. NFS_ACL_DEFAULT);
  649. return (err > 0) ? 0 : err;
  650. }
  651. #endif /* CONFIG_NFS_V3_ACL */
  652. /*
  653. * NFS XDR decode functions
  654. */
  655. /*
  656. * Decode attrstat reply.
  657. */
  658. static int
  659. nfs3_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  660. {
  661. int status;
  662. if ((status = ntohl(*p++)))
  663. return -nfs_stat_to_errno(status);
  664. xdr_decode_fattr(p, fattr);
  665. return 0;
  666. }
  667. /*
  668. * Decode status+wcc_data reply
  669. * SATTR, REMOVE, RMDIR
  670. */
  671. static int
  672. nfs3_xdr_wccstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  673. {
  674. int status;
  675. if ((status = ntohl(*p++)))
  676. status = -nfs_stat_to_errno(status);
  677. xdr_decode_wcc_data(p, fattr);
  678. return status;
  679. }
  680. static int
  681. nfs3_xdr_removeres(struct rpc_rqst *req, __be32 *p, struct nfs_removeres *res)
  682. {
  683. return nfs3_xdr_wccstat(req, p, &res->dir_attr);
  684. }
  685. /*
  686. * Decode LOOKUP reply
  687. */
  688. static int
  689. nfs3_xdr_lookupres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
  690. {
  691. int status;
  692. if ((status = ntohl(*p++))) {
  693. status = -nfs_stat_to_errno(status);
  694. } else {
  695. if (!(p = xdr_decode_fhandle(p, res->fh)))
  696. return -errno_NFSERR_IO;
  697. p = xdr_decode_post_op_attr(p, res->fattr);
  698. }
  699. xdr_decode_post_op_attr(p, res->dir_attr);
  700. return status;
  701. }
  702. /*
  703. * Decode ACCESS reply
  704. */
  705. static int
  706. nfs3_xdr_accessres(struct rpc_rqst *req, __be32 *p, struct nfs3_accessres *res)
  707. {
  708. int status = ntohl(*p++);
  709. p = xdr_decode_post_op_attr(p, res->fattr);
  710. if (status)
  711. return -nfs_stat_to_errno(status);
  712. res->access = ntohl(*p++);
  713. return 0;
  714. }
  715. static int
  716. nfs3_xdr_readlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_readlinkargs *args)
  717. {
  718. struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
  719. unsigned int replen;
  720. p = xdr_encode_fhandle(p, args->fh);
  721. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  722. /* Inline the page array */
  723. replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS3_readlinkres_sz) << 2;
  724. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, args->pgbase, args->pglen);
  725. return 0;
  726. }
  727. /*
  728. * Decode READLINK reply
  729. */
  730. static int
  731. nfs3_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  732. {
  733. struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
  734. struct kvec *iov = rcvbuf->head;
  735. int hdrlen, len, recvd;
  736. char *kaddr;
  737. int status;
  738. status = ntohl(*p++);
  739. p = xdr_decode_post_op_attr(p, fattr);
  740. if (status != 0)
  741. return -nfs_stat_to_errno(status);
  742. /* Convert length of symlink */
  743. len = ntohl(*p++);
  744. if (len >= rcvbuf->page_len || len <= 0) {
  745. dprintk(KERN_WARNING "nfs: server returned giant symlink!\n");
  746. return -ENAMETOOLONG;
  747. }
  748. hdrlen = (u8 *) p - (u8 *) iov->iov_base;
  749. if (iov->iov_len < hdrlen) {
  750. printk(KERN_WARNING "NFS: READLINK reply header overflowed:"
  751. "length %d > %Zu\n", hdrlen, iov->iov_len);
  752. return -errno_NFSERR_IO;
  753. } else if (iov->iov_len != hdrlen) {
  754. dprintk("NFS: READLINK header is short. iovec will be shifted.\n");
  755. xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen);
  756. }
  757. recvd = req->rq_rcv_buf.len - hdrlen;
  758. if (recvd < len) {
  759. printk(KERN_WARNING "NFS: server cheating in readlink reply: "
  760. "count %u > recvd %u\n", len, recvd);
  761. return -EIO;
  762. }
  763. /* NULL terminate the string we got */
  764. kaddr = (char*)kmap_atomic(rcvbuf->pages[0], KM_USER0);
  765. kaddr[len+rcvbuf->page_base] = '\0';
  766. kunmap_atomic(kaddr, KM_USER0);
  767. return 0;
  768. }
  769. /*
  770. * Decode READ reply
  771. */
  772. static int
  773. nfs3_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
  774. {
  775. struct kvec *iov = req->rq_rcv_buf.head;
  776. int status, count, ocount, recvd, hdrlen;
  777. status = ntohl(*p++);
  778. p = xdr_decode_post_op_attr(p, res->fattr);
  779. if (status != 0)
  780. return -nfs_stat_to_errno(status);
  781. /* Decode reply could and EOF flag. NFSv3 is somewhat redundant
  782. * in that it puts the count both in the res struct and in the
  783. * opaque data count. */
  784. count = ntohl(*p++);
  785. res->eof = ntohl(*p++);
  786. ocount = ntohl(*p++);
  787. if (ocount != count) {
  788. printk(KERN_WARNING "NFS: READ count doesn't match RPC opaque count.\n");
  789. return -errno_NFSERR_IO;
  790. }
  791. hdrlen = (u8 *) p - (u8 *) iov->iov_base;
  792. if (iov->iov_len < hdrlen) {
  793. printk(KERN_WARNING "NFS: READ reply header overflowed:"
  794. "length %d > %Zu\n", hdrlen, iov->iov_len);
  795. return -errno_NFSERR_IO;
  796. } else if (iov->iov_len != hdrlen) {
  797. dprintk("NFS: READ header is short. iovec will be shifted.\n");
  798. xdr_shift_buf(&req->rq_rcv_buf, iov->iov_len - hdrlen);
  799. }
  800. recvd = req->rq_rcv_buf.len - hdrlen;
  801. if (count > recvd) {
  802. printk(KERN_WARNING "NFS: server cheating in read reply: "
  803. "count %d > recvd %d\n", count, recvd);
  804. count = recvd;
  805. res->eof = 0;
  806. }
  807. if (count < res->count)
  808. res->count = count;
  809. return count;
  810. }
  811. /*
  812. * Decode WRITE response
  813. */
  814. static int
  815. nfs3_xdr_writeres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
  816. {
  817. int status;
  818. status = ntohl(*p++);
  819. p = xdr_decode_wcc_data(p, res->fattr);
  820. if (status != 0)
  821. return -nfs_stat_to_errno(status);
  822. res->count = ntohl(*p++);
  823. res->verf->committed = (enum nfs3_stable_how)ntohl(*p++);
  824. res->verf->verifier[0] = *p++;
  825. res->verf->verifier[1] = *p++;
  826. return res->count;
  827. }
  828. /*
  829. * Decode a CREATE response
  830. */
  831. static int
  832. nfs3_xdr_createres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
  833. {
  834. int status;
  835. status = ntohl(*p++);
  836. if (status == 0) {
  837. if (*p++) {
  838. if (!(p = xdr_decode_fhandle(p, res->fh)))
  839. return -errno_NFSERR_IO;
  840. p = xdr_decode_post_op_attr(p, res->fattr);
  841. } else {
  842. memset(res->fh, 0, sizeof(*res->fh));
  843. /* Do decode post_op_attr but set it to NULL */
  844. p = xdr_decode_post_op_attr(p, res->fattr);
  845. res->fattr->valid = 0;
  846. }
  847. } else {
  848. status = -nfs_stat_to_errno(status);
  849. }
  850. p = xdr_decode_wcc_data(p, res->dir_attr);
  851. return status;
  852. }
  853. /*
  854. * Decode RENAME reply
  855. */
  856. static int
  857. nfs3_xdr_renameres(struct rpc_rqst *req, __be32 *p, struct nfs3_renameres *res)
  858. {
  859. int status;
  860. if ((status = ntohl(*p++)) != 0)
  861. status = -nfs_stat_to_errno(status);
  862. p = xdr_decode_wcc_data(p, res->fromattr);
  863. p = xdr_decode_wcc_data(p, res->toattr);
  864. return status;
  865. }
  866. /*
  867. * Decode LINK reply
  868. */
  869. static int
  870. nfs3_xdr_linkres(struct rpc_rqst *req, __be32 *p, struct nfs3_linkres *res)
  871. {
  872. int status;
  873. if ((status = ntohl(*p++)) != 0)
  874. status = -nfs_stat_to_errno(status);
  875. p = xdr_decode_post_op_attr(p, res->fattr);
  876. p = xdr_decode_wcc_data(p, res->dir_attr);
  877. return status;
  878. }
  879. /*
  880. * Decode FSSTAT reply
  881. */
  882. static int
  883. nfs3_xdr_fsstatres(struct rpc_rqst *req, __be32 *p, struct nfs_fsstat *res)
  884. {
  885. int status;
  886. status = ntohl(*p++);
  887. p = xdr_decode_post_op_attr(p, res->fattr);
  888. if (status != 0)
  889. return -nfs_stat_to_errno(status);
  890. p = xdr_decode_hyper(p, &res->tbytes);
  891. p = xdr_decode_hyper(p, &res->fbytes);
  892. p = xdr_decode_hyper(p, &res->abytes);
  893. p = xdr_decode_hyper(p, &res->tfiles);
  894. p = xdr_decode_hyper(p, &res->ffiles);
  895. p = xdr_decode_hyper(p, &res->afiles);
  896. /* ignore invarsec */
  897. return 0;
  898. }
  899. /*
  900. * Decode FSINFO reply
  901. */
  902. static int
  903. nfs3_xdr_fsinfores(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *res)
  904. {
  905. int status;
  906. status = ntohl(*p++);
  907. p = xdr_decode_post_op_attr(p, res->fattr);
  908. if (status != 0)
  909. return -nfs_stat_to_errno(status);
  910. res->rtmax = ntohl(*p++);
  911. res->rtpref = ntohl(*p++);
  912. res->rtmult = ntohl(*p++);
  913. res->wtmax = ntohl(*p++);
  914. res->wtpref = ntohl(*p++);
  915. res->wtmult = ntohl(*p++);
  916. res->dtpref = ntohl(*p++);
  917. p = xdr_decode_hyper(p, &res->maxfilesize);
  918. /* ignore time_delta and properties */
  919. res->lease_time = 0;
  920. return 0;
  921. }
  922. /*
  923. * Decode PATHCONF reply
  924. */
  925. static int
  926. nfs3_xdr_pathconfres(struct rpc_rqst *req, __be32 *p, struct nfs_pathconf *res)
  927. {
  928. int status;
  929. status = ntohl(*p++);
  930. p = xdr_decode_post_op_attr(p, res->fattr);
  931. if (status != 0)
  932. return -nfs_stat_to_errno(status);
  933. res->max_link = ntohl(*p++);
  934. res->max_namelen = ntohl(*p++);
  935. /* ignore remaining fields */
  936. return 0;
  937. }
  938. /*
  939. * Decode COMMIT reply
  940. */
  941. static int
  942. nfs3_xdr_commitres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
  943. {
  944. int status;
  945. status = ntohl(*p++);
  946. p = xdr_decode_wcc_data(p, res->fattr);
  947. if (status != 0)
  948. return -nfs_stat_to_errno(status);
  949. res->verf->verifier[0] = *p++;
  950. res->verf->verifier[1] = *p++;
  951. return 0;
  952. }
  953. #ifdef CONFIG_NFS_V3_ACL
  954. /*
  955. * Decode GETACL reply
  956. */
  957. static int
  958. nfs3_xdr_getaclres(struct rpc_rqst *req, __be32 *p,
  959. struct nfs3_getaclres *res)
  960. {
  961. struct xdr_buf *buf = &req->rq_rcv_buf;
  962. int status = ntohl(*p++);
  963. struct posix_acl **acl;
  964. unsigned int *aclcnt;
  965. int err, base;
  966. if (status != 0)
  967. return -nfs_stat_to_errno(status);
  968. p = xdr_decode_post_op_attr(p, res->fattr);
  969. res->mask = ntohl(*p++);
  970. if (res->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
  971. return -EINVAL;
  972. base = (char *)p - (char *)req->rq_rcv_buf.head->iov_base;
  973. acl = (res->mask & NFS_ACL) ? &res->acl_access : NULL;
  974. aclcnt = (res->mask & NFS_ACLCNT) ? &res->acl_access_count : NULL;
  975. err = nfsacl_decode(buf, base, aclcnt, acl);
  976. acl = (res->mask & NFS_DFACL) ? &res->acl_default : NULL;
  977. aclcnt = (res->mask & NFS_DFACLCNT) ? &res->acl_default_count : NULL;
  978. if (err > 0)
  979. err = nfsacl_decode(buf, base + err, aclcnt, acl);
  980. return (err > 0) ? 0 : err;
  981. }
  982. /*
  983. * Decode setacl reply.
  984. */
  985. static int
  986. nfs3_xdr_setaclres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  987. {
  988. int status = ntohl(*p++);
  989. if (status)
  990. return -nfs_stat_to_errno(status);
  991. xdr_decode_post_op_attr(p, fattr);
  992. return 0;
  993. }
  994. #endif /* CONFIG_NFS_V3_ACL */
  995. #define PROC(proc, argtype, restype, timer) \
  996. [NFS3PROC_##proc] = { \
  997. .p_proc = NFS3PROC_##proc, \
  998. .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \
  999. .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \
  1000. .p_arglen = NFS3_##argtype##_sz, \
  1001. .p_replen = NFS3_##restype##_sz, \
  1002. .p_timer = timer, \
  1003. .p_statidx = NFS3PROC_##proc, \
  1004. .p_name = #proc, \
  1005. }
  1006. struct rpc_procinfo nfs3_procedures[] = {
  1007. PROC(GETATTR, fhandle, attrstat, 1),
  1008. PROC(SETATTR, sattrargs, wccstat, 0),
  1009. PROC(LOOKUP, diropargs, lookupres, 2),
  1010. PROC(ACCESS, accessargs, accessres, 1),
  1011. PROC(READLINK, readlinkargs, readlinkres, 3),
  1012. PROC(READ, readargs, readres, 3),
  1013. PROC(WRITE, writeargs, writeres, 4),
  1014. PROC(CREATE, createargs, createres, 0),
  1015. PROC(MKDIR, mkdirargs, createres, 0),
  1016. PROC(SYMLINK, symlinkargs, createres, 0),
  1017. PROC(MKNOD, mknodargs, createres, 0),
  1018. PROC(REMOVE, removeargs, removeres, 0),
  1019. PROC(RMDIR, diropargs, wccstat, 0),
  1020. PROC(RENAME, renameargs, renameres, 0),
  1021. PROC(LINK, linkargs, linkres, 0),
  1022. PROC(READDIR, readdirargs, readdirres, 3),
  1023. PROC(READDIRPLUS, readdirargs, readdirres, 3),
  1024. PROC(FSSTAT, fhandle, fsstatres, 0),
  1025. PROC(FSINFO, fhandle, fsinfores, 0),
  1026. PROC(PATHCONF, fhandle, pathconfres, 0),
  1027. PROC(COMMIT, commitargs, commitres, 5),
  1028. };
  1029. struct rpc_version nfs_version3 = {
  1030. .number = 3,
  1031. .nrprocs = ARRAY_SIZE(nfs3_procedures),
  1032. .procs = nfs3_procedures
  1033. };
  1034. #ifdef CONFIG_NFS_V3_ACL
  1035. static struct rpc_procinfo nfs3_acl_procedures[] = {
  1036. [ACLPROC3_GETACL] = {
  1037. .p_proc = ACLPROC3_GETACL,
  1038. .p_encode = (kxdrproc_t) nfs3_xdr_getaclargs,
  1039. .p_decode = (kxdrproc_t) nfs3_xdr_getaclres,
  1040. .p_arglen = ACL3_getaclargs_sz,
  1041. .p_replen = ACL3_getaclres_sz,
  1042. .p_timer = 1,
  1043. .p_name = "GETACL",
  1044. },
  1045. [ACLPROC3_SETACL] = {
  1046. .p_proc = ACLPROC3_SETACL,
  1047. .p_encode = (kxdrproc_t) nfs3_xdr_setaclargs,
  1048. .p_decode = (kxdrproc_t) nfs3_xdr_setaclres,
  1049. .p_arglen = ACL3_setaclargs_sz,
  1050. .p_replen = ACL3_setaclres_sz,
  1051. .p_timer = 0,
  1052. .p_name = "SETACL",
  1053. },
  1054. };
  1055. struct rpc_version nfsacl_version3 = {
  1056. .number = 3,
  1057. .nrprocs = sizeof(nfs3_acl_procedures)/
  1058. sizeof(nfs3_acl_procedures[0]),
  1059. .procs = nfs3_acl_procedures,
  1060. };
  1061. #endif /* CONFIG_NFS_V3_ACL */