nfs3xdr.c 30 KB

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