nfs3xdr.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  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. p = xdr_inline_peek(xdr, 8);
  586. if (p != NULL)
  587. entry->eof = !p[0] && p[1];
  588. else
  589. entry->eof = 0;
  590. return p;
  591. out_overflow:
  592. print_overflow_msg(__func__, xdr);
  593. out_overflow_exit:
  594. return ERR_PTR(-EAGAIN);
  595. }
  596. /*
  597. * Encode COMMIT arguments
  598. */
  599. static int
  600. nfs3_xdr_commitargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
  601. {
  602. p = xdr_encode_fhandle(p, args->fh);
  603. p = xdr_encode_hyper(p, args->offset);
  604. *p++ = htonl(args->count);
  605. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  606. return 0;
  607. }
  608. #ifdef CONFIG_NFS_V3_ACL
  609. /*
  610. * Encode GETACL arguments
  611. */
  612. static int
  613. nfs3_xdr_getaclargs(struct rpc_rqst *req, __be32 *p,
  614. struct nfs3_getaclargs *args)
  615. {
  616. struct rpc_auth *auth = req->rq_cred->cr_auth;
  617. unsigned int replen;
  618. p = xdr_encode_fhandle(p, args->fh);
  619. *p++ = htonl(args->mask);
  620. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  621. if (args->mask & (NFS_ACL | NFS_DFACL)) {
  622. /* Inline the page array */
  623. replen = (RPC_REPHDRSIZE + auth->au_rslack +
  624. ACL3_getaclres_sz) << 2;
  625. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, 0,
  626. NFSACL_MAXPAGES << PAGE_SHIFT);
  627. }
  628. return 0;
  629. }
  630. /*
  631. * Encode SETACL arguments
  632. */
  633. static int
  634. nfs3_xdr_setaclargs(struct rpc_rqst *req, __be32 *p,
  635. struct nfs3_setaclargs *args)
  636. {
  637. struct xdr_buf *buf = &req->rq_snd_buf;
  638. unsigned int base;
  639. int err;
  640. p = xdr_encode_fhandle(p, NFS_FH(args->inode));
  641. *p++ = htonl(args->mask);
  642. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  643. base = req->rq_slen;
  644. if (args->npages != 0)
  645. xdr_encode_pages(buf, args->pages, 0, args->len);
  646. else
  647. req->rq_slen = xdr_adjust_iovec(req->rq_svec,
  648. p + XDR_QUADLEN(args->len));
  649. err = nfsacl_encode(buf, base, args->inode,
  650. (args->mask & NFS_ACL) ?
  651. args->acl_access : NULL, 1, 0);
  652. if (err > 0)
  653. err = nfsacl_encode(buf, base + err, args->inode,
  654. (args->mask & NFS_DFACL) ?
  655. args->acl_default : NULL, 1,
  656. NFS_ACL_DEFAULT);
  657. return (err > 0) ? 0 : err;
  658. }
  659. #endif /* CONFIG_NFS_V3_ACL */
  660. /*
  661. * NFS XDR decode functions
  662. */
  663. /*
  664. * Decode attrstat reply.
  665. */
  666. static int
  667. nfs3_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  668. {
  669. int status;
  670. if ((status = ntohl(*p++)))
  671. return nfs_stat_to_errno(status);
  672. xdr_decode_fattr(p, fattr);
  673. return 0;
  674. }
  675. /*
  676. * Decode status+wcc_data reply
  677. * SATTR, REMOVE, RMDIR
  678. */
  679. static int
  680. nfs3_xdr_wccstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  681. {
  682. int status;
  683. if ((status = ntohl(*p++)))
  684. status = nfs_stat_to_errno(status);
  685. xdr_decode_wcc_data(p, fattr);
  686. return status;
  687. }
  688. static int
  689. nfs3_xdr_removeres(struct rpc_rqst *req, __be32 *p, struct nfs_removeres *res)
  690. {
  691. return nfs3_xdr_wccstat(req, p, res->dir_attr);
  692. }
  693. /*
  694. * Decode LOOKUP reply
  695. */
  696. static int
  697. nfs3_xdr_lookupres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
  698. {
  699. int status;
  700. if ((status = ntohl(*p++))) {
  701. status = nfs_stat_to_errno(status);
  702. } else {
  703. if (!(p = xdr_decode_fhandle(p, res->fh)))
  704. return -errno_NFSERR_IO;
  705. p = xdr_decode_post_op_attr(p, res->fattr);
  706. }
  707. xdr_decode_post_op_attr(p, res->dir_attr);
  708. return status;
  709. }
  710. /*
  711. * Decode ACCESS reply
  712. */
  713. static int
  714. nfs3_xdr_accessres(struct rpc_rqst *req, __be32 *p, struct nfs3_accessres *res)
  715. {
  716. int status = ntohl(*p++);
  717. p = xdr_decode_post_op_attr(p, res->fattr);
  718. if (status)
  719. return nfs_stat_to_errno(status);
  720. res->access = ntohl(*p++);
  721. return 0;
  722. }
  723. static int
  724. nfs3_xdr_readlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_readlinkargs *args)
  725. {
  726. struct rpc_auth *auth = req->rq_cred->cr_auth;
  727. unsigned int replen;
  728. p = xdr_encode_fhandle(p, args->fh);
  729. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  730. /* Inline the page array */
  731. replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS3_readlinkres_sz) << 2;
  732. xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, args->pgbase, args->pglen);
  733. return 0;
  734. }
  735. /*
  736. * Decode READLINK reply
  737. */
  738. static int
  739. nfs3_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  740. {
  741. struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
  742. struct kvec *iov = rcvbuf->head;
  743. size_t hdrlen;
  744. u32 len, recvd;
  745. int status;
  746. status = ntohl(*p++);
  747. p = xdr_decode_post_op_attr(p, fattr);
  748. if (status != 0)
  749. return nfs_stat_to_errno(status);
  750. /* Convert length of symlink */
  751. len = ntohl(*p++);
  752. if (len >= rcvbuf->page_len) {
  753. dprintk("nfs: server returned giant symlink!\n");
  754. return -ENAMETOOLONG;
  755. }
  756. hdrlen = (u8 *) p - (u8 *) iov->iov_base;
  757. if (iov->iov_len < hdrlen) {
  758. dprintk("NFS: READLINK reply header overflowed:"
  759. "length %Zu > %Zu\n", hdrlen, iov->iov_len);
  760. return -errno_NFSERR_IO;
  761. } else if (iov->iov_len != hdrlen) {
  762. dprintk("NFS: READLINK header is short. "
  763. "iovec will be shifted.\n");
  764. xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen);
  765. }
  766. recvd = req->rq_rcv_buf.len - hdrlen;
  767. if (recvd < len) {
  768. dprintk("NFS: server cheating in readlink reply: "
  769. "count %u > recvd %u\n", len, recvd);
  770. return -EIO;
  771. }
  772. xdr_terminate_string(rcvbuf, len);
  773. return 0;
  774. }
  775. /*
  776. * Decode READ reply
  777. */
  778. static int
  779. nfs3_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
  780. {
  781. struct kvec *iov = req->rq_rcv_buf.head;
  782. size_t hdrlen;
  783. u32 count, ocount, recvd;
  784. int status;
  785. status = ntohl(*p++);
  786. p = xdr_decode_post_op_attr(p, res->fattr);
  787. if (status != 0)
  788. return nfs_stat_to_errno(status);
  789. /* Decode reply count and EOF flag. NFSv3 is somewhat redundant
  790. * in that it puts the count both in the res struct and in the
  791. * opaque data count. */
  792. count = ntohl(*p++);
  793. res->eof = ntohl(*p++);
  794. ocount = ntohl(*p++);
  795. if (ocount != count) {
  796. dprintk("NFS: READ count doesn't match RPC opaque count.\n");
  797. return -errno_NFSERR_IO;
  798. }
  799. hdrlen = (u8 *) p - (u8 *) iov->iov_base;
  800. if (iov->iov_len < hdrlen) {
  801. dprintk("NFS: READ reply header overflowed:"
  802. "length %Zu > %Zu\n", hdrlen, iov->iov_len);
  803. return -errno_NFSERR_IO;
  804. } else if (iov->iov_len != hdrlen) {
  805. dprintk("NFS: READ header is short. iovec will be shifted.\n");
  806. xdr_shift_buf(&req->rq_rcv_buf, iov->iov_len - hdrlen);
  807. }
  808. recvd = req->rq_rcv_buf.len - hdrlen;
  809. if (count > recvd) {
  810. dprintk("NFS: server cheating in read reply: "
  811. "count %u > recvd %u\n", count, recvd);
  812. count = recvd;
  813. res->eof = 0;
  814. }
  815. if (count < res->count)
  816. res->count = count;
  817. return count;
  818. }
  819. /*
  820. * Decode WRITE response
  821. */
  822. static int
  823. nfs3_xdr_writeres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
  824. {
  825. int status;
  826. status = ntohl(*p++);
  827. p = xdr_decode_wcc_data(p, res->fattr);
  828. if (status != 0)
  829. return nfs_stat_to_errno(status);
  830. res->count = ntohl(*p++);
  831. res->verf->committed = (enum nfs3_stable_how)ntohl(*p++);
  832. res->verf->verifier[0] = *p++;
  833. res->verf->verifier[1] = *p++;
  834. return res->count;
  835. }
  836. /*
  837. * Decode a CREATE response
  838. */
  839. static int
  840. nfs3_xdr_createres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
  841. {
  842. int status;
  843. status = ntohl(*p++);
  844. if (status == 0) {
  845. if (*p++) {
  846. if (!(p = xdr_decode_fhandle(p, res->fh)))
  847. return -errno_NFSERR_IO;
  848. p = xdr_decode_post_op_attr(p, res->fattr);
  849. } else {
  850. memset(res->fh, 0, sizeof(*res->fh));
  851. /* Do decode post_op_attr but set it to NULL */
  852. p = xdr_decode_post_op_attr(p, res->fattr);
  853. res->fattr->valid = 0;
  854. }
  855. } else {
  856. status = nfs_stat_to_errno(status);
  857. }
  858. p = xdr_decode_wcc_data(p, res->dir_attr);
  859. return status;
  860. }
  861. /*
  862. * Decode RENAME reply
  863. */
  864. static int
  865. nfs3_xdr_renameres(struct rpc_rqst *req, __be32 *p, struct nfs_renameres *res)
  866. {
  867. int status;
  868. if ((status = ntohl(*p++)) != 0)
  869. status = nfs_stat_to_errno(status);
  870. p = xdr_decode_wcc_data(p, res->old_fattr);
  871. p = xdr_decode_wcc_data(p, res->new_fattr);
  872. return status;
  873. }
  874. /*
  875. * Decode LINK reply
  876. */
  877. static int
  878. nfs3_xdr_linkres(struct rpc_rqst *req, __be32 *p, struct nfs3_linkres *res)
  879. {
  880. int status;
  881. if ((status = ntohl(*p++)) != 0)
  882. status = nfs_stat_to_errno(status);
  883. p = xdr_decode_post_op_attr(p, res->fattr);
  884. p = xdr_decode_wcc_data(p, res->dir_attr);
  885. return status;
  886. }
  887. /*
  888. * Decode FSSTAT reply
  889. */
  890. static int
  891. nfs3_xdr_fsstatres(struct rpc_rqst *req, __be32 *p, struct nfs_fsstat *res)
  892. {
  893. int status;
  894. status = ntohl(*p++);
  895. p = xdr_decode_post_op_attr(p, res->fattr);
  896. if (status != 0)
  897. return nfs_stat_to_errno(status);
  898. p = xdr_decode_hyper(p, &res->tbytes);
  899. p = xdr_decode_hyper(p, &res->fbytes);
  900. p = xdr_decode_hyper(p, &res->abytes);
  901. p = xdr_decode_hyper(p, &res->tfiles);
  902. p = xdr_decode_hyper(p, &res->ffiles);
  903. p = xdr_decode_hyper(p, &res->afiles);
  904. /* ignore invarsec */
  905. return 0;
  906. }
  907. /*
  908. * Decode FSINFO reply
  909. */
  910. static int
  911. nfs3_xdr_fsinfores(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *res)
  912. {
  913. int status;
  914. status = ntohl(*p++);
  915. p = xdr_decode_post_op_attr(p, res->fattr);
  916. if (status != 0)
  917. return nfs_stat_to_errno(status);
  918. res->rtmax = ntohl(*p++);
  919. res->rtpref = ntohl(*p++);
  920. res->rtmult = ntohl(*p++);
  921. res->wtmax = ntohl(*p++);
  922. res->wtpref = ntohl(*p++);
  923. res->wtmult = ntohl(*p++);
  924. res->dtpref = ntohl(*p++);
  925. p = xdr_decode_hyper(p, &res->maxfilesize);
  926. p = xdr_decode_time3(p, &res->time_delta);
  927. /* ignore properties */
  928. res->lease_time = 0;
  929. return 0;
  930. }
  931. /*
  932. * Decode PATHCONF reply
  933. */
  934. static int
  935. nfs3_xdr_pathconfres(struct rpc_rqst *req, __be32 *p, struct nfs_pathconf *res)
  936. {
  937. int status;
  938. status = ntohl(*p++);
  939. p = xdr_decode_post_op_attr(p, res->fattr);
  940. if (status != 0)
  941. return nfs_stat_to_errno(status);
  942. res->max_link = ntohl(*p++);
  943. res->max_namelen = ntohl(*p++);
  944. /* ignore remaining fields */
  945. return 0;
  946. }
  947. /*
  948. * Decode COMMIT reply
  949. */
  950. static int
  951. nfs3_xdr_commitres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
  952. {
  953. int status;
  954. status = ntohl(*p++);
  955. p = xdr_decode_wcc_data(p, res->fattr);
  956. if (status != 0)
  957. return nfs_stat_to_errno(status);
  958. res->verf->verifier[0] = *p++;
  959. res->verf->verifier[1] = *p++;
  960. return 0;
  961. }
  962. #ifdef CONFIG_NFS_V3_ACL
  963. /*
  964. * Decode GETACL reply
  965. */
  966. static int
  967. nfs3_xdr_getaclres(struct rpc_rqst *req, __be32 *p,
  968. struct nfs3_getaclres *res)
  969. {
  970. struct xdr_buf *buf = &req->rq_rcv_buf;
  971. int status = ntohl(*p++);
  972. struct posix_acl **acl;
  973. unsigned int *aclcnt;
  974. int err, base;
  975. if (status != 0)
  976. return nfs_stat_to_errno(status);
  977. p = xdr_decode_post_op_attr(p, res->fattr);
  978. res->mask = ntohl(*p++);
  979. if (res->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
  980. return -EINVAL;
  981. base = (char *)p - (char *)req->rq_rcv_buf.head->iov_base;
  982. acl = (res->mask & NFS_ACL) ? &res->acl_access : NULL;
  983. aclcnt = (res->mask & NFS_ACLCNT) ? &res->acl_access_count : NULL;
  984. err = nfsacl_decode(buf, base, aclcnt, acl);
  985. acl = (res->mask & NFS_DFACL) ? &res->acl_default : NULL;
  986. aclcnt = (res->mask & NFS_DFACLCNT) ? &res->acl_default_count : NULL;
  987. if (err > 0)
  988. err = nfsacl_decode(buf, base + err, aclcnt, acl);
  989. return (err > 0) ? 0 : err;
  990. }
  991. /*
  992. * Decode setacl reply.
  993. */
  994. static int
  995. nfs3_xdr_setaclres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
  996. {
  997. int status = ntohl(*p++);
  998. if (status)
  999. return nfs_stat_to_errno(status);
  1000. xdr_decode_post_op_attr(p, fattr);
  1001. return 0;
  1002. }
  1003. #endif /* CONFIG_NFS_V3_ACL */
  1004. #define PROC(proc, argtype, restype, timer) \
  1005. [NFS3PROC_##proc] = { \
  1006. .p_proc = NFS3PROC_##proc, \
  1007. .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \
  1008. .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \
  1009. .p_arglen = NFS3_##argtype##_sz, \
  1010. .p_replen = NFS3_##restype##_sz, \
  1011. .p_timer = timer, \
  1012. .p_statidx = NFS3PROC_##proc, \
  1013. .p_name = #proc, \
  1014. }
  1015. struct rpc_procinfo nfs3_procedures[] = {
  1016. PROC(GETATTR, fhandle, attrstat, 1),
  1017. PROC(SETATTR, sattrargs, wccstat, 0),
  1018. PROC(LOOKUP, diropargs, lookupres, 2),
  1019. PROC(ACCESS, accessargs, accessres, 1),
  1020. PROC(READLINK, readlinkargs, readlinkres, 3),
  1021. PROC(READ, readargs, readres, 3),
  1022. PROC(WRITE, writeargs, writeres, 4),
  1023. PROC(CREATE, createargs, createres, 0),
  1024. PROC(MKDIR, mkdirargs, createres, 0),
  1025. PROC(SYMLINK, symlinkargs, createres, 0),
  1026. PROC(MKNOD, mknodargs, createres, 0),
  1027. PROC(REMOVE, removeargs, removeres, 0),
  1028. PROC(RMDIR, diropargs, wccstat, 0),
  1029. PROC(RENAME, renameargs, renameres, 0),
  1030. PROC(LINK, linkargs, linkres, 0),
  1031. PROC(READDIR, readdirargs, readdirres, 3),
  1032. PROC(READDIRPLUS, readdirargs, readdirres, 3),
  1033. PROC(FSSTAT, fhandle, fsstatres, 0),
  1034. PROC(FSINFO, fhandle, fsinfores, 0),
  1035. PROC(PATHCONF, fhandle, pathconfres, 0),
  1036. PROC(COMMIT, commitargs, commitres, 5),
  1037. };
  1038. struct rpc_version nfs_version3 = {
  1039. .number = 3,
  1040. .nrprocs = ARRAY_SIZE(nfs3_procedures),
  1041. .procs = nfs3_procedures
  1042. };
  1043. #ifdef CONFIG_NFS_V3_ACL
  1044. static struct rpc_procinfo nfs3_acl_procedures[] = {
  1045. [ACLPROC3_GETACL] = {
  1046. .p_proc = ACLPROC3_GETACL,
  1047. .p_encode = (kxdrproc_t) nfs3_xdr_getaclargs,
  1048. .p_decode = (kxdrproc_t) nfs3_xdr_getaclres,
  1049. .p_arglen = ACL3_getaclargs_sz,
  1050. .p_replen = ACL3_getaclres_sz,
  1051. .p_timer = 1,
  1052. .p_name = "GETACL",
  1053. },
  1054. [ACLPROC3_SETACL] = {
  1055. .p_proc = ACLPROC3_SETACL,
  1056. .p_encode = (kxdrproc_t) nfs3_xdr_setaclargs,
  1057. .p_decode = (kxdrproc_t) nfs3_xdr_setaclres,
  1058. .p_arglen = ACL3_setaclargs_sz,
  1059. .p_replen = ACL3_setaclres_sz,
  1060. .p_timer = 0,
  1061. .p_name = "SETACL",
  1062. },
  1063. };
  1064. struct rpc_version nfsacl_version3 = {
  1065. .number = 3,
  1066. .nrprocs = sizeof(nfs3_acl_procedures)/
  1067. sizeof(nfs3_acl_procedures[0]),
  1068. .procs = nfs3_acl_procedures,
  1069. };
  1070. #endif /* CONFIG_NFS_V3_ACL */