nfs3xdr.c 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/fs/nfs/nfs3xdr.c
  4. *
  5. * XDR functions to encode/decode NFSv3 RPC arguments and results.
  6. *
  7. * Copyright (C) 1996, 1997 Olaf Kirch
  8. */
  9. #include <linux/param.h>
  10. #include <linux/time.h>
  11. #include <linux/mm.h>
  12. #include <linux/errno.h>
  13. #include <linux/string.h>
  14. #include <linux/in.h>
  15. #include <linux/pagemap.h>
  16. #include <linux/proc_fs.h>
  17. #include <linux/kdev_t.h>
  18. #include <linux/sunrpc/clnt.h>
  19. #include <linux/nfs.h>
  20. #include <linux/nfs3.h>
  21. #include <linux/nfs_fs.h>
  22. #include <linux/nfsacl.h>
  23. #include "nfstrace.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_post_op_fh_sz (1+NFS3_fh_sz)
  35. #define NFS3_sattr_sz (15)
  36. #define NFS3_filename_sz (1+(NFS3_MAXNAMLEN>>2))
  37. #define NFS3_path_sz (1+(NFS3_MAXPATHLEN>>2))
  38. #define NFS3_fattr_sz (21)
  39. #define NFS3_cookieverf_sz (NFS3_COOKIEVERFSIZE>>2)
  40. #define NFS3_wcc_attr_sz (6)
  41. #define NFS3_pre_op_attr_sz (1+NFS3_wcc_attr_sz)
  42. #define NFS3_post_op_attr_sz (1+NFS3_fattr_sz)
  43. #define NFS3_wcc_data_sz (NFS3_pre_op_attr_sz+NFS3_post_op_attr_sz)
  44. #define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz)
  45. #define NFS3_getattrargs_sz (NFS3_fh_sz)
  46. #define NFS3_setattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3)
  47. #define NFS3_lookupargs_sz (NFS3_fh_sz+NFS3_filename_sz)
  48. #define NFS3_accessargs_sz (NFS3_fh_sz+1)
  49. #define NFS3_readlinkargs_sz (NFS3_fh_sz)
  50. #define NFS3_readargs_sz (NFS3_fh_sz+3)
  51. #define NFS3_writeargs_sz (NFS3_fh_sz+5)
  52. #define NFS3_createargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
  53. #define NFS3_mkdirargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
  54. #define NFS3_symlinkargs_sz (NFS3_diropargs_sz+1+NFS3_sattr_sz)
  55. #define NFS3_mknodargs_sz (NFS3_diropargs_sz+2+NFS3_sattr_sz)
  56. #define NFS3_removeargs_sz (NFS3_fh_sz+NFS3_filename_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+NFS3_cookieverf_sz+3)
  60. #define NFS3_readdirplusargs_sz (NFS3_fh_sz+NFS3_cookieverf_sz+4)
  61. #define NFS3_commitargs_sz (NFS3_fh_sz+3)
  62. #define NFS3_getattrres_sz (1+NFS3_fattr_sz)
  63. #define NFS3_setattrres_sz (1+NFS3_wcc_data_sz)
  64. #define NFS3_removeres_sz (NFS3_setattrres_sz)
  65. #define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz))
  66. #define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1)
  67. #define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1+1)
  68. #define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3+1)
  69. #define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4)
  70. #define NFS3_createres_sz (1+NFS3_post_op_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
  71. #define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz))
  72. #define NFS3_linkres_sz (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
  73. #define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2+1)
  74. #define NFS3_fsstatres_sz (1+NFS3_post_op_attr_sz+13)
  75. #define NFS3_fsinfores_sz (1+NFS3_post_op_attr_sz+12)
  76. #define NFS3_pathconfres_sz (1+NFS3_post_op_attr_sz+6)
  77. #define NFS3_commitres_sz (1+NFS3_wcc_data_sz+2)
  78. #define ACL3_getaclargs_sz (NFS3_fh_sz+1)
  79. #define ACL3_setaclargs_sz (NFS3_fh_sz+1+ \
  80. XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE))
  81. #define ACL3_getaclres_sz (1+NFS3_post_op_attr_sz+1+ \
  82. XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE)+1)
  83. #define ACL3_setaclres_sz (1+NFS3_post_op_attr_sz)
  84. static int nfs3_stat_to_errno(enum nfs_stat);
  85. /*
  86. * Map file type to S_IFMT bits
  87. */
  88. static const umode_t nfs_type2fmt[] = {
  89. [NF3BAD] = 0,
  90. [NF3REG] = S_IFREG,
  91. [NF3DIR] = S_IFDIR,
  92. [NF3BLK] = S_IFBLK,
  93. [NF3CHR] = S_IFCHR,
  94. [NF3LNK] = S_IFLNK,
  95. [NF3SOCK] = S_IFSOCK,
  96. [NF3FIFO] = S_IFIFO,
  97. };
  98. static struct user_namespace *rpc_userns(const struct rpc_clnt *clnt)
  99. {
  100. if (clnt && clnt->cl_cred)
  101. return clnt->cl_cred->user_ns;
  102. return &init_user_ns;
  103. }
  104. static struct user_namespace *rpc_rqst_userns(const struct rpc_rqst *rqstp)
  105. {
  106. if (rqstp->rq_task)
  107. return rpc_userns(rqstp->rq_task->tk_client);
  108. return &init_user_ns;
  109. }
  110. /*
  111. * Encode/decode NFSv3 basic data types
  112. *
  113. * Basic NFSv3 data types are defined in section 2.5 of RFC 1813:
  114. * "NFS Version 3 Protocol Specification".
  115. *
  116. * Not all basic data types have their own encoding and decoding
  117. * functions. For run-time efficiency, some data types are encoded
  118. * or decoded inline.
  119. */
  120. static void encode_uint32(struct xdr_stream *xdr, u32 value)
  121. {
  122. __be32 *p = xdr_reserve_space(xdr, 4);
  123. *p = cpu_to_be32(value);
  124. }
  125. static int decode_uint32(struct xdr_stream *xdr, u32 *value)
  126. {
  127. __be32 *p;
  128. p = xdr_inline_decode(xdr, 4);
  129. if (unlikely(!p))
  130. return -EIO;
  131. *value = be32_to_cpup(p);
  132. return 0;
  133. }
  134. static int decode_uint64(struct xdr_stream *xdr, u64 *value)
  135. {
  136. __be32 *p;
  137. p = xdr_inline_decode(xdr, 8);
  138. if (unlikely(!p))
  139. return -EIO;
  140. xdr_decode_hyper(p, value);
  141. return 0;
  142. }
  143. /*
  144. * fileid3
  145. *
  146. * typedef uint64 fileid3;
  147. */
  148. static __be32 *xdr_decode_fileid3(__be32 *p, u64 *fileid)
  149. {
  150. return xdr_decode_hyper(p, fileid);
  151. }
  152. static int decode_fileid3(struct xdr_stream *xdr, u64 *fileid)
  153. {
  154. return decode_uint64(xdr, fileid);
  155. }
  156. /*
  157. * filename3
  158. *
  159. * typedef string filename3<>;
  160. */
  161. static void encode_filename3(struct xdr_stream *xdr,
  162. const char *name, u32 length)
  163. {
  164. __be32 *p;
  165. WARN_ON_ONCE(length > NFS3_MAXNAMLEN);
  166. p = xdr_reserve_space(xdr, 4 + length);
  167. xdr_encode_opaque(p, name, length);
  168. }
  169. static int decode_inline_filename3(struct xdr_stream *xdr,
  170. const char **name, u32 *length)
  171. {
  172. __be32 *p;
  173. u32 count;
  174. p = xdr_inline_decode(xdr, 4);
  175. if (unlikely(!p))
  176. return -EIO;
  177. count = be32_to_cpup(p);
  178. if (count > NFS3_MAXNAMLEN)
  179. goto out_nametoolong;
  180. p = xdr_inline_decode(xdr, count);
  181. if (unlikely(!p))
  182. return -EIO;
  183. *name = (const char *)p;
  184. *length = count;
  185. return 0;
  186. out_nametoolong:
  187. dprintk("NFS: returned filename too long: %u\n", count);
  188. return -ENAMETOOLONG;
  189. }
  190. /*
  191. * nfspath3
  192. *
  193. * typedef string nfspath3<>;
  194. */
  195. static void encode_nfspath3(struct xdr_stream *xdr, struct page **pages,
  196. const u32 length)
  197. {
  198. encode_uint32(xdr, length);
  199. xdr_write_pages(xdr, pages, 0, length);
  200. }
  201. static int decode_nfspath3(struct xdr_stream *xdr)
  202. {
  203. u32 recvd, count;
  204. __be32 *p;
  205. p = xdr_inline_decode(xdr, 4);
  206. if (unlikely(!p))
  207. return -EIO;
  208. count = be32_to_cpup(p);
  209. if (unlikely(count >= xdr->buf->page_len || count > NFS3_MAXPATHLEN))
  210. goto out_nametoolong;
  211. recvd = xdr_read_pages(xdr, count);
  212. if (unlikely(count > recvd))
  213. goto out_cheating;
  214. xdr_terminate_string(xdr->buf, count);
  215. return 0;
  216. out_nametoolong:
  217. dprintk("NFS: returned pathname too long: %u\n", count);
  218. return -ENAMETOOLONG;
  219. out_cheating:
  220. dprintk("NFS: server cheating in pathname result: "
  221. "count %u > recvd %u\n", count, recvd);
  222. return -EIO;
  223. }
  224. /*
  225. * cookie3
  226. *
  227. * typedef uint64 cookie3
  228. */
  229. static __be32 *xdr_encode_cookie3(__be32 *p, u64 cookie)
  230. {
  231. return xdr_encode_hyper(p, cookie);
  232. }
  233. static int decode_cookie3(struct xdr_stream *xdr, u64 *cookie)
  234. {
  235. return decode_uint64(xdr, cookie);
  236. }
  237. /*
  238. * cookieverf3
  239. *
  240. * typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
  241. */
  242. static __be32 *xdr_encode_cookieverf3(__be32 *p, const __be32 *verifier)
  243. {
  244. memcpy(p, verifier, NFS3_COOKIEVERFSIZE);
  245. return p + XDR_QUADLEN(NFS3_COOKIEVERFSIZE);
  246. }
  247. static int decode_cookieverf3(struct xdr_stream *xdr, __be32 *verifier)
  248. {
  249. __be32 *p;
  250. p = xdr_inline_decode(xdr, NFS3_COOKIEVERFSIZE);
  251. if (unlikely(!p))
  252. return -EIO;
  253. memcpy(verifier, p, NFS3_COOKIEVERFSIZE);
  254. return 0;
  255. }
  256. /*
  257. * createverf3
  258. *
  259. * typedef opaque createverf3[NFS3_CREATEVERFSIZE];
  260. */
  261. static void encode_createverf3(struct xdr_stream *xdr, const __be32 *verifier)
  262. {
  263. __be32 *p;
  264. p = xdr_reserve_space(xdr, NFS3_CREATEVERFSIZE);
  265. memcpy(p, verifier, NFS3_CREATEVERFSIZE);
  266. }
  267. static int decode_writeverf3(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
  268. {
  269. __be32 *p;
  270. p = xdr_inline_decode(xdr, NFS3_WRITEVERFSIZE);
  271. if (unlikely(!p))
  272. return -EIO;
  273. memcpy(verifier->data, p, NFS3_WRITEVERFSIZE);
  274. return 0;
  275. }
  276. /*
  277. * size3
  278. *
  279. * typedef uint64 size3;
  280. */
  281. static __be32 *xdr_decode_size3(__be32 *p, u64 *size)
  282. {
  283. return xdr_decode_hyper(p, size);
  284. }
  285. /*
  286. * nfsstat3
  287. *
  288. * enum nfsstat3 {
  289. * NFS3_OK = 0,
  290. * ...
  291. * }
  292. */
  293. #define NFS3_OK NFS_OK
  294. static int decode_nfsstat3(struct xdr_stream *xdr, enum nfs_stat *status)
  295. {
  296. __be32 *p;
  297. p = xdr_inline_decode(xdr, 4);
  298. if (unlikely(!p))
  299. return -EIO;
  300. if (unlikely(*p != cpu_to_be32(NFS3_OK)))
  301. goto out_status;
  302. *status = 0;
  303. return 0;
  304. out_status:
  305. *status = be32_to_cpup(p);
  306. trace_nfs_xdr_status(xdr, (int)*status);
  307. return 0;
  308. }
  309. /*
  310. * ftype3
  311. *
  312. * enum ftype3 {
  313. * NF3REG = 1,
  314. * NF3DIR = 2,
  315. * NF3BLK = 3,
  316. * NF3CHR = 4,
  317. * NF3LNK = 5,
  318. * NF3SOCK = 6,
  319. * NF3FIFO = 7
  320. * };
  321. */
  322. static void encode_ftype3(struct xdr_stream *xdr, const u32 type)
  323. {
  324. encode_uint32(xdr, type);
  325. }
  326. static __be32 *xdr_decode_ftype3(__be32 *p, umode_t *mode)
  327. {
  328. u32 type;
  329. type = be32_to_cpup(p++);
  330. if (type > NF3FIFO)
  331. type = NF3NON;
  332. *mode = nfs_type2fmt[type];
  333. return p;
  334. }
  335. /*
  336. * specdata3
  337. *
  338. * struct specdata3 {
  339. * uint32 specdata1;
  340. * uint32 specdata2;
  341. * };
  342. */
  343. static void encode_specdata3(struct xdr_stream *xdr, const dev_t rdev)
  344. {
  345. __be32 *p;
  346. p = xdr_reserve_space(xdr, 8);
  347. *p++ = cpu_to_be32(MAJOR(rdev));
  348. *p = cpu_to_be32(MINOR(rdev));
  349. }
  350. static __be32 *xdr_decode_specdata3(__be32 *p, dev_t *rdev)
  351. {
  352. unsigned int major, minor;
  353. major = be32_to_cpup(p++);
  354. minor = be32_to_cpup(p++);
  355. *rdev = MKDEV(major, minor);
  356. if (MAJOR(*rdev) != major || MINOR(*rdev) != minor)
  357. *rdev = 0;
  358. return p;
  359. }
  360. /*
  361. * nfs_fh3
  362. *
  363. * struct nfs_fh3 {
  364. * opaque data<NFS3_FHSIZE>;
  365. * };
  366. */
  367. static void encode_nfs_fh3(struct xdr_stream *xdr, const struct nfs_fh *fh)
  368. {
  369. __be32 *p;
  370. WARN_ON_ONCE(fh->size > NFS3_FHSIZE);
  371. p = xdr_reserve_space(xdr, 4 + fh->size);
  372. xdr_encode_opaque(p, fh->data, fh->size);
  373. }
  374. static int decode_nfs_fh3(struct xdr_stream *xdr, struct nfs_fh *fh)
  375. {
  376. u32 length;
  377. __be32 *p;
  378. p = xdr_inline_decode(xdr, 4);
  379. if (unlikely(!p))
  380. return -EIO;
  381. length = be32_to_cpup(p++);
  382. if (unlikely(length > NFS3_FHSIZE))
  383. goto out_toobig;
  384. p = xdr_inline_decode(xdr, length);
  385. if (unlikely(!p))
  386. return -EIO;
  387. fh->size = length;
  388. memcpy(fh->data, p, length);
  389. return 0;
  390. out_toobig:
  391. dprintk("NFS: file handle size (%u) too big\n", length);
  392. return -E2BIG;
  393. }
  394. static void zero_nfs_fh3(struct nfs_fh *fh)
  395. {
  396. memset(fh, 0, sizeof(*fh));
  397. }
  398. /*
  399. * nfstime3
  400. *
  401. * struct nfstime3 {
  402. * uint32 seconds;
  403. * uint32 nseconds;
  404. * };
  405. */
  406. static __be32 *xdr_encode_nfstime3(__be32 *p, const struct timespec64 *timep)
  407. {
  408. *p++ = cpu_to_be32((u32)timep->tv_sec);
  409. *p++ = cpu_to_be32(timep->tv_nsec);
  410. return p;
  411. }
  412. static __be32 *xdr_decode_nfstime3(__be32 *p, struct timespec64 *timep)
  413. {
  414. timep->tv_sec = be32_to_cpup(p++);
  415. timep->tv_nsec = be32_to_cpup(p++);
  416. return p;
  417. }
  418. /*
  419. * sattr3
  420. *
  421. * enum time_how {
  422. * DONT_CHANGE = 0,
  423. * SET_TO_SERVER_TIME = 1,
  424. * SET_TO_CLIENT_TIME = 2
  425. * };
  426. *
  427. * union set_mode3 switch (bool set_it) {
  428. * case TRUE:
  429. * mode3 mode;
  430. * default:
  431. * void;
  432. * };
  433. *
  434. * union set_uid3 switch (bool set_it) {
  435. * case TRUE:
  436. * uid3 uid;
  437. * default:
  438. * void;
  439. * };
  440. *
  441. * union set_gid3 switch (bool set_it) {
  442. * case TRUE:
  443. * gid3 gid;
  444. * default:
  445. * void;
  446. * };
  447. *
  448. * union set_size3 switch (bool set_it) {
  449. * case TRUE:
  450. * size3 size;
  451. * default:
  452. * void;
  453. * };
  454. *
  455. * union set_atime switch (time_how set_it) {
  456. * case SET_TO_CLIENT_TIME:
  457. * nfstime3 atime;
  458. * default:
  459. * void;
  460. * };
  461. *
  462. * union set_mtime switch (time_how set_it) {
  463. * case SET_TO_CLIENT_TIME:
  464. * nfstime3 mtime;
  465. * default:
  466. * void;
  467. * };
  468. *
  469. * struct sattr3 {
  470. * set_mode3 mode;
  471. * set_uid3 uid;
  472. * set_gid3 gid;
  473. * set_size3 size;
  474. * set_atime atime;
  475. * set_mtime mtime;
  476. * };
  477. */
  478. static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr,
  479. struct user_namespace *userns)
  480. {
  481. u32 nbytes;
  482. __be32 *p;
  483. /*
  484. * In order to make only a single xdr_reserve_space() call,
  485. * pre-compute the total number of bytes to be reserved.
  486. * Six boolean values, one for each set_foo field, are always
  487. * present in the encoded result, so start there.
  488. */
  489. nbytes = 6 * 4;
  490. if (attr->ia_valid & ATTR_MODE)
  491. nbytes += 4;
  492. if (attr->ia_valid & ATTR_UID)
  493. nbytes += 4;
  494. if (attr->ia_valid & ATTR_GID)
  495. nbytes += 4;
  496. if (attr->ia_valid & ATTR_SIZE)
  497. nbytes += 8;
  498. if (attr->ia_valid & ATTR_ATIME_SET)
  499. nbytes += 8;
  500. if (attr->ia_valid & ATTR_MTIME_SET)
  501. nbytes += 8;
  502. p = xdr_reserve_space(xdr, nbytes);
  503. if (attr->ia_valid & ATTR_MODE) {
  504. *p++ = xdr_one;
  505. *p++ = cpu_to_be32(attr->ia_mode & S_IALLUGO);
  506. } else
  507. *p++ = xdr_zero;
  508. if (attr->ia_valid & ATTR_UID) {
  509. *p++ = xdr_one;
  510. *p++ = cpu_to_be32(from_kuid_munged(userns, attr->ia_uid));
  511. } else
  512. *p++ = xdr_zero;
  513. if (attr->ia_valid & ATTR_GID) {
  514. *p++ = xdr_one;
  515. *p++ = cpu_to_be32(from_kgid_munged(userns, attr->ia_gid));
  516. } else
  517. *p++ = xdr_zero;
  518. if (attr->ia_valid & ATTR_SIZE) {
  519. *p++ = xdr_one;
  520. p = xdr_encode_hyper(p, (u64)attr->ia_size);
  521. } else
  522. *p++ = xdr_zero;
  523. if (attr->ia_valid & ATTR_ATIME_SET) {
  524. *p++ = xdr_two;
  525. p = xdr_encode_nfstime3(p, &attr->ia_atime);
  526. } else if (attr->ia_valid & ATTR_ATIME) {
  527. *p++ = xdr_one;
  528. } else
  529. *p++ = xdr_zero;
  530. if (attr->ia_valid & ATTR_MTIME_SET) {
  531. *p++ = xdr_two;
  532. xdr_encode_nfstime3(p, &attr->ia_mtime);
  533. } else if (attr->ia_valid & ATTR_MTIME) {
  534. *p = xdr_one;
  535. } else
  536. *p = xdr_zero;
  537. }
  538. /*
  539. * fattr3
  540. *
  541. * struct fattr3 {
  542. * ftype3 type;
  543. * mode3 mode;
  544. * uint32 nlink;
  545. * uid3 uid;
  546. * gid3 gid;
  547. * size3 size;
  548. * size3 used;
  549. * specdata3 rdev;
  550. * uint64 fsid;
  551. * fileid3 fileid;
  552. * nfstime3 atime;
  553. * nfstime3 mtime;
  554. * nfstime3 ctime;
  555. * };
  556. */
  557. static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr,
  558. struct user_namespace *userns)
  559. {
  560. umode_t fmode;
  561. __be32 *p;
  562. p = xdr_inline_decode(xdr, NFS3_fattr_sz << 2);
  563. if (unlikely(!p))
  564. return -EIO;
  565. p = xdr_decode_ftype3(p, &fmode);
  566. fattr->mode = (be32_to_cpup(p++) & ~S_IFMT) | fmode;
  567. fattr->nlink = be32_to_cpup(p++);
  568. fattr->uid = make_kuid(userns, be32_to_cpup(p++));
  569. if (!uid_valid(fattr->uid))
  570. goto out_uid;
  571. fattr->gid = make_kgid(userns, be32_to_cpup(p++));
  572. if (!gid_valid(fattr->gid))
  573. goto out_gid;
  574. p = xdr_decode_size3(p, &fattr->size);
  575. p = xdr_decode_size3(p, &fattr->du.nfs3.used);
  576. p = xdr_decode_specdata3(p, &fattr->rdev);
  577. p = xdr_decode_hyper(p, &fattr->fsid.major);
  578. fattr->fsid.minor = 0;
  579. p = xdr_decode_fileid3(p, &fattr->fileid);
  580. p = xdr_decode_nfstime3(p, &fattr->atime);
  581. p = xdr_decode_nfstime3(p, &fattr->mtime);
  582. xdr_decode_nfstime3(p, &fattr->ctime);
  583. fattr->change_attr = nfs_timespec_to_change_attr(&fattr->ctime);
  584. fattr->valid |= NFS_ATTR_FATTR_V3;
  585. return 0;
  586. out_uid:
  587. dprintk("NFS: returned invalid uid\n");
  588. return -EINVAL;
  589. out_gid:
  590. dprintk("NFS: returned invalid gid\n");
  591. return -EINVAL;
  592. }
  593. /*
  594. * post_op_attr
  595. *
  596. * union post_op_attr switch (bool attributes_follow) {
  597. * case TRUE:
  598. * fattr3 attributes;
  599. * case FALSE:
  600. * void;
  601. * };
  602. */
  603. static int decode_post_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr,
  604. struct user_namespace *userns)
  605. {
  606. __be32 *p;
  607. p = xdr_inline_decode(xdr, 4);
  608. if (unlikely(!p))
  609. return -EIO;
  610. if (*p != xdr_zero)
  611. return decode_fattr3(xdr, fattr, userns);
  612. return 0;
  613. }
  614. /*
  615. * wcc_attr
  616. * struct wcc_attr {
  617. * size3 size;
  618. * nfstime3 mtime;
  619. * nfstime3 ctime;
  620. * };
  621. */
  622. static int decode_wcc_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr)
  623. {
  624. __be32 *p;
  625. p = xdr_inline_decode(xdr, NFS3_wcc_attr_sz << 2);
  626. if (unlikely(!p))
  627. return -EIO;
  628. fattr->valid |= NFS_ATTR_FATTR_PRESIZE
  629. | NFS_ATTR_FATTR_PRECHANGE
  630. | NFS_ATTR_FATTR_PREMTIME
  631. | NFS_ATTR_FATTR_PRECTIME;
  632. p = xdr_decode_size3(p, &fattr->pre_size);
  633. p = xdr_decode_nfstime3(p, &fattr->pre_mtime);
  634. xdr_decode_nfstime3(p, &fattr->pre_ctime);
  635. fattr->pre_change_attr = nfs_timespec_to_change_attr(&fattr->pre_ctime);
  636. return 0;
  637. }
  638. /*
  639. * pre_op_attr
  640. * union pre_op_attr switch (bool attributes_follow) {
  641. * case TRUE:
  642. * wcc_attr attributes;
  643. * case FALSE:
  644. * void;
  645. * };
  646. *
  647. * wcc_data
  648. *
  649. * struct wcc_data {
  650. * pre_op_attr before;
  651. * post_op_attr after;
  652. * };
  653. */
  654. static int decode_pre_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr)
  655. {
  656. __be32 *p;
  657. p = xdr_inline_decode(xdr, 4);
  658. if (unlikely(!p))
  659. return -EIO;
  660. if (*p != xdr_zero)
  661. return decode_wcc_attr(xdr, fattr);
  662. return 0;
  663. }
  664. static int decode_wcc_data(struct xdr_stream *xdr, struct nfs_fattr *fattr,
  665. struct user_namespace *userns)
  666. {
  667. int error;
  668. error = decode_pre_op_attr(xdr, fattr);
  669. if (unlikely(error))
  670. goto out;
  671. error = decode_post_op_attr(xdr, fattr, userns);
  672. out:
  673. return error;
  674. }
  675. /*
  676. * post_op_fh3
  677. *
  678. * union post_op_fh3 switch (bool handle_follows) {
  679. * case TRUE:
  680. * nfs_fh3 handle;
  681. * case FALSE:
  682. * void;
  683. * };
  684. */
  685. static int decode_post_op_fh3(struct xdr_stream *xdr, struct nfs_fh *fh)
  686. {
  687. __be32 *p = xdr_inline_decode(xdr, 4);
  688. if (unlikely(!p))
  689. return -EIO;
  690. if (*p != xdr_zero)
  691. return decode_nfs_fh3(xdr, fh);
  692. zero_nfs_fh3(fh);
  693. return 0;
  694. }
  695. /*
  696. * diropargs3
  697. *
  698. * struct diropargs3 {
  699. * nfs_fh3 dir;
  700. * filename3 name;
  701. * };
  702. */
  703. static void encode_diropargs3(struct xdr_stream *xdr, const struct nfs_fh *fh,
  704. const char *name, u32 length)
  705. {
  706. encode_nfs_fh3(xdr, fh);
  707. encode_filename3(xdr, name, length);
  708. }
  709. /*
  710. * NFSv3 XDR encode functions
  711. *
  712. * NFSv3 argument types are defined in section 3.3 of RFC 1813:
  713. * "NFS Version 3 Protocol Specification".
  714. */
  715. /*
  716. * 3.3.1 GETATTR3args
  717. *
  718. * struct GETATTR3args {
  719. * nfs_fh3 object;
  720. * };
  721. */
  722. static void nfs3_xdr_enc_getattr3args(struct rpc_rqst *req,
  723. struct xdr_stream *xdr,
  724. const void *data)
  725. {
  726. const struct nfs_fh *fh = data;
  727. encode_nfs_fh3(xdr, fh);
  728. }
  729. /*
  730. * 3.3.2 SETATTR3args
  731. *
  732. * union sattrguard3 switch (bool check) {
  733. * case TRUE:
  734. * nfstime3 obj_ctime;
  735. * case FALSE:
  736. * void;
  737. * };
  738. *
  739. * struct SETATTR3args {
  740. * nfs_fh3 object;
  741. * sattr3 new_attributes;
  742. * sattrguard3 guard;
  743. * };
  744. */
  745. static void encode_sattrguard3(struct xdr_stream *xdr,
  746. const struct nfs3_sattrargs *args)
  747. {
  748. __be32 *p;
  749. if (args->guard) {
  750. p = xdr_reserve_space(xdr, 4 + 8);
  751. *p++ = xdr_one;
  752. xdr_encode_nfstime3(p, &args->guardtime);
  753. } else {
  754. p = xdr_reserve_space(xdr, 4);
  755. *p = xdr_zero;
  756. }
  757. }
  758. static void nfs3_xdr_enc_setattr3args(struct rpc_rqst *req,
  759. struct xdr_stream *xdr,
  760. const void *data)
  761. {
  762. const struct nfs3_sattrargs *args = data;
  763. encode_nfs_fh3(xdr, args->fh);
  764. encode_sattr3(xdr, args->sattr, rpc_rqst_userns(req));
  765. encode_sattrguard3(xdr, args);
  766. }
  767. /*
  768. * 3.3.3 LOOKUP3args
  769. *
  770. * struct LOOKUP3args {
  771. * diropargs3 what;
  772. * };
  773. */
  774. static void nfs3_xdr_enc_lookup3args(struct rpc_rqst *req,
  775. struct xdr_stream *xdr,
  776. const void *data)
  777. {
  778. const struct nfs3_diropargs *args = data;
  779. encode_diropargs3(xdr, args->fh, args->name, args->len);
  780. }
  781. /*
  782. * 3.3.4 ACCESS3args
  783. *
  784. * struct ACCESS3args {
  785. * nfs_fh3 object;
  786. * uint32 access;
  787. * };
  788. */
  789. static void encode_access3args(struct xdr_stream *xdr,
  790. const struct nfs3_accessargs *args)
  791. {
  792. encode_nfs_fh3(xdr, args->fh);
  793. encode_uint32(xdr, args->access);
  794. }
  795. static void nfs3_xdr_enc_access3args(struct rpc_rqst *req,
  796. struct xdr_stream *xdr,
  797. const void *data)
  798. {
  799. const struct nfs3_accessargs *args = data;
  800. encode_access3args(xdr, args);
  801. }
  802. /*
  803. * 3.3.5 READLINK3args
  804. *
  805. * struct READLINK3args {
  806. * nfs_fh3 symlink;
  807. * };
  808. */
  809. static void nfs3_xdr_enc_readlink3args(struct rpc_rqst *req,
  810. struct xdr_stream *xdr,
  811. const void *data)
  812. {
  813. const struct nfs3_readlinkargs *args = data;
  814. encode_nfs_fh3(xdr, args->fh);
  815. rpc_prepare_reply_pages(req, args->pages, args->pgbase,
  816. args->pglen, NFS3_readlinkres_sz);
  817. }
  818. /*
  819. * 3.3.6 READ3args
  820. *
  821. * struct READ3args {
  822. * nfs_fh3 file;
  823. * offset3 offset;
  824. * count3 count;
  825. * };
  826. */
  827. static void encode_read3args(struct xdr_stream *xdr,
  828. const struct nfs_pgio_args *args)
  829. {
  830. __be32 *p;
  831. encode_nfs_fh3(xdr, args->fh);
  832. p = xdr_reserve_space(xdr, 8 + 4);
  833. p = xdr_encode_hyper(p, args->offset);
  834. *p = cpu_to_be32(args->count);
  835. }
  836. static void nfs3_xdr_enc_read3args(struct rpc_rqst *req,
  837. struct xdr_stream *xdr,
  838. const void *data)
  839. {
  840. const struct nfs_pgio_args *args = data;
  841. unsigned int replen = args->replen ? args->replen : NFS3_readres_sz;
  842. encode_read3args(xdr, args);
  843. rpc_prepare_reply_pages(req, args->pages, args->pgbase,
  844. args->count, replen);
  845. req->rq_rcv_buf.flags |= XDRBUF_READ;
  846. }
  847. /*
  848. * 3.3.7 WRITE3args
  849. *
  850. * enum stable_how {
  851. * UNSTABLE = 0,
  852. * DATA_SYNC = 1,
  853. * FILE_SYNC = 2
  854. * };
  855. *
  856. * struct WRITE3args {
  857. * nfs_fh3 file;
  858. * offset3 offset;
  859. * count3 count;
  860. * stable_how stable;
  861. * opaque data<>;
  862. * };
  863. */
  864. static void encode_write3args(struct xdr_stream *xdr,
  865. const struct nfs_pgio_args *args)
  866. {
  867. __be32 *p;
  868. encode_nfs_fh3(xdr, args->fh);
  869. p = xdr_reserve_space(xdr, 8 + 4 + 4 + 4);
  870. p = xdr_encode_hyper(p, args->offset);
  871. *p++ = cpu_to_be32(args->count);
  872. *p++ = cpu_to_be32(args->stable);
  873. *p = cpu_to_be32(args->count);
  874. xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
  875. }
  876. static void nfs3_xdr_enc_write3args(struct rpc_rqst *req,
  877. struct xdr_stream *xdr,
  878. const void *data)
  879. {
  880. const struct nfs_pgio_args *args = data;
  881. encode_write3args(xdr, args);
  882. xdr->buf->flags |= XDRBUF_WRITE;
  883. }
  884. /*
  885. * 3.3.8 CREATE3args
  886. *
  887. * enum createmode3 {
  888. * UNCHECKED = 0,
  889. * GUARDED = 1,
  890. * EXCLUSIVE = 2
  891. * };
  892. *
  893. * union createhow3 switch (createmode3 mode) {
  894. * case UNCHECKED:
  895. * case GUARDED:
  896. * sattr3 obj_attributes;
  897. * case EXCLUSIVE:
  898. * createverf3 verf;
  899. * };
  900. *
  901. * struct CREATE3args {
  902. * diropargs3 where;
  903. * createhow3 how;
  904. * };
  905. */
  906. static void encode_createhow3(struct xdr_stream *xdr,
  907. const struct nfs3_createargs *args,
  908. struct user_namespace *userns)
  909. {
  910. encode_uint32(xdr, args->createmode);
  911. switch (args->createmode) {
  912. case NFS3_CREATE_UNCHECKED:
  913. case NFS3_CREATE_GUARDED:
  914. encode_sattr3(xdr, args->sattr, userns);
  915. break;
  916. case NFS3_CREATE_EXCLUSIVE:
  917. encode_createverf3(xdr, args->verifier);
  918. break;
  919. default:
  920. BUG();
  921. }
  922. }
  923. static void nfs3_xdr_enc_create3args(struct rpc_rqst *req,
  924. struct xdr_stream *xdr,
  925. const void *data)
  926. {
  927. const struct nfs3_createargs *args = data;
  928. encode_diropargs3(xdr, args->fh, args->name, args->len);
  929. encode_createhow3(xdr, args, rpc_rqst_userns(req));
  930. }
  931. /*
  932. * 3.3.9 MKDIR3args
  933. *
  934. * struct MKDIR3args {
  935. * diropargs3 where;
  936. * sattr3 attributes;
  937. * };
  938. */
  939. static void nfs3_xdr_enc_mkdir3args(struct rpc_rqst *req,
  940. struct xdr_stream *xdr,
  941. const void *data)
  942. {
  943. const struct nfs3_mkdirargs *args = data;
  944. encode_diropargs3(xdr, args->fh, args->name, args->len);
  945. encode_sattr3(xdr, args->sattr, rpc_rqst_userns(req));
  946. }
  947. /*
  948. * 3.3.10 SYMLINK3args
  949. *
  950. * struct symlinkdata3 {
  951. * sattr3 symlink_attributes;
  952. * nfspath3 symlink_data;
  953. * };
  954. *
  955. * struct SYMLINK3args {
  956. * diropargs3 where;
  957. * symlinkdata3 symlink;
  958. * };
  959. */
  960. static void encode_symlinkdata3(struct xdr_stream *xdr,
  961. const void *data,
  962. struct user_namespace *userns)
  963. {
  964. const struct nfs3_symlinkargs *args = data;
  965. encode_sattr3(xdr, args->sattr, userns);
  966. encode_nfspath3(xdr, args->pages, args->pathlen);
  967. }
  968. static void nfs3_xdr_enc_symlink3args(struct rpc_rqst *req,
  969. struct xdr_stream *xdr,
  970. const void *data)
  971. {
  972. const struct nfs3_symlinkargs *args = data;
  973. encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
  974. encode_symlinkdata3(xdr, args, rpc_rqst_userns(req));
  975. xdr->buf->flags |= XDRBUF_WRITE;
  976. }
  977. /*
  978. * 3.3.11 MKNOD3args
  979. *
  980. * struct devicedata3 {
  981. * sattr3 dev_attributes;
  982. * specdata3 spec;
  983. * };
  984. *
  985. * union mknoddata3 switch (ftype3 type) {
  986. * case NF3CHR:
  987. * case NF3BLK:
  988. * devicedata3 device;
  989. * case NF3SOCK:
  990. * case NF3FIFO:
  991. * sattr3 pipe_attributes;
  992. * default:
  993. * void;
  994. * };
  995. *
  996. * struct MKNOD3args {
  997. * diropargs3 where;
  998. * mknoddata3 what;
  999. * };
  1000. */
  1001. static void encode_devicedata3(struct xdr_stream *xdr,
  1002. const struct nfs3_mknodargs *args,
  1003. struct user_namespace *userns)
  1004. {
  1005. encode_sattr3(xdr, args->sattr, userns);
  1006. encode_specdata3(xdr, args->rdev);
  1007. }
  1008. static void encode_mknoddata3(struct xdr_stream *xdr,
  1009. const struct nfs3_mknodargs *args,
  1010. struct user_namespace *userns)
  1011. {
  1012. encode_ftype3(xdr, args->type);
  1013. switch (args->type) {
  1014. case NF3CHR:
  1015. case NF3BLK:
  1016. encode_devicedata3(xdr, args, userns);
  1017. break;
  1018. case NF3SOCK:
  1019. case NF3FIFO:
  1020. encode_sattr3(xdr, args->sattr, userns);
  1021. break;
  1022. case NF3REG:
  1023. case NF3DIR:
  1024. break;
  1025. default:
  1026. BUG();
  1027. }
  1028. }
  1029. static void nfs3_xdr_enc_mknod3args(struct rpc_rqst *req,
  1030. struct xdr_stream *xdr,
  1031. const void *data)
  1032. {
  1033. const struct nfs3_mknodargs *args = data;
  1034. encode_diropargs3(xdr, args->fh, args->name, args->len);
  1035. encode_mknoddata3(xdr, args, rpc_rqst_userns(req));
  1036. }
  1037. /*
  1038. * 3.3.12 REMOVE3args
  1039. *
  1040. * struct REMOVE3args {
  1041. * diropargs3 object;
  1042. * };
  1043. */
  1044. static void nfs3_xdr_enc_remove3args(struct rpc_rqst *req,
  1045. struct xdr_stream *xdr,
  1046. const void *data)
  1047. {
  1048. const struct nfs_removeargs *args = data;
  1049. encode_diropargs3(xdr, args->fh, args->name.name, args->name.len);
  1050. }
  1051. /*
  1052. * 3.3.14 RENAME3args
  1053. *
  1054. * struct RENAME3args {
  1055. * diropargs3 from;
  1056. * diropargs3 to;
  1057. * };
  1058. */
  1059. static void nfs3_xdr_enc_rename3args(struct rpc_rqst *req,
  1060. struct xdr_stream *xdr,
  1061. const void *data)
  1062. {
  1063. const struct nfs_renameargs *args = data;
  1064. const struct qstr *old = args->old_name;
  1065. const struct qstr *new = args->new_name;
  1066. encode_diropargs3(xdr, args->old_dir, old->name, old->len);
  1067. encode_diropargs3(xdr, args->new_dir, new->name, new->len);
  1068. }
  1069. /*
  1070. * 3.3.15 LINK3args
  1071. *
  1072. * struct LINK3args {
  1073. * nfs_fh3 file;
  1074. * diropargs3 link;
  1075. * };
  1076. */
  1077. static void nfs3_xdr_enc_link3args(struct rpc_rqst *req,
  1078. struct xdr_stream *xdr,
  1079. const void *data)
  1080. {
  1081. const struct nfs3_linkargs *args = data;
  1082. encode_nfs_fh3(xdr, args->fromfh);
  1083. encode_diropargs3(xdr, args->tofh, args->toname, args->tolen);
  1084. }
  1085. /*
  1086. * 3.3.16 READDIR3args
  1087. *
  1088. * struct READDIR3args {
  1089. * nfs_fh3 dir;
  1090. * cookie3 cookie;
  1091. * cookieverf3 cookieverf;
  1092. * count3 count;
  1093. * };
  1094. */
  1095. static void encode_readdir3args(struct xdr_stream *xdr,
  1096. const struct nfs3_readdirargs *args)
  1097. {
  1098. __be32 *p;
  1099. encode_nfs_fh3(xdr, args->fh);
  1100. p = xdr_reserve_space(xdr, 8 + NFS3_COOKIEVERFSIZE + 4);
  1101. p = xdr_encode_cookie3(p, args->cookie);
  1102. p = xdr_encode_cookieverf3(p, args->verf);
  1103. *p = cpu_to_be32(args->count);
  1104. }
  1105. static void nfs3_xdr_enc_readdir3args(struct rpc_rqst *req,
  1106. struct xdr_stream *xdr,
  1107. const void *data)
  1108. {
  1109. const struct nfs3_readdirargs *args = data;
  1110. encode_readdir3args(xdr, args);
  1111. rpc_prepare_reply_pages(req, args->pages, 0,
  1112. args->count, NFS3_readdirres_sz);
  1113. }
  1114. /*
  1115. * 3.3.17 READDIRPLUS3args
  1116. *
  1117. * struct READDIRPLUS3args {
  1118. * nfs_fh3 dir;
  1119. * cookie3 cookie;
  1120. * cookieverf3 cookieverf;
  1121. * count3 dircount;
  1122. * count3 maxcount;
  1123. * };
  1124. */
  1125. static void encode_readdirplus3args(struct xdr_stream *xdr,
  1126. const struct nfs3_readdirargs *args)
  1127. {
  1128. __be32 *p;
  1129. encode_nfs_fh3(xdr, args->fh);
  1130. p = xdr_reserve_space(xdr, 8 + NFS3_COOKIEVERFSIZE + 4 + 4);
  1131. p = xdr_encode_cookie3(p, args->cookie);
  1132. p = xdr_encode_cookieverf3(p, args->verf);
  1133. /*
  1134. * readdirplus: need dircount + buffer size.
  1135. * We just make sure we make dircount big enough
  1136. */
  1137. *p++ = cpu_to_be32(args->count >> 3);
  1138. *p = cpu_to_be32(args->count);
  1139. }
  1140. static void nfs3_xdr_enc_readdirplus3args(struct rpc_rqst *req,
  1141. struct xdr_stream *xdr,
  1142. const void *data)
  1143. {
  1144. const struct nfs3_readdirargs *args = data;
  1145. encode_readdirplus3args(xdr, args);
  1146. rpc_prepare_reply_pages(req, args->pages, 0,
  1147. args->count, NFS3_readdirres_sz);
  1148. }
  1149. /*
  1150. * 3.3.21 COMMIT3args
  1151. *
  1152. * struct COMMIT3args {
  1153. * nfs_fh3 file;
  1154. * offset3 offset;
  1155. * count3 count;
  1156. * };
  1157. */
  1158. static void encode_commit3args(struct xdr_stream *xdr,
  1159. const struct nfs_commitargs *args)
  1160. {
  1161. __be32 *p;
  1162. encode_nfs_fh3(xdr, args->fh);
  1163. p = xdr_reserve_space(xdr, 8 + 4);
  1164. p = xdr_encode_hyper(p, args->offset);
  1165. *p = cpu_to_be32(args->count);
  1166. }
  1167. static void nfs3_xdr_enc_commit3args(struct rpc_rqst *req,
  1168. struct xdr_stream *xdr,
  1169. const void *data)
  1170. {
  1171. const struct nfs_commitargs *args = data;
  1172. encode_commit3args(xdr, args);
  1173. }
  1174. #ifdef CONFIG_NFS_V3_ACL
  1175. static void nfs3_xdr_enc_getacl3args(struct rpc_rqst *req,
  1176. struct xdr_stream *xdr,
  1177. const void *data)
  1178. {
  1179. const struct nfs3_getaclargs *args = data;
  1180. encode_nfs_fh3(xdr, args->fh);
  1181. encode_uint32(xdr, args->mask);
  1182. if (args->mask & (NFS_ACL | NFS_DFACL)) {
  1183. rpc_prepare_reply_pages(req, args->pages, 0,
  1184. NFSACL_MAXPAGES << PAGE_SHIFT,
  1185. ACL3_getaclres_sz);
  1186. req->rq_rcv_buf.flags |= XDRBUF_SPARSE_PAGES;
  1187. }
  1188. }
  1189. static void nfs3_xdr_enc_setacl3args(struct rpc_rqst *req,
  1190. struct xdr_stream *xdr,
  1191. const void *data)
  1192. {
  1193. const struct nfs3_setaclargs *args = data;
  1194. unsigned int base;
  1195. int error;
  1196. encode_nfs_fh3(xdr, NFS_FH(args->inode));
  1197. encode_uint32(xdr, args->mask);
  1198. base = req->rq_slen;
  1199. if (args->npages != 0)
  1200. xdr_write_pages(xdr, args->pages, 0, args->len);
  1201. else
  1202. xdr_reserve_space(xdr, args->len);
  1203. error = nfsacl_encode(xdr->buf, base, args->inode,
  1204. (args->mask & NFS_ACL) ?
  1205. args->acl_access : NULL, 1, 0);
  1206. /* FIXME: this is just broken */
  1207. BUG_ON(error < 0);
  1208. error = nfsacl_encode(xdr->buf, base + error, args->inode,
  1209. (args->mask & NFS_DFACL) ?
  1210. args->acl_default : NULL, 1,
  1211. NFS_ACL_DEFAULT);
  1212. BUG_ON(error < 0);
  1213. }
  1214. #endif /* CONFIG_NFS_V3_ACL */
  1215. /*
  1216. * NFSv3 XDR decode functions
  1217. *
  1218. * NFSv3 result types are defined in section 3.3 of RFC 1813:
  1219. * "NFS Version 3 Protocol Specification".
  1220. */
  1221. /*
  1222. * 3.3.1 GETATTR3res
  1223. *
  1224. * struct GETATTR3resok {
  1225. * fattr3 obj_attributes;
  1226. * };
  1227. *
  1228. * union GETATTR3res switch (nfsstat3 status) {
  1229. * case NFS3_OK:
  1230. * GETATTR3resok resok;
  1231. * default:
  1232. * void;
  1233. * };
  1234. */
  1235. static int nfs3_xdr_dec_getattr3res(struct rpc_rqst *req,
  1236. struct xdr_stream *xdr,
  1237. void *result)
  1238. {
  1239. enum nfs_stat status;
  1240. int error;
  1241. error = decode_nfsstat3(xdr, &status);
  1242. if (unlikely(error))
  1243. goto out;
  1244. if (status != NFS3_OK)
  1245. goto out_default;
  1246. error = decode_fattr3(xdr, result, rpc_rqst_userns(req));
  1247. out:
  1248. return error;
  1249. out_default:
  1250. return nfs3_stat_to_errno(status);
  1251. }
  1252. /*
  1253. * 3.3.2 SETATTR3res
  1254. *
  1255. * struct SETATTR3resok {
  1256. * wcc_data obj_wcc;
  1257. * };
  1258. *
  1259. * struct SETATTR3resfail {
  1260. * wcc_data obj_wcc;
  1261. * };
  1262. *
  1263. * union SETATTR3res switch (nfsstat3 status) {
  1264. * case NFS3_OK:
  1265. * SETATTR3resok resok;
  1266. * default:
  1267. * SETATTR3resfail resfail;
  1268. * };
  1269. */
  1270. static int nfs3_xdr_dec_setattr3res(struct rpc_rqst *req,
  1271. struct xdr_stream *xdr,
  1272. void *result)
  1273. {
  1274. enum nfs_stat status;
  1275. int error;
  1276. error = decode_nfsstat3(xdr, &status);
  1277. if (unlikely(error))
  1278. goto out;
  1279. error = decode_wcc_data(xdr, result, rpc_rqst_userns(req));
  1280. if (unlikely(error))
  1281. goto out;
  1282. if (status != NFS3_OK)
  1283. goto out_status;
  1284. out:
  1285. return error;
  1286. out_status:
  1287. return nfs3_stat_to_errno(status);
  1288. }
  1289. /*
  1290. * 3.3.3 LOOKUP3res
  1291. *
  1292. * struct LOOKUP3resok {
  1293. * nfs_fh3 object;
  1294. * post_op_attr obj_attributes;
  1295. * post_op_attr dir_attributes;
  1296. * };
  1297. *
  1298. * struct LOOKUP3resfail {
  1299. * post_op_attr dir_attributes;
  1300. * };
  1301. *
  1302. * union LOOKUP3res switch (nfsstat3 status) {
  1303. * case NFS3_OK:
  1304. * LOOKUP3resok resok;
  1305. * default:
  1306. * LOOKUP3resfail resfail;
  1307. * };
  1308. */
  1309. static int nfs3_xdr_dec_lookup3res(struct rpc_rqst *req,
  1310. struct xdr_stream *xdr,
  1311. void *data)
  1312. {
  1313. struct user_namespace *userns = rpc_rqst_userns(req);
  1314. struct nfs3_diropres *result = data;
  1315. enum nfs_stat status;
  1316. int error;
  1317. error = decode_nfsstat3(xdr, &status);
  1318. if (unlikely(error))
  1319. goto out;
  1320. if (status != NFS3_OK)
  1321. goto out_default;
  1322. error = decode_nfs_fh3(xdr, result->fh);
  1323. if (unlikely(error))
  1324. goto out;
  1325. error = decode_post_op_attr(xdr, result->fattr, userns);
  1326. if (unlikely(error))
  1327. goto out;
  1328. error = decode_post_op_attr(xdr, result->dir_attr, userns);
  1329. out:
  1330. return error;
  1331. out_default:
  1332. error = decode_post_op_attr(xdr, result->dir_attr, userns);
  1333. if (unlikely(error))
  1334. goto out;
  1335. return nfs3_stat_to_errno(status);
  1336. }
  1337. /*
  1338. * 3.3.4 ACCESS3res
  1339. *
  1340. * struct ACCESS3resok {
  1341. * post_op_attr obj_attributes;
  1342. * uint32 access;
  1343. * };
  1344. *
  1345. * struct ACCESS3resfail {
  1346. * post_op_attr obj_attributes;
  1347. * };
  1348. *
  1349. * union ACCESS3res switch (nfsstat3 status) {
  1350. * case NFS3_OK:
  1351. * ACCESS3resok resok;
  1352. * default:
  1353. * ACCESS3resfail resfail;
  1354. * };
  1355. */
  1356. static int nfs3_xdr_dec_access3res(struct rpc_rqst *req,
  1357. struct xdr_stream *xdr,
  1358. void *data)
  1359. {
  1360. struct nfs3_accessres *result = data;
  1361. enum nfs_stat status;
  1362. int error;
  1363. error = decode_nfsstat3(xdr, &status);
  1364. if (unlikely(error))
  1365. goto out;
  1366. error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
  1367. if (unlikely(error))
  1368. goto out;
  1369. if (status != NFS3_OK)
  1370. goto out_default;
  1371. error = decode_uint32(xdr, &result->access);
  1372. out:
  1373. return error;
  1374. out_default:
  1375. return nfs3_stat_to_errno(status);
  1376. }
  1377. /*
  1378. * 3.3.5 READLINK3res
  1379. *
  1380. * struct READLINK3resok {
  1381. * post_op_attr symlink_attributes;
  1382. * nfspath3 data;
  1383. * };
  1384. *
  1385. * struct READLINK3resfail {
  1386. * post_op_attr symlink_attributes;
  1387. * };
  1388. *
  1389. * union READLINK3res switch (nfsstat3 status) {
  1390. * case NFS3_OK:
  1391. * READLINK3resok resok;
  1392. * default:
  1393. * READLINK3resfail resfail;
  1394. * };
  1395. */
  1396. static int nfs3_xdr_dec_readlink3res(struct rpc_rqst *req,
  1397. struct xdr_stream *xdr,
  1398. void *result)
  1399. {
  1400. enum nfs_stat status;
  1401. int error;
  1402. error = decode_nfsstat3(xdr, &status);
  1403. if (unlikely(error))
  1404. goto out;
  1405. error = decode_post_op_attr(xdr, result, rpc_rqst_userns(req));
  1406. if (unlikely(error))
  1407. goto out;
  1408. if (status != NFS3_OK)
  1409. goto out_default;
  1410. error = decode_nfspath3(xdr);
  1411. out:
  1412. return error;
  1413. out_default:
  1414. return nfs3_stat_to_errno(status);
  1415. }
  1416. /*
  1417. * 3.3.6 READ3res
  1418. *
  1419. * struct READ3resok {
  1420. * post_op_attr file_attributes;
  1421. * count3 count;
  1422. * bool eof;
  1423. * opaque data<>;
  1424. * };
  1425. *
  1426. * struct READ3resfail {
  1427. * post_op_attr file_attributes;
  1428. * };
  1429. *
  1430. * union READ3res switch (nfsstat3 status) {
  1431. * case NFS3_OK:
  1432. * READ3resok resok;
  1433. * default:
  1434. * READ3resfail resfail;
  1435. * };
  1436. */
  1437. static int decode_read3resok(struct xdr_stream *xdr,
  1438. struct nfs_pgio_res *result)
  1439. {
  1440. u32 eof, count, ocount, recvd;
  1441. __be32 *p;
  1442. p = xdr_inline_decode(xdr, 4 + 4 + 4);
  1443. if (unlikely(!p))
  1444. return -EIO;
  1445. count = be32_to_cpup(p++);
  1446. eof = be32_to_cpup(p++);
  1447. ocount = be32_to_cpup(p++);
  1448. if (unlikely(ocount != count))
  1449. goto out_mismatch;
  1450. recvd = xdr_read_pages(xdr, count);
  1451. if (unlikely(count > recvd))
  1452. goto out_cheating;
  1453. out:
  1454. result->eof = eof;
  1455. result->count = count;
  1456. return count;
  1457. out_mismatch:
  1458. dprintk("NFS: READ count doesn't match length of opaque: "
  1459. "count %u != ocount %u\n", count, ocount);
  1460. return -EIO;
  1461. out_cheating:
  1462. dprintk("NFS: server cheating in read result: "
  1463. "count %u > recvd %u\n", count, recvd);
  1464. count = recvd;
  1465. eof = 0;
  1466. goto out;
  1467. }
  1468. static int nfs3_xdr_dec_read3res(struct rpc_rqst *req, struct xdr_stream *xdr,
  1469. void *data)
  1470. {
  1471. struct nfs_pgio_res *result = data;
  1472. unsigned int pos;
  1473. enum nfs_stat status;
  1474. int error;
  1475. pos = xdr_stream_pos(xdr);
  1476. error = decode_nfsstat3(xdr, &status);
  1477. if (unlikely(error))
  1478. goto out;
  1479. error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
  1480. if (unlikely(error))
  1481. goto out;
  1482. result->op_status = status;
  1483. if (status != NFS3_OK)
  1484. goto out_status;
  1485. result->replen = 4 + ((xdr_stream_pos(xdr) - pos) >> 2);
  1486. error = decode_read3resok(xdr, result);
  1487. out:
  1488. return error;
  1489. out_status:
  1490. return nfs3_stat_to_errno(status);
  1491. }
  1492. /*
  1493. * 3.3.7 WRITE3res
  1494. *
  1495. * enum stable_how {
  1496. * UNSTABLE = 0,
  1497. * DATA_SYNC = 1,
  1498. * FILE_SYNC = 2
  1499. * };
  1500. *
  1501. * struct WRITE3resok {
  1502. * wcc_data file_wcc;
  1503. * count3 count;
  1504. * stable_how committed;
  1505. * writeverf3 verf;
  1506. * };
  1507. *
  1508. * struct WRITE3resfail {
  1509. * wcc_data file_wcc;
  1510. * };
  1511. *
  1512. * union WRITE3res switch (nfsstat3 status) {
  1513. * case NFS3_OK:
  1514. * WRITE3resok resok;
  1515. * default:
  1516. * WRITE3resfail resfail;
  1517. * };
  1518. */
  1519. static int decode_write3resok(struct xdr_stream *xdr,
  1520. struct nfs_pgio_res *result)
  1521. {
  1522. __be32 *p;
  1523. p = xdr_inline_decode(xdr, 4 + 4);
  1524. if (unlikely(!p))
  1525. return -EIO;
  1526. result->count = be32_to_cpup(p++);
  1527. result->verf->committed = be32_to_cpup(p++);
  1528. if (unlikely(result->verf->committed > NFS_FILE_SYNC))
  1529. goto out_badvalue;
  1530. if (decode_writeverf3(xdr, &result->verf->verifier))
  1531. return -EIO;
  1532. return result->count;
  1533. out_badvalue:
  1534. dprintk("NFS: bad stable_how value: %u\n", result->verf->committed);
  1535. return -EIO;
  1536. }
  1537. static int nfs3_xdr_dec_write3res(struct rpc_rqst *req, struct xdr_stream *xdr,
  1538. void *data)
  1539. {
  1540. struct nfs_pgio_res *result = data;
  1541. enum nfs_stat status;
  1542. int error;
  1543. error = decode_nfsstat3(xdr, &status);
  1544. if (unlikely(error))
  1545. goto out;
  1546. error = decode_wcc_data(xdr, result->fattr, rpc_rqst_userns(req));
  1547. if (unlikely(error))
  1548. goto out;
  1549. result->op_status = status;
  1550. if (status != NFS3_OK)
  1551. goto out_status;
  1552. error = decode_write3resok(xdr, result);
  1553. out:
  1554. return error;
  1555. out_status:
  1556. return nfs3_stat_to_errno(status);
  1557. }
  1558. /*
  1559. * 3.3.8 CREATE3res
  1560. *
  1561. * struct CREATE3resok {
  1562. * post_op_fh3 obj;
  1563. * post_op_attr obj_attributes;
  1564. * wcc_data dir_wcc;
  1565. * };
  1566. *
  1567. * struct CREATE3resfail {
  1568. * wcc_data dir_wcc;
  1569. * };
  1570. *
  1571. * union CREATE3res switch (nfsstat3 status) {
  1572. * case NFS3_OK:
  1573. * CREATE3resok resok;
  1574. * default:
  1575. * CREATE3resfail resfail;
  1576. * };
  1577. */
  1578. static int decode_create3resok(struct xdr_stream *xdr,
  1579. struct nfs3_diropres *result,
  1580. struct user_namespace *userns)
  1581. {
  1582. int error;
  1583. error = decode_post_op_fh3(xdr, result->fh);
  1584. if (unlikely(error))
  1585. goto out;
  1586. error = decode_post_op_attr(xdr, result->fattr, userns);
  1587. if (unlikely(error))
  1588. goto out;
  1589. /* The server isn't required to return a file handle.
  1590. * If it didn't, force the client to perform a LOOKUP
  1591. * to determine the correct file handle and attribute
  1592. * values for the new object. */
  1593. if (result->fh->size == 0)
  1594. result->fattr->valid = 0;
  1595. error = decode_wcc_data(xdr, result->dir_attr, userns);
  1596. out:
  1597. return error;
  1598. }
  1599. static int nfs3_xdr_dec_create3res(struct rpc_rqst *req,
  1600. struct xdr_stream *xdr,
  1601. void *data)
  1602. {
  1603. struct user_namespace *userns = rpc_rqst_userns(req);
  1604. struct nfs3_diropres *result = data;
  1605. enum nfs_stat status;
  1606. int error;
  1607. error = decode_nfsstat3(xdr, &status);
  1608. if (unlikely(error))
  1609. goto out;
  1610. if (status != NFS3_OK)
  1611. goto out_default;
  1612. error = decode_create3resok(xdr, result, userns);
  1613. out:
  1614. return error;
  1615. out_default:
  1616. error = decode_wcc_data(xdr, result->dir_attr, userns);
  1617. if (unlikely(error))
  1618. goto out;
  1619. return nfs3_stat_to_errno(status);
  1620. }
  1621. /*
  1622. * 3.3.12 REMOVE3res
  1623. *
  1624. * struct REMOVE3resok {
  1625. * wcc_data dir_wcc;
  1626. * };
  1627. *
  1628. * struct REMOVE3resfail {
  1629. * wcc_data dir_wcc;
  1630. * };
  1631. *
  1632. * union REMOVE3res switch (nfsstat3 status) {
  1633. * case NFS3_OK:
  1634. * REMOVE3resok resok;
  1635. * default:
  1636. * REMOVE3resfail resfail;
  1637. * };
  1638. */
  1639. static int nfs3_xdr_dec_remove3res(struct rpc_rqst *req,
  1640. struct xdr_stream *xdr,
  1641. void *data)
  1642. {
  1643. struct nfs_removeres *result = data;
  1644. enum nfs_stat status;
  1645. int error;
  1646. error = decode_nfsstat3(xdr, &status);
  1647. if (unlikely(error))
  1648. goto out;
  1649. error = decode_wcc_data(xdr, result->dir_attr, rpc_rqst_userns(req));
  1650. if (unlikely(error))
  1651. goto out;
  1652. if (status != NFS3_OK)
  1653. goto out_status;
  1654. out:
  1655. return error;
  1656. out_status:
  1657. return nfs3_stat_to_errno(status);
  1658. }
  1659. /*
  1660. * 3.3.14 RENAME3res
  1661. *
  1662. * struct RENAME3resok {
  1663. * wcc_data fromdir_wcc;
  1664. * wcc_data todir_wcc;
  1665. * };
  1666. *
  1667. * struct RENAME3resfail {
  1668. * wcc_data fromdir_wcc;
  1669. * wcc_data todir_wcc;
  1670. * };
  1671. *
  1672. * union RENAME3res switch (nfsstat3 status) {
  1673. * case NFS3_OK:
  1674. * RENAME3resok resok;
  1675. * default:
  1676. * RENAME3resfail resfail;
  1677. * };
  1678. */
  1679. static int nfs3_xdr_dec_rename3res(struct rpc_rqst *req,
  1680. struct xdr_stream *xdr,
  1681. void *data)
  1682. {
  1683. struct user_namespace *userns = rpc_rqst_userns(req);
  1684. struct nfs_renameres *result = data;
  1685. enum nfs_stat status;
  1686. int error;
  1687. error = decode_nfsstat3(xdr, &status);
  1688. if (unlikely(error))
  1689. goto out;
  1690. error = decode_wcc_data(xdr, result->old_fattr, userns);
  1691. if (unlikely(error))
  1692. goto out;
  1693. error = decode_wcc_data(xdr, result->new_fattr, userns);
  1694. if (unlikely(error))
  1695. goto out;
  1696. if (status != NFS3_OK)
  1697. goto out_status;
  1698. out:
  1699. return error;
  1700. out_status:
  1701. return nfs3_stat_to_errno(status);
  1702. }
  1703. /*
  1704. * 3.3.15 LINK3res
  1705. *
  1706. * struct LINK3resok {
  1707. * post_op_attr file_attributes;
  1708. * wcc_data linkdir_wcc;
  1709. * };
  1710. *
  1711. * struct LINK3resfail {
  1712. * post_op_attr file_attributes;
  1713. * wcc_data linkdir_wcc;
  1714. * };
  1715. *
  1716. * union LINK3res switch (nfsstat3 status) {
  1717. * case NFS3_OK:
  1718. * LINK3resok resok;
  1719. * default:
  1720. * LINK3resfail resfail;
  1721. * };
  1722. */
  1723. static int nfs3_xdr_dec_link3res(struct rpc_rqst *req, struct xdr_stream *xdr,
  1724. void *data)
  1725. {
  1726. struct user_namespace *userns = rpc_rqst_userns(req);
  1727. struct nfs3_linkres *result = data;
  1728. enum nfs_stat status;
  1729. int error;
  1730. error = decode_nfsstat3(xdr, &status);
  1731. if (unlikely(error))
  1732. goto out;
  1733. error = decode_post_op_attr(xdr, result->fattr, userns);
  1734. if (unlikely(error))
  1735. goto out;
  1736. error = decode_wcc_data(xdr, result->dir_attr, userns);
  1737. if (unlikely(error))
  1738. goto out;
  1739. if (status != NFS3_OK)
  1740. goto out_status;
  1741. out:
  1742. return error;
  1743. out_status:
  1744. return nfs3_stat_to_errno(status);
  1745. }
  1746. /**
  1747. * nfs3_decode_dirent - Decode a single NFSv3 directory entry stored in
  1748. * the local page cache
  1749. * @xdr: XDR stream where entry resides
  1750. * @entry: buffer to fill in with entry data
  1751. * @plus: boolean indicating whether this should be a readdirplus entry
  1752. *
  1753. * Returns zero if successful, otherwise a negative errno value is
  1754. * returned.
  1755. *
  1756. * This function is not invoked during READDIR reply decoding, but
  1757. * rather whenever an application invokes the getdents(2) system call
  1758. * on a directory already in our cache.
  1759. *
  1760. * 3.3.16 entry3
  1761. *
  1762. * struct entry3 {
  1763. * fileid3 fileid;
  1764. * filename3 name;
  1765. * cookie3 cookie;
  1766. * fhandle3 filehandle;
  1767. * post_op_attr3 attributes;
  1768. * entry3 *nextentry;
  1769. * };
  1770. *
  1771. * 3.3.17 entryplus3
  1772. * struct entryplus3 {
  1773. * fileid3 fileid;
  1774. * filename3 name;
  1775. * cookie3 cookie;
  1776. * post_op_attr name_attributes;
  1777. * post_op_fh3 name_handle;
  1778. * entryplus3 *nextentry;
  1779. * };
  1780. */
  1781. int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
  1782. bool plus)
  1783. {
  1784. struct user_namespace *userns = rpc_userns(entry->server->client);
  1785. __be32 *p;
  1786. int error;
  1787. u64 new_cookie;
  1788. p = xdr_inline_decode(xdr, 4);
  1789. if (unlikely(!p))
  1790. return -EAGAIN;
  1791. if (*p == xdr_zero) {
  1792. p = xdr_inline_decode(xdr, 4);
  1793. if (unlikely(!p))
  1794. return -EAGAIN;
  1795. if (*p == xdr_zero)
  1796. return -EAGAIN;
  1797. entry->eof = 1;
  1798. return -EBADCOOKIE;
  1799. }
  1800. error = decode_fileid3(xdr, &entry->ino);
  1801. if (unlikely(error))
  1802. return -EAGAIN;
  1803. error = decode_inline_filename3(xdr, &entry->name, &entry->len);
  1804. if (unlikely(error))
  1805. return -EAGAIN;
  1806. error = decode_cookie3(xdr, &new_cookie);
  1807. if (unlikely(error))
  1808. return -EAGAIN;
  1809. entry->d_type = DT_UNKNOWN;
  1810. if (plus) {
  1811. entry->fattr->valid = 0;
  1812. error = decode_post_op_attr(xdr, entry->fattr, userns);
  1813. if (unlikely(error))
  1814. return -EAGAIN;
  1815. if (entry->fattr->valid & NFS_ATTR_FATTR_V3)
  1816. entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
  1817. if (entry->fattr->fileid != entry->ino) {
  1818. entry->fattr->mounted_on_fileid = entry->ino;
  1819. entry->fattr->valid |= NFS_ATTR_FATTR_MOUNTED_ON_FILEID;
  1820. }
  1821. /* In fact, a post_op_fh3: */
  1822. p = xdr_inline_decode(xdr, 4);
  1823. if (unlikely(!p))
  1824. return -EAGAIN;
  1825. if (*p != xdr_zero) {
  1826. error = decode_nfs_fh3(xdr, entry->fh);
  1827. if (unlikely(error))
  1828. return -EAGAIN;
  1829. } else
  1830. zero_nfs_fh3(entry->fh);
  1831. }
  1832. entry->prev_cookie = entry->cookie;
  1833. entry->cookie = new_cookie;
  1834. return 0;
  1835. }
  1836. /*
  1837. * 3.3.16 READDIR3res
  1838. *
  1839. * struct dirlist3 {
  1840. * entry3 *entries;
  1841. * bool eof;
  1842. * };
  1843. *
  1844. * struct READDIR3resok {
  1845. * post_op_attr dir_attributes;
  1846. * cookieverf3 cookieverf;
  1847. * dirlist3 reply;
  1848. * };
  1849. *
  1850. * struct READDIR3resfail {
  1851. * post_op_attr dir_attributes;
  1852. * };
  1853. *
  1854. * union READDIR3res switch (nfsstat3 status) {
  1855. * case NFS3_OK:
  1856. * READDIR3resok resok;
  1857. * default:
  1858. * READDIR3resfail resfail;
  1859. * };
  1860. *
  1861. * Read the directory contents into the page cache, but otherwise
  1862. * don't touch them. The actual decoding is done by nfs3_decode_entry()
  1863. * during subsequent nfs_readdir() calls.
  1864. */
  1865. static int decode_dirlist3(struct xdr_stream *xdr)
  1866. {
  1867. return xdr_read_pages(xdr, xdr->buf->page_len);
  1868. }
  1869. static int decode_readdir3resok(struct xdr_stream *xdr,
  1870. struct nfs3_readdirres *result,
  1871. struct user_namespace *userns)
  1872. {
  1873. int error;
  1874. error = decode_post_op_attr(xdr, result->dir_attr, userns);
  1875. if (unlikely(error))
  1876. goto out;
  1877. /* XXX: do we need to check if result->verf != NULL ? */
  1878. error = decode_cookieverf3(xdr, result->verf);
  1879. if (unlikely(error))
  1880. goto out;
  1881. error = decode_dirlist3(xdr);
  1882. out:
  1883. return error;
  1884. }
  1885. static int nfs3_xdr_dec_readdir3res(struct rpc_rqst *req,
  1886. struct xdr_stream *xdr,
  1887. void *data)
  1888. {
  1889. struct nfs3_readdirres *result = data;
  1890. enum nfs_stat status;
  1891. int error;
  1892. error = decode_nfsstat3(xdr, &status);
  1893. if (unlikely(error))
  1894. goto out;
  1895. if (status != NFS3_OK)
  1896. goto out_default;
  1897. error = decode_readdir3resok(xdr, result, rpc_rqst_userns(req));
  1898. out:
  1899. return error;
  1900. out_default:
  1901. error = decode_post_op_attr(xdr, result->dir_attr, rpc_rqst_userns(req));
  1902. if (unlikely(error))
  1903. goto out;
  1904. return nfs3_stat_to_errno(status);
  1905. }
  1906. /*
  1907. * 3.3.18 FSSTAT3res
  1908. *
  1909. * struct FSSTAT3resok {
  1910. * post_op_attr obj_attributes;
  1911. * size3 tbytes;
  1912. * size3 fbytes;
  1913. * size3 abytes;
  1914. * size3 tfiles;
  1915. * size3 ffiles;
  1916. * size3 afiles;
  1917. * uint32 invarsec;
  1918. * };
  1919. *
  1920. * struct FSSTAT3resfail {
  1921. * post_op_attr obj_attributes;
  1922. * };
  1923. *
  1924. * union FSSTAT3res switch (nfsstat3 status) {
  1925. * case NFS3_OK:
  1926. * FSSTAT3resok resok;
  1927. * default:
  1928. * FSSTAT3resfail resfail;
  1929. * };
  1930. */
  1931. static int decode_fsstat3resok(struct xdr_stream *xdr,
  1932. struct nfs_fsstat *result)
  1933. {
  1934. __be32 *p;
  1935. p = xdr_inline_decode(xdr, 8 * 6 + 4);
  1936. if (unlikely(!p))
  1937. return -EIO;
  1938. p = xdr_decode_size3(p, &result->tbytes);
  1939. p = xdr_decode_size3(p, &result->fbytes);
  1940. p = xdr_decode_size3(p, &result->abytes);
  1941. p = xdr_decode_size3(p, &result->tfiles);
  1942. p = xdr_decode_size3(p, &result->ffiles);
  1943. xdr_decode_size3(p, &result->afiles);
  1944. /* ignore invarsec */
  1945. return 0;
  1946. }
  1947. static int nfs3_xdr_dec_fsstat3res(struct rpc_rqst *req,
  1948. struct xdr_stream *xdr,
  1949. void *data)
  1950. {
  1951. struct nfs_fsstat *result = data;
  1952. enum nfs_stat status;
  1953. int error;
  1954. error = decode_nfsstat3(xdr, &status);
  1955. if (unlikely(error))
  1956. goto out;
  1957. error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
  1958. if (unlikely(error))
  1959. goto out;
  1960. if (status != NFS3_OK)
  1961. goto out_status;
  1962. error = decode_fsstat3resok(xdr, result);
  1963. out:
  1964. return error;
  1965. out_status:
  1966. return nfs3_stat_to_errno(status);
  1967. }
  1968. /*
  1969. * 3.3.19 FSINFO3res
  1970. *
  1971. * struct FSINFO3resok {
  1972. * post_op_attr obj_attributes;
  1973. * uint32 rtmax;
  1974. * uint32 rtpref;
  1975. * uint32 rtmult;
  1976. * uint32 wtmax;
  1977. * uint32 wtpref;
  1978. * uint32 wtmult;
  1979. * uint32 dtpref;
  1980. * size3 maxfilesize;
  1981. * nfstime3 time_delta;
  1982. * uint32 properties;
  1983. * };
  1984. *
  1985. * struct FSINFO3resfail {
  1986. * post_op_attr obj_attributes;
  1987. * };
  1988. *
  1989. * union FSINFO3res switch (nfsstat3 status) {
  1990. * case NFS3_OK:
  1991. * FSINFO3resok resok;
  1992. * default:
  1993. * FSINFO3resfail resfail;
  1994. * };
  1995. */
  1996. static int decode_fsinfo3resok(struct xdr_stream *xdr,
  1997. struct nfs_fsinfo *result)
  1998. {
  1999. __be32 *p;
  2000. p = xdr_inline_decode(xdr, 4 * 7 + 8 + 8 + 4);
  2001. if (unlikely(!p))
  2002. return -EIO;
  2003. result->rtmax = be32_to_cpup(p++);
  2004. result->rtpref = be32_to_cpup(p++);
  2005. result->rtmult = be32_to_cpup(p++);
  2006. result->wtmax = be32_to_cpup(p++);
  2007. result->wtpref = be32_to_cpup(p++);
  2008. result->wtmult = be32_to_cpup(p++);
  2009. result->dtpref = be32_to_cpup(p++);
  2010. p = xdr_decode_size3(p, &result->maxfilesize);
  2011. xdr_decode_nfstime3(p, &result->time_delta);
  2012. /* ignore properties */
  2013. result->lease_time = 0;
  2014. return 0;
  2015. }
  2016. static int nfs3_xdr_dec_fsinfo3res(struct rpc_rqst *req,
  2017. struct xdr_stream *xdr,
  2018. void *data)
  2019. {
  2020. struct nfs_fsinfo *result = data;
  2021. enum nfs_stat status;
  2022. int error;
  2023. error = decode_nfsstat3(xdr, &status);
  2024. if (unlikely(error))
  2025. goto out;
  2026. error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
  2027. if (unlikely(error))
  2028. goto out;
  2029. if (status != NFS3_OK)
  2030. goto out_status;
  2031. error = decode_fsinfo3resok(xdr, result);
  2032. out:
  2033. return error;
  2034. out_status:
  2035. return nfs3_stat_to_errno(status);
  2036. }
  2037. /*
  2038. * 3.3.20 PATHCONF3res
  2039. *
  2040. * struct PATHCONF3resok {
  2041. * post_op_attr obj_attributes;
  2042. * uint32 linkmax;
  2043. * uint32 name_max;
  2044. * bool no_trunc;
  2045. * bool chown_restricted;
  2046. * bool case_insensitive;
  2047. * bool case_preserving;
  2048. * };
  2049. *
  2050. * struct PATHCONF3resfail {
  2051. * post_op_attr obj_attributes;
  2052. * };
  2053. *
  2054. * union PATHCONF3res switch (nfsstat3 status) {
  2055. * case NFS3_OK:
  2056. * PATHCONF3resok resok;
  2057. * default:
  2058. * PATHCONF3resfail resfail;
  2059. * };
  2060. */
  2061. static int decode_pathconf3resok(struct xdr_stream *xdr,
  2062. struct nfs_pathconf *result)
  2063. {
  2064. __be32 *p;
  2065. p = xdr_inline_decode(xdr, 4 * 6);
  2066. if (unlikely(!p))
  2067. return -EIO;
  2068. result->max_link = be32_to_cpup(p++);
  2069. result->max_namelen = be32_to_cpup(p);
  2070. /* ignore remaining fields */
  2071. return 0;
  2072. }
  2073. static int nfs3_xdr_dec_pathconf3res(struct rpc_rqst *req,
  2074. struct xdr_stream *xdr,
  2075. void *data)
  2076. {
  2077. struct nfs_pathconf *result = data;
  2078. enum nfs_stat status;
  2079. int error;
  2080. error = decode_nfsstat3(xdr, &status);
  2081. if (unlikely(error))
  2082. goto out;
  2083. error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
  2084. if (unlikely(error))
  2085. goto out;
  2086. if (status != NFS3_OK)
  2087. goto out_status;
  2088. error = decode_pathconf3resok(xdr, result);
  2089. out:
  2090. return error;
  2091. out_status:
  2092. return nfs3_stat_to_errno(status);
  2093. }
  2094. /*
  2095. * 3.3.21 COMMIT3res
  2096. *
  2097. * struct COMMIT3resok {
  2098. * wcc_data file_wcc;
  2099. * writeverf3 verf;
  2100. * };
  2101. *
  2102. * struct COMMIT3resfail {
  2103. * wcc_data file_wcc;
  2104. * };
  2105. *
  2106. * union COMMIT3res switch (nfsstat3 status) {
  2107. * case NFS3_OK:
  2108. * COMMIT3resok resok;
  2109. * default:
  2110. * COMMIT3resfail resfail;
  2111. * };
  2112. */
  2113. static int nfs3_xdr_dec_commit3res(struct rpc_rqst *req,
  2114. struct xdr_stream *xdr,
  2115. void *data)
  2116. {
  2117. struct nfs_commitres *result = data;
  2118. struct nfs_writeverf *verf = result->verf;
  2119. enum nfs_stat status;
  2120. int error;
  2121. error = decode_nfsstat3(xdr, &status);
  2122. if (unlikely(error))
  2123. goto out;
  2124. error = decode_wcc_data(xdr, result->fattr, rpc_rqst_userns(req));
  2125. if (unlikely(error))
  2126. goto out;
  2127. result->op_status = status;
  2128. if (status != NFS3_OK)
  2129. goto out_status;
  2130. error = decode_writeverf3(xdr, &verf->verifier);
  2131. if (!error)
  2132. verf->committed = NFS_FILE_SYNC;
  2133. out:
  2134. return error;
  2135. out_status:
  2136. return nfs3_stat_to_errno(status);
  2137. }
  2138. #ifdef CONFIG_NFS_V3_ACL
  2139. static inline int decode_getacl3resok(struct xdr_stream *xdr,
  2140. struct nfs3_getaclres *result,
  2141. struct user_namespace *userns)
  2142. {
  2143. struct posix_acl **acl;
  2144. unsigned int *aclcnt;
  2145. size_t hdrlen;
  2146. int error;
  2147. error = decode_post_op_attr(xdr, result->fattr, userns);
  2148. if (unlikely(error))
  2149. goto out;
  2150. error = decode_uint32(xdr, &result->mask);
  2151. if (unlikely(error))
  2152. goto out;
  2153. error = -EINVAL;
  2154. if (result->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
  2155. goto out;
  2156. hdrlen = xdr_stream_pos(xdr);
  2157. acl = NULL;
  2158. if (result->mask & NFS_ACL)
  2159. acl = &result->acl_access;
  2160. aclcnt = NULL;
  2161. if (result->mask & NFS_ACLCNT)
  2162. aclcnt = &result->acl_access_count;
  2163. error = nfsacl_decode(xdr->buf, hdrlen, aclcnt, acl);
  2164. if (unlikely(error <= 0))
  2165. goto out;
  2166. acl = NULL;
  2167. if (result->mask & NFS_DFACL)
  2168. acl = &result->acl_default;
  2169. aclcnt = NULL;
  2170. if (result->mask & NFS_DFACLCNT)
  2171. aclcnt = &result->acl_default_count;
  2172. error = nfsacl_decode(xdr->buf, hdrlen + error, aclcnt, acl);
  2173. if (unlikely(error <= 0))
  2174. return error;
  2175. error = 0;
  2176. out:
  2177. return error;
  2178. }
  2179. static int nfs3_xdr_dec_getacl3res(struct rpc_rqst *req,
  2180. struct xdr_stream *xdr,
  2181. void *result)
  2182. {
  2183. enum nfs_stat status;
  2184. int error;
  2185. error = decode_nfsstat3(xdr, &status);
  2186. if (unlikely(error))
  2187. goto out;
  2188. if (status != NFS3_OK)
  2189. goto out_default;
  2190. error = decode_getacl3resok(xdr, result, rpc_rqst_userns(req));
  2191. out:
  2192. return error;
  2193. out_default:
  2194. return nfs3_stat_to_errno(status);
  2195. }
  2196. static int nfs3_xdr_dec_setacl3res(struct rpc_rqst *req,
  2197. struct xdr_stream *xdr,
  2198. void *result)
  2199. {
  2200. enum nfs_stat status;
  2201. int error;
  2202. error = decode_nfsstat3(xdr, &status);
  2203. if (unlikely(error))
  2204. goto out;
  2205. if (status != NFS3_OK)
  2206. goto out_default;
  2207. error = decode_post_op_attr(xdr, result, rpc_rqst_userns(req));
  2208. out:
  2209. return error;
  2210. out_default:
  2211. return nfs3_stat_to_errno(status);
  2212. }
  2213. #endif /* CONFIG_NFS_V3_ACL */
  2214. /*
  2215. * We need to translate between nfs status return values and
  2216. * the local errno values which may not be the same.
  2217. */
  2218. static const struct {
  2219. int stat;
  2220. int errno;
  2221. } nfs_errtbl[] = {
  2222. { NFS_OK, 0 },
  2223. { NFSERR_PERM, -EPERM },
  2224. { NFSERR_NOENT, -ENOENT },
  2225. { NFSERR_IO, -errno_NFSERR_IO},
  2226. { NFSERR_NXIO, -ENXIO },
  2227. /* { NFSERR_EAGAIN, -EAGAIN }, */
  2228. { NFSERR_ACCES, -EACCES },
  2229. { NFSERR_EXIST, -EEXIST },
  2230. { NFSERR_XDEV, -EXDEV },
  2231. { NFSERR_NODEV, -ENODEV },
  2232. { NFSERR_NOTDIR, -ENOTDIR },
  2233. { NFSERR_ISDIR, -EISDIR },
  2234. { NFSERR_INVAL, -EINVAL },
  2235. { NFSERR_FBIG, -EFBIG },
  2236. { NFSERR_NOSPC, -ENOSPC },
  2237. { NFSERR_ROFS, -EROFS },
  2238. { NFSERR_MLINK, -EMLINK },
  2239. { NFSERR_NAMETOOLONG, -ENAMETOOLONG },
  2240. { NFSERR_NOTEMPTY, -ENOTEMPTY },
  2241. { NFSERR_DQUOT, -EDQUOT },
  2242. { NFSERR_STALE, -ESTALE },
  2243. { NFSERR_REMOTE, -EREMOTE },
  2244. #ifdef EWFLUSH
  2245. { NFSERR_WFLUSH, -EWFLUSH },
  2246. #endif
  2247. { NFSERR_BADHANDLE, -EBADHANDLE },
  2248. { NFSERR_NOT_SYNC, -ENOTSYNC },
  2249. { NFSERR_BAD_COOKIE, -EBADCOOKIE },
  2250. { NFSERR_NOTSUPP, -ENOTSUPP },
  2251. { NFSERR_TOOSMALL, -ETOOSMALL },
  2252. { NFSERR_SERVERFAULT, -EREMOTEIO },
  2253. { NFSERR_BADTYPE, -EBADTYPE },
  2254. { NFSERR_JUKEBOX, -EJUKEBOX },
  2255. { -1, -EIO }
  2256. };
  2257. /**
  2258. * nfs3_stat_to_errno - convert an NFS status code to a local errno
  2259. * @status: NFS status code to convert
  2260. *
  2261. * Returns a local errno value, or -EIO if the NFS status code is
  2262. * not recognized. This function is used jointly by NFSv2 and NFSv3.
  2263. */
  2264. static int nfs3_stat_to_errno(enum nfs_stat status)
  2265. {
  2266. int i;
  2267. for (i = 0; nfs_errtbl[i].stat != -1; i++) {
  2268. if (nfs_errtbl[i].stat == (int)status)
  2269. return nfs_errtbl[i].errno;
  2270. }
  2271. dprintk("NFS: Unrecognized nfs status value: %u\n", status);
  2272. return nfs_errtbl[i].errno;
  2273. }
  2274. #define PROC(proc, argtype, restype, timer) \
  2275. [NFS3PROC_##proc] = { \
  2276. .p_proc = NFS3PROC_##proc, \
  2277. .p_encode = nfs3_xdr_enc_##argtype##3args, \
  2278. .p_decode = nfs3_xdr_dec_##restype##3res, \
  2279. .p_arglen = NFS3_##argtype##args_sz, \
  2280. .p_replen = NFS3_##restype##res_sz, \
  2281. .p_timer = timer, \
  2282. .p_statidx = NFS3PROC_##proc, \
  2283. .p_name = #proc, \
  2284. }
  2285. const struct rpc_procinfo nfs3_procedures[] = {
  2286. PROC(GETATTR, getattr, getattr, 1),
  2287. PROC(SETATTR, setattr, setattr, 0),
  2288. PROC(LOOKUP, lookup, lookup, 2),
  2289. PROC(ACCESS, access, access, 1),
  2290. PROC(READLINK, readlink, readlink, 3),
  2291. PROC(READ, read, read, 3),
  2292. PROC(WRITE, write, write, 4),
  2293. PROC(CREATE, create, create, 0),
  2294. PROC(MKDIR, mkdir, create, 0),
  2295. PROC(SYMLINK, symlink, create, 0),
  2296. PROC(MKNOD, mknod, create, 0),
  2297. PROC(REMOVE, remove, remove, 0),
  2298. PROC(RMDIR, lookup, setattr, 0),
  2299. PROC(RENAME, rename, rename, 0),
  2300. PROC(LINK, link, link, 0),
  2301. PROC(READDIR, readdir, readdir, 3),
  2302. PROC(READDIRPLUS, readdirplus, readdir, 3),
  2303. PROC(FSSTAT, getattr, fsstat, 0),
  2304. PROC(FSINFO, getattr, fsinfo, 0),
  2305. PROC(PATHCONF, getattr, pathconf, 0),
  2306. PROC(COMMIT, commit, commit, 5),
  2307. };
  2308. static unsigned int nfs_version3_counts[ARRAY_SIZE(nfs3_procedures)];
  2309. const struct rpc_version nfs_version3 = {
  2310. .number = 3,
  2311. .nrprocs = ARRAY_SIZE(nfs3_procedures),
  2312. .procs = nfs3_procedures,
  2313. .counts = nfs_version3_counts,
  2314. };
  2315. #ifdef CONFIG_NFS_V3_ACL
  2316. static const struct rpc_procinfo nfs3_acl_procedures[] = {
  2317. [ACLPROC3_GETACL] = {
  2318. .p_proc = ACLPROC3_GETACL,
  2319. .p_encode = nfs3_xdr_enc_getacl3args,
  2320. .p_decode = nfs3_xdr_dec_getacl3res,
  2321. .p_arglen = ACL3_getaclargs_sz,
  2322. .p_replen = ACL3_getaclres_sz,
  2323. .p_timer = 1,
  2324. .p_name = "GETACL",
  2325. },
  2326. [ACLPROC3_SETACL] = {
  2327. .p_proc = ACLPROC3_SETACL,
  2328. .p_encode = nfs3_xdr_enc_setacl3args,
  2329. .p_decode = nfs3_xdr_dec_setacl3res,
  2330. .p_arglen = ACL3_setaclargs_sz,
  2331. .p_replen = ACL3_setaclres_sz,
  2332. .p_timer = 0,
  2333. .p_name = "SETACL",
  2334. },
  2335. };
  2336. static unsigned int nfs3_acl_counts[ARRAY_SIZE(nfs3_acl_procedures)];
  2337. const struct rpc_version nfsacl_version3 = {
  2338. .number = 3,
  2339. .nrprocs = ARRAY_SIZE(nfs3_acl_procedures),
  2340. .procs = nfs3_acl_procedures,
  2341. .counts = nfs3_acl_counts,
  2342. };
  2343. #endif /* CONFIG_NFS_V3_ACL */