nfs3xdr.c 29 KB

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