nfs3xdr.c 30 KB

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