nfs3xdr.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  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. entry->d_type = DT_UNKNOWN;
  562. if (plus) {
  563. entry->fattr->valid = 0;
  564. p = xdr_decode_post_op_attr_stream(xdr, entry->fattr);
  565. if (IS_ERR(p))
  566. goto out_overflow_exit;
  567. entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
  568. /* In fact, a post_op_fh3: */
  569. p = xdr_inline_decode(xdr, 4);
  570. if (unlikely(!p))
  571. goto out_overflow;
  572. if (*p++) {
  573. p = xdr_decode_fhandle_stream(xdr, entry->fh);
  574. if (IS_ERR(p))
  575. goto out_overflow_exit;
  576. /* Ugh -- server reply was truncated */
  577. if (p == NULL) {
  578. dprintk("NFS: FH truncated\n");
  579. *entry = old;
  580. return ERR_PTR(-EAGAIN);
  581. }
  582. } else
  583. memset((u8*)(entry->fh), 0, sizeof(*entry->fh));
  584. }
  585. return p;
  586. out_overflow:
  587. print_overflow_msg(__func__, xdr);
  588. out_overflow_exit:
  589. return ERR_PTR(-EAGAIN);
  590. }
  591. /*
  592. * Encode COMMIT arguments
  593. */
  594. static int
  595. nfs3_xdr_commitargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
  596. {
  597. p = xdr_encode_fhandle(p, args->fh);
  598. p = xdr_encode_hyper(p, args->offset);
  599. *p++ = htonl(args->count);
  600. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  601. return 0;
  602. }
  603. #ifdef CONFIG_NFS_V3_ACL
  604. /*
  605. * Encode GETACL arguments
  606. */
  607. static int
  608. nfs3_xdr_getaclargs(struct rpc_rqst *req, __be32 *p,
  609. struct nfs3_getaclargs *args)
  610. {
  611. struct rpc_auth *auth = req->rq_cred->cr_auth;
  612. unsigned int replen;
  613. p = xdr_encode_fhandle(p, args->fh);
  614. *p++ = htonl(args->mask);
  615. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  616. if (args->mask & (NFS_ACL | NFS_DFACL)) {
  617. /* Inline the page array */
  618. replen = (RPC_REPHDRSIZE + auth->au_rslack +
  619. ACL3_getaclres_sz) << 2;
  620. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, 0,
  621. NFSACL_MAXPAGES << PAGE_SHIFT);
  622. }
  623. return 0;
  624. }
  625. /*
  626. * Encode SETACL arguments
  627. */
  628. static int
  629. nfs3_xdr_setaclargs(struct rpc_rqst *req, __be32 *p,
  630. struct nfs3_setaclargs *args)
  631. {
  632. struct xdr_buf *buf = &req->rq_snd_buf;
  633. unsigned int base;
  634. int err;
  635. p = xdr_encode_fhandle(p, NFS_FH(args->inode));
  636. *p++ = htonl(args->mask);
  637. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  638. base = req->rq_slen;
  639. if (args->npages != 0)
  640. xdr_encode_pages(buf, args->pages, 0, args->len);
  641. else
  642. req->rq_slen = xdr_adjust_iovec(req->rq_svec,
  643. p + XDR_QUADLEN(args->len));
  644. err = nfsacl_encode(buf, base, args->inode,
  645. (args->mask & NFS_ACL) ?
  646. args->acl_access : NULL, 1, 0);
  647. if (err > 0)
  648. err = nfsacl_encode(buf, base + err, args->inode,
  649. (args->mask & NFS_DFACL) ?
  650. args->acl_default : NULL, 1,
  651. NFS_ACL_DEFAULT);
  652. return (err > 0) ? 0 : err;
  653. }
  654. #endif /* CONFIG_NFS_V3_ACL */
  655. /*
  656. * NFS XDR decode functions
  657. */
  658. /*
  659. * Decode attrstat reply.
  660. */
  661. static int
  662. nfs3_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  663. {
  664. int status;
  665. if ((status = ntohl(*p++)))
  666. return nfs_stat_to_errno(status);
  667. xdr_decode_fattr(p, fattr);
  668. return 0;
  669. }
  670. /*
  671. * Decode status+wcc_data reply
  672. * SATTR, REMOVE, RMDIR
  673. */
  674. static int
  675. nfs3_xdr_wccstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  676. {
  677. int status;
  678. if ((status = ntohl(*p++)))
  679. status = nfs_stat_to_errno(status);
  680. xdr_decode_wcc_data(p, fattr);
  681. return status;
  682. }
  683. static int
  684. nfs3_xdr_removeres(struct rpc_rqst *req, __be32 *p, struct nfs_removeres *res)
  685. {
  686. return nfs3_xdr_wccstat(req, p, res->dir_attr);
  687. }
  688. /*
  689. * Decode LOOKUP reply
  690. */
  691. static int
  692. nfs3_xdr_lookupres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
  693. {
  694. int status;
  695. if ((status = ntohl(*p++))) {
  696. status = nfs_stat_to_errno(status);
  697. } else {
  698. if (!(p = xdr_decode_fhandle(p, res->fh)))
  699. return -errno_NFSERR_IO;
  700. p = xdr_decode_post_op_attr(p, res->fattr);
  701. }
  702. xdr_decode_post_op_attr(p, res->dir_attr);
  703. return status;
  704. }
  705. /*
  706. * Decode ACCESS reply
  707. */
  708. static int
  709. nfs3_xdr_accessres(struct rpc_rqst *req, __be32 *p, struct nfs3_accessres *res)
  710. {
  711. int status = ntohl(*p++);
  712. p = xdr_decode_post_op_attr(p, res->fattr);
  713. if (status)
  714. return nfs_stat_to_errno(status);
  715. res->access = ntohl(*p++);
  716. return 0;
  717. }
  718. static int
  719. nfs3_xdr_readlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_readlinkargs *args)
  720. {
  721. struct rpc_auth *auth = req->rq_cred->cr_auth;
  722. unsigned int replen;
  723. p = xdr_encode_fhandle(p, args->fh);
  724. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  725. /* Inline the page array */
  726. replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS3_readlinkres_sz) << 2;
  727. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, args->pgbase, args->pglen);
  728. return 0;
  729. }
  730. /*
  731. * Decode READLINK reply
  732. */
  733. static int
  734. nfs3_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  735. {
  736. struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
  737. struct kvec *iov = rcvbuf->head;
  738. size_t hdrlen;
  739. u32 len, recvd;
  740. int status;
  741. status = ntohl(*p++);
  742. p = xdr_decode_post_op_attr(p, fattr);
  743. if (status != 0)
  744. return nfs_stat_to_errno(status);
  745. /* Convert length of symlink */
  746. len = ntohl(*p++);
  747. if (len >= rcvbuf->page_len) {
  748. dprintk("nfs: server returned giant symlink!\n");
  749. return -ENAMETOOLONG;
  750. }
  751. hdrlen = (u8 *) p - (u8 *) iov->iov_base;
  752. if (iov->iov_len < hdrlen) {
  753. dprintk("NFS: READLINK reply header overflowed:"
  754. "length %Zu > %Zu\n", hdrlen, iov->iov_len);
  755. return -errno_NFSERR_IO;
  756. } else if (iov->iov_len != hdrlen) {
  757. dprintk("NFS: READLINK header is short. "
  758. "iovec will be shifted.\n");
  759. xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen);
  760. }
  761. recvd = req->rq_rcv_buf.len - hdrlen;
  762. if (recvd < len) {
  763. dprintk("NFS: server cheating in readlink reply: "
  764. "count %u > recvd %u\n", len, recvd);
  765. return -EIO;
  766. }
  767. xdr_terminate_string(rcvbuf, len);
  768. return 0;
  769. }
  770. /*
  771. * Decode READ reply
  772. */
  773. static int
  774. nfs3_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
  775. {
  776. struct kvec *iov = req->rq_rcv_buf.head;
  777. size_t hdrlen;
  778. u32 count, ocount, recvd;
  779. int status;
  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 count 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 %Zu > %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 %u > recvd %u\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 nfs_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->old_fattr);
  866. p = xdr_decode_wcc_data(p, res->new_fattr);
  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. p = xdr_decode_time3(p, &res->time_delta);
  922. /* ignore properties */
  923. res->lease_time = 0;
  924. return 0;
  925. }
  926. /*
  927. * Decode PATHCONF reply
  928. */
  929. static int
  930. nfs3_xdr_pathconfres(struct rpc_rqst *req, __be32 *p, struct nfs_pathconf *res)
  931. {
  932. int status;
  933. status = ntohl(*p++);
  934. p = xdr_decode_post_op_attr(p, res->fattr);
  935. if (status != 0)
  936. return nfs_stat_to_errno(status);
  937. res->max_link = ntohl(*p++);
  938. res->max_namelen = ntohl(*p++);
  939. /* ignore remaining fields */
  940. return 0;
  941. }
  942. /*
  943. * Decode COMMIT reply
  944. */
  945. static int
  946. nfs3_xdr_commitres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
  947. {
  948. int status;
  949. status = ntohl(*p++);
  950. p = xdr_decode_wcc_data(p, res->fattr);
  951. if (status != 0)
  952. return nfs_stat_to_errno(status);
  953. res->verf->verifier[0] = *p++;
  954. res->verf->verifier[1] = *p++;
  955. return 0;
  956. }
  957. #ifdef CONFIG_NFS_V3_ACL
  958. /*
  959. * Decode GETACL reply
  960. */
  961. static int
  962. nfs3_xdr_getaclres(struct rpc_rqst *req, __be32 *p,
  963. struct nfs3_getaclres *res)
  964. {
  965. struct xdr_buf *buf = &req->rq_rcv_buf;
  966. int status = ntohl(*p++);
  967. struct posix_acl **acl;
  968. unsigned int *aclcnt;
  969. int err, base;
  970. if (status != 0)
  971. return nfs_stat_to_errno(status);
  972. p = xdr_decode_post_op_attr(p, res->fattr);
  973. res->mask = ntohl(*p++);
  974. if (res->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
  975. return -EINVAL;
  976. base = (char *)p - (char *)req->rq_rcv_buf.head->iov_base;
  977. acl = (res->mask & NFS_ACL) ? &res->acl_access : NULL;
  978. aclcnt = (res->mask & NFS_ACLCNT) ? &res->acl_access_count : NULL;
  979. err = nfsacl_decode(buf, base, aclcnt, acl);
  980. acl = (res->mask & NFS_DFACL) ? &res->acl_default : NULL;
  981. aclcnt = (res->mask & NFS_DFACLCNT) ? &res->acl_default_count : NULL;
  982. if (err > 0)
  983. err = nfsacl_decode(buf, base + err, aclcnt, acl);
  984. return (err > 0) ? 0 : err;
  985. }
  986. /*
  987. * Decode setacl reply.
  988. */
  989. static int
  990. nfs3_xdr_setaclres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  991. {
  992. int status = ntohl(*p++);
  993. if (status)
  994. return nfs_stat_to_errno(status);
  995. xdr_decode_post_op_attr(p, fattr);
  996. return 0;
  997. }
  998. #endif /* CONFIG_NFS_V3_ACL */
  999. #define PROC(proc, argtype, restype, timer) \
  1000. [NFS3PROC_##proc] = { \
  1001. .p_proc = NFS3PROC_##proc, \
  1002. .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \
  1003. .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \
  1004. .p_arglen = NFS3_##argtype##_sz, \
  1005. .p_replen = NFS3_##restype##_sz, \
  1006. .p_timer = timer, \
  1007. .p_statidx = NFS3PROC_##proc, \
  1008. .p_name = #proc, \
  1009. }
  1010. struct rpc_procinfo nfs3_procedures[] = {
  1011. PROC(GETATTR, fhandle, attrstat, 1),
  1012. PROC(SETATTR, sattrargs, wccstat, 0),
  1013. PROC(LOOKUP, diropargs, lookupres, 2),
  1014. PROC(ACCESS, accessargs, accessres, 1),
  1015. PROC(READLINK, readlinkargs, readlinkres, 3),
  1016. PROC(READ, readargs, readres, 3),
  1017. PROC(WRITE, writeargs, writeres, 4),
  1018. PROC(CREATE, createargs, createres, 0),
  1019. PROC(MKDIR, mkdirargs, createres, 0),
  1020. PROC(SYMLINK, symlinkargs, createres, 0),
  1021. PROC(MKNOD, mknodargs, createres, 0),
  1022. PROC(REMOVE, removeargs, removeres, 0),
  1023. PROC(RMDIR, diropargs, wccstat, 0),
  1024. PROC(RENAME, renameargs, renameres, 0),
  1025. PROC(LINK, linkargs, linkres, 0),
  1026. PROC(READDIR, readdirargs, readdirres, 3),
  1027. PROC(READDIRPLUS, readdirargs, readdirres, 3),
  1028. PROC(FSSTAT, fhandle, fsstatres, 0),
  1029. PROC(FSINFO, fhandle, fsinfores, 0),
  1030. PROC(PATHCONF, fhandle, pathconfres, 0),
  1031. PROC(COMMIT, commitargs, commitres, 5),
  1032. };
  1033. struct rpc_version nfs_version3 = {
  1034. .number = 3,
  1035. .nrprocs = ARRAY_SIZE(nfs3_procedures),
  1036. .procs = nfs3_procedures
  1037. };
  1038. #ifdef CONFIG_NFS_V3_ACL
  1039. static struct rpc_procinfo nfs3_acl_procedures[] = {
  1040. [ACLPROC3_GETACL] = {
  1041. .p_proc = ACLPROC3_GETACL,
  1042. .p_encode = (kxdrproc_t) nfs3_xdr_getaclargs,
  1043. .p_decode = (kxdrproc_t) nfs3_xdr_getaclres,
  1044. .p_arglen = ACL3_getaclargs_sz,
  1045. .p_replen = ACL3_getaclres_sz,
  1046. .p_timer = 1,
  1047. .p_name = "GETACL",
  1048. },
  1049. [ACLPROC3_SETACL] = {
  1050. .p_proc = ACLPROC3_SETACL,
  1051. .p_encode = (kxdrproc_t) nfs3_xdr_setaclargs,
  1052. .p_decode = (kxdrproc_t) nfs3_xdr_setaclres,
  1053. .p_arglen = ACL3_setaclargs_sz,
  1054. .p_replen = ACL3_setaclres_sz,
  1055. .p_timer = 0,
  1056. .p_name = "SETACL",
  1057. },
  1058. };
  1059. struct rpc_version nfsacl_version3 = {
  1060. .number = 3,
  1061. .nrprocs = sizeof(nfs3_acl_procedures)/
  1062. sizeof(nfs3_acl_procedures[0]),
  1063. .procs = nfs3_acl_procedures,
  1064. };
  1065. #endif /* CONFIG_NFS_V3_ACL */