nfs3xdr.c 29 KB

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