nfs3.c 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <thread.h>
  4. #include <sunrpc.h>
  5. #include <nfs3.h>
  6. char*
  7. nfs3StatusStr(Nfs3Status x)
  8. {
  9. switch(x){
  10. case Nfs3Ok:
  11. return "Nfs3Ok";
  12. case Nfs3ErrNotOwner:
  13. return "Nfs3ErrNotOwner";
  14. case Nfs3ErrNoEnt:
  15. return "Nfs3ErrNoEnt";
  16. case Nfs3ErrNoMem:
  17. return "Nfs3ErrNoMem";
  18. case Nfs3ErrIo:
  19. return "Nfs3ErrIo";
  20. case Nfs3ErrNxio:
  21. return "Nfs3ErrNxio";
  22. case Nfs3ErrAcces:
  23. return "Nfs3ErrAcces";
  24. case Nfs3ErrExist:
  25. return "Nfs3ErrExist";
  26. case Nfs3ErrXDev:
  27. return "Nfs3ErrXDev";
  28. case Nfs3ErrNoDev:
  29. return "Nfs3ErrNoDev";
  30. case Nfs3ErrNotDir:
  31. return "Nfs3ErrNotDir";
  32. case Nfs3ErrIsDir:
  33. return "Nfs3ErrIsDir";
  34. case Nfs3ErrInval:
  35. return "Nfs3ErrInval";
  36. case Nfs3ErrFbig:
  37. return "Nfs3ErrFbig";
  38. case Nfs3ErrNoSpc:
  39. return "Nfs3ErrNoSpc";
  40. case Nfs3ErrRoFs:
  41. return "Nfs3ErrRoFs";
  42. case Nfs3ErrMLink:
  43. return "Nfs3ErrMLink";
  44. case Nfs3ErrNameTooLong:
  45. return "Nfs3ErrNameTooLong";
  46. case Nfs3ErrNotEmpty:
  47. return "Nfs3ErrNotEmpty";
  48. case Nfs3ErrDQuot:
  49. return "Nfs3ErrDQuot";
  50. case Nfs3ErrStale:
  51. return "Nfs3ErrStale";
  52. case Nfs3ErrRemote:
  53. return "Nfs3ErrRemote";
  54. case Nfs3ErrBadHandle:
  55. return "Nfs3ErrBadHandle";
  56. case Nfs3ErrNotSync:
  57. return "Nfs3ErrNotSync";
  58. case Nfs3ErrBadCookie:
  59. return "Nfs3ErrBadCookie";
  60. case Nfs3ErrNotSupp:
  61. return "Nfs3ErrNotSupp";
  62. case Nfs3ErrTooSmall:
  63. return "Nfs3ErrTooSmall";
  64. case Nfs3ErrServerFault:
  65. return "Nfs3ErrServerFault";
  66. case Nfs3ErrBadType:
  67. return "Nfs3ErrBadType";
  68. case Nfs3ErrJukebox:
  69. return "Nfs3ErrJukebox";
  70. case Nfs3ErrFprintNotFound:
  71. return "Nfs3ErrFprintNotFound";
  72. case Nfs3ErrAborted:
  73. return "Nfs3ErrAborted";
  74. default:
  75. return "unknown";
  76. }
  77. }
  78. static struct {
  79. SunStatus status;
  80. char *msg;
  81. } etab[] = {
  82. Nfs3ErrNotOwner, "not owner",
  83. Nfs3ErrNoEnt, "directory entry not found",
  84. Nfs3ErrIo, "i/o error",
  85. Nfs3ErrNxio, "no such device",
  86. Nfs3ErrNoMem, "out of memory",
  87. Nfs3ErrAcces, "access denied",
  88. Nfs3ErrExist, "file or directory exists",
  89. Nfs3ErrXDev, "cross-device operation",
  90. Nfs3ErrNoDev, "no such device",
  91. Nfs3ErrNotDir, "not a directory",
  92. Nfs3ErrIsDir, "is a directory",
  93. Nfs3ErrInval, "invalid arguments",
  94. Nfs3ErrFbig, "file too big",
  95. Nfs3ErrNoSpc, "no space left on device",
  96. Nfs3ErrRoFs, "read-only file system",
  97. Nfs3ErrMLink, "too many links",
  98. Nfs3ErrNameTooLong, "name too long",
  99. Nfs3ErrNotEmpty, "directory not empty",
  100. Nfs3ErrDQuot, "dquot",
  101. Nfs3ErrStale, "stale handle",
  102. Nfs3ErrRemote, "remote error",
  103. Nfs3ErrBadHandle, "bad handle",
  104. Nfs3ErrNotSync, "out of sync with server",
  105. Nfs3ErrBadCookie, "bad cookie",
  106. Nfs3ErrNotSupp, "not supported",
  107. Nfs3ErrTooSmall, "too small",
  108. Nfs3ErrServerFault, "server fault",
  109. Nfs3ErrBadType, "bad type",
  110. Nfs3ErrJukebox, "jukebox -- try again later",
  111. Nfs3ErrFprintNotFound, "fprint not found",
  112. Nfs3ErrAborted, "aborted",
  113. };
  114. void
  115. nfs3Errstr(SunStatus status)
  116. {
  117. int i;
  118. for(i=0; i<nelem(etab); i++){
  119. if(etab[i].status == status){
  120. werrstr(etab[i].msg);
  121. return;
  122. }
  123. }
  124. werrstr("unknown nfs3 error %d", (int)status);
  125. }
  126. char*
  127. nfs3FileTypeStr(Nfs3FileType x)
  128. {
  129. switch(x){
  130. case Nfs3FileReg:
  131. return "Nfs3FileReg";
  132. case Nfs3FileDir:
  133. return "Nfs3FileDir";
  134. case Nfs3FileBlock:
  135. return "Nfs3FileBlock";
  136. case Nfs3FileChar:
  137. return "Nfs3FileChar";
  138. case Nfs3FileSymlink:
  139. return "Nfs3FileSymlink";
  140. case Nfs3FileSocket:
  141. return "Nfs3FileSocket";
  142. case Nfs3FileFifo:
  143. return "Nfs3FileFifo";
  144. default:
  145. return "unknown";
  146. }
  147. }
  148. void
  149. nfs3HandlePrint(Fmt *fmt, Nfs3Handle *x)
  150. {
  151. fmtprint(fmt, "%s\n", "Nfs3Handle");
  152. fmtprint(fmt, "\t%s=", "handle");
  153. if(x->len > 64)
  154. fmtprint(fmt, "%.*H... (%d)", 64, x->h, x->len);
  155. else
  156. fmtprint(fmt, "%.*H", x->len, x->h);
  157. fmtprint(fmt, "\n");
  158. }
  159. uint
  160. nfs3HandleSize(Nfs3Handle *x)
  161. {
  162. uint a;
  163. USED(x);
  164. a = 0 + sunVarOpaqueSize(x->len);
  165. return a;
  166. }
  167. int
  168. nfs3HandlePack(uchar *a, uchar *ea, uchar **pa, Nfs3Handle *x)
  169. {
  170. if(x->len > Nfs3MaxHandleSize || sunUint32Pack(a, ea, &a, &x->len) < 0
  171. || sunFixedOpaquePack(a, ea, &a, x->h, x->len) < 0)
  172. goto Err;
  173. *pa = a;
  174. return 0;
  175. Err:
  176. *pa = ea;
  177. return -1;
  178. }
  179. int
  180. nfs3HandleUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Handle *x)
  181. {
  182. uchar *ha;
  183. u32int n;
  184. if(sunUint32Unpack(a, ea, &a, &n) < 0 || n > Nfs3MaxHandleSize)
  185. goto Err;
  186. ha = a;
  187. a += (n+3)&~3;
  188. if(a > ea)
  189. goto Err;
  190. memmove(x->h, ha, n);
  191. x->len = n;
  192. *pa = a;
  193. return 0;
  194. Err:
  195. *pa = ea;
  196. return -1;
  197. }
  198. void
  199. nfs3TimePrint(Fmt *fmt, Nfs3Time *x)
  200. {
  201. fmtprint(fmt, "%s\n", "Nfs3Time");
  202. fmtprint(fmt, "\t%s=", "sec");
  203. fmtprint(fmt, "%ud", x->sec);
  204. fmtprint(fmt, "\n");
  205. fmtprint(fmt, "\t%s=", "nsec");
  206. fmtprint(fmt, "%ud", x->nsec);
  207. fmtprint(fmt, "\n");
  208. }
  209. uint
  210. nfs3TimeSize(Nfs3Time *x)
  211. {
  212. uint a;
  213. USED(x);
  214. a = 0 + 4 + 4;
  215. return a;
  216. }
  217. int
  218. nfs3TimePack(uchar *a, uchar *ea, uchar **pa, Nfs3Time *x)
  219. {
  220. if(sunUint32Pack(a, ea, &a, &x->sec) < 0) goto Err;
  221. if(sunUint32Pack(a, ea, &a, &x->nsec) < 0) goto Err;
  222. *pa = a;
  223. return 0;
  224. Err:
  225. *pa = ea;
  226. return -1;
  227. }
  228. int
  229. nfs3TimeUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Time *x)
  230. {
  231. if(sunUint32Unpack(a, ea, &a, &x->sec) < 0) goto Err;
  232. if(sunUint32Unpack(a, ea, &a, &x->nsec) < 0) goto Err;
  233. *pa = a;
  234. return 0;
  235. Err:
  236. *pa = ea;
  237. return -1;
  238. }
  239. void
  240. nfs3AttrPrint(Fmt *fmt, Nfs3Attr *x)
  241. {
  242. fmtprint(fmt, "%s\n", "Nfs3Attr");
  243. fmtprint(fmt, "\t%s=", "type");
  244. fmtprint(fmt, "%s", nfs3FileTypeStr(x->type));
  245. fmtprint(fmt, "\n");
  246. fmtprint(fmt, "\t%s=", "mode");
  247. fmtprint(fmt, "%ud", x->mode);
  248. fmtprint(fmt, "\n");
  249. fmtprint(fmt, "\t%s=", "nlink");
  250. fmtprint(fmt, "%ud", x->nlink);
  251. fmtprint(fmt, "\n");
  252. fmtprint(fmt, "\t%s=", "uid");
  253. fmtprint(fmt, "%ud", x->uid);
  254. fmtprint(fmt, "\n");
  255. fmtprint(fmt, "\t%s=", "gid");
  256. fmtprint(fmt, "%ud", x->gid);
  257. fmtprint(fmt, "\n");
  258. fmtprint(fmt, "\t%s=", "size");
  259. fmtprint(fmt, "%llud", x->size);
  260. fmtprint(fmt, "\n");
  261. fmtprint(fmt, "\t%s=", "used");
  262. fmtprint(fmt, "%llud", x->used);
  263. fmtprint(fmt, "\n");
  264. fmtprint(fmt, "\t%s=", "major");
  265. fmtprint(fmt, "%ud", x->major);
  266. fmtprint(fmt, "\n");
  267. fmtprint(fmt, "\t%s=", "minor");
  268. fmtprint(fmt, "%ud", x->minor);
  269. fmtprint(fmt, "\n");
  270. fmtprint(fmt, "\t%s=", "fsid");
  271. fmtprint(fmt, "%llud", x->fsid);
  272. fmtprint(fmt, "\n");
  273. fmtprint(fmt, "\t%s=", "fileid");
  274. fmtprint(fmt, "%llud", x->fileid);
  275. fmtprint(fmt, "\n");
  276. fmtprint(fmt, "\t%s=", "atime");
  277. nfs3TimePrint(fmt, &x->atime);
  278. fmtprint(fmt, "\n");
  279. fmtprint(fmt, "\t%s=", "mtime");
  280. nfs3TimePrint(fmt, &x->mtime);
  281. fmtprint(fmt, "\n");
  282. fmtprint(fmt, "\t%s=", "ctime");
  283. nfs3TimePrint(fmt, &x->ctime);
  284. fmtprint(fmt, "\n");
  285. }
  286. uint
  287. nfs3AttrSize(Nfs3Attr *x)
  288. {
  289. uint a;
  290. USED(x);
  291. a = 0 + 4 + 4 + 4 + 4 + 4 + 8 + 8 + 4 + 4 + 8 + 8 + nfs3TimeSize(&x->atime) + nfs3TimeSize(&x->mtime) + nfs3TimeSize(&x->ctime);
  292. return a;
  293. }
  294. int
  295. nfs3AttrPack(uchar *a, uchar *ea, uchar **pa, Nfs3Attr *x)
  296. {
  297. int i;
  298. if(i=x->type, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  299. if(sunUint32Pack(a, ea, &a, &x->mode) < 0) goto Err;
  300. if(sunUint32Pack(a, ea, &a, &x->nlink) < 0) goto Err;
  301. if(sunUint32Pack(a, ea, &a, &x->uid) < 0) goto Err;
  302. if(sunUint32Pack(a, ea, &a, &x->gid) < 0) goto Err;
  303. if(sunUint64Pack(a, ea, &a, &x->size) < 0) goto Err;
  304. if(sunUint64Pack(a, ea, &a, &x->used) < 0) goto Err;
  305. if(sunUint32Pack(a, ea, &a, &x->major) < 0) goto Err;
  306. if(sunUint32Pack(a, ea, &a, &x->minor) < 0) goto Err;
  307. if(sunUint64Pack(a, ea, &a, &x->fsid) < 0) goto Err;
  308. if(sunUint64Pack(a, ea, &a, &x->fileid) < 0) goto Err;
  309. if(nfs3TimePack(a, ea, &a, &x->atime) < 0) goto Err;
  310. if(nfs3TimePack(a, ea, &a, &x->mtime) < 0) goto Err;
  311. if(nfs3TimePack(a, ea, &a, &x->ctime) < 0) goto Err;
  312. *pa = a;
  313. return 0;
  314. Err:
  315. *pa = ea;
  316. return -1;
  317. }
  318. int
  319. nfs3AttrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Attr *x)
  320. {
  321. int i;
  322. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->type = i;
  323. if(sunUint32Unpack(a, ea, &a, &x->mode) < 0) goto Err;
  324. if(sunUint32Unpack(a, ea, &a, &x->nlink) < 0) goto Err;
  325. if(sunUint32Unpack(a, ea, &a, &x->uid) < 0) goto Err;
  326. if(sunUint32Unpack(a, ea, &a, &x->gid) < 0) goto Err;
  327. if(sunUint64Unpack(a, ea, &a, &x->size) < 0) goto Err;
  328. if(sunUint64Unpack(a, ea, &a, &x->used) < 0) goto Err;
  329. if(sunUint32Unpack(a, ea, &a, &x->major) < 0) goto Err;
  330. if(sunUint32Unpack(a, ea, &a, &x->minor) < 0) goto Err;
  331. if(sunUint64Unpack(a, ea, &a, &x->fsid) < 0) goto Err;
  332. if(sunUint64Unpack(a, ea, &a, &x->fileid) < 0) goto Err;
  333. if(nfs3TimeUnpack(a, ea, &a, &x->atime) < 0) goto Err;
  334. if(nfs3TimeUnpack(a, ea, &a, &x->mtime) < 0) goto Err;
  335. if(nfs3TimeUnpack(a, ea, &a, &x->ctime) < 0) goto Err;
  336. *pa = a;
  337. return 0;
  338. Err:
  339. *pa = ea;
  340. return -1;
  341. }
  342. void
  343. nfs3WccAttrPrint(Fmt *fmt, Nfs3WccAttr *x)
  344. {
  345. fmtprint(fmt, "%s\n", "Nfs3WccAttr");
  346. fmtprint(fmt, "\t%s=", "size");
  347. fmtprint(fmt, "%llud", x->size);
  348. fmtprint(fmt, "\n");
  349. fmtprint(fmt, "\t%s=", "mtime");
  350. nfs3TimePrint(fmt, &x->mtime);
  351. fmtprint(fmt, "\n");
  352. fmtprint(fmt, "\t%s=", "ctime");
  353. nfs3TimePrint(fmt, &x->ctime);
  354. fmtprint(fmt, "\n");
  355. }
  356. uint
  357. nfs3WccAttrSize(Nfs3WccAttr *x)
  358. {
  359. uint a;
  360. USED(x);
  361. a = 0 + 8 + nfs3TimeSize(&x->mtime) + nfs3TimeSize(&x->ctime);
  362. return a;
  363. }
  364. int
  365. nfs3WccAttrPack(uchar *a, uchar *ea, uchar **pa, Nfs3WccAttr *x)
  366. {
  367. if(sunUint64Pack(a, ea, &a, &x->size) < 0) goto Err;
  368. if(nfs3TimePack(a, ea, &a, &x->mtime) < 0) goto Err;
  369. if(nfs3TimePack(a, ea, &a, &x->ctime) < 0) goto Err;
  370. *pa = a;
  371. return 0;
  372. Err:
  373. *pa = ea;
  374. return -1;
  375. }
  376. int
  377. nfs3WccAttrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3WccAttr *x)
  378. {
  379. if(sunUint64Unpack(a, ea, &a, &x->size) < 0) goto Err;
  380. if(nfs3TimeUnpack(a, ea, &a, &x->mtime) < 0) goto Err;
  381. if(nfs3TimeUnpack(a, ea, &a, &x->ctime) < 0) goto Err;
  382. *pa = a;
  383. return 0;
  384. Err:
  385. *pa = ea;
  386. return -1;
  387. }
  388. void
  389. nfs3WccPrint(Fmt *fmt, Nfs3Wcc *x)
  390. {
  391. fmtprint(fmt, "%s\n", "Nfs3Wcc");
  392. fmtprint(fmt, "\t%s=", "haveWccAttr");
  393. fmtprint(fmt, "%d", x->haveWccAttr);
  394. fmtprint(fmt, "\n");
  395. switch(x->haveWccAttr){
  396. case 1:
  397. fmtprint(fmt, "\t%s=", "wccAttr");
  398. nfs3WccAttrPrint(fmt, &x->wccAttr);
  399. fmtprint(fmt, "\n");
  400. break;
  401. }
  402. fmtprint(fmt, "\t%s=", "haveAttr");
  403. fmtprint(fmt, "%d", x->haveAttr);
  404. fmtprint(fmt, "\n");
  405. switch(x->haveAttr){
  406. case 1:
  407. fmtprint(fmt, "\t%s=", "attr");
  408. nfs3AttrPrint(fmt, &x->attr);
  409. fmtprint(fmt, "\n");
  410. break;
  411. }
  412. }
  413. uint
  414. nfs3WccSize(Nfs3Wcc *x)
  415. {
  416. uint a;
  417. USED(x);
  418. a = 0 + 4;
  419. switch(x->haveWccAttr){
  420. case 1:
  421. a = a + nfs3WccAttrSize(&x->wccAttr);
  422. break;
  423. }
  424. a = a + 4;
  425. switch(x->haveAttr){
  426. case 1:
  427. a = a + nfs3AttrSize(&x->attr);
  428. break;
  429. }
  430. return a;
  431. }
  432. int
  433. nfs3WccPack(uchar *a, uchar *ea, uchar **pa, Nfs3Wcc *x)
  434. {
  435. if(sunUint1Pack(a, ea, &a, &x->haveWccAttr) < 0) goto Err;
  436. switch(x->haveWccAttr){
  437. case 1:
  438. if(nfs3WccAttrPack(a, ea, &a, &x->wccAttr) < 0) goto Err;
  439. break;
  440. }
  441. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  442. switch(x->haveAttr){
  443. case 1:
  444. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  445. break;
  446. }
  447. *pa = a;
  448. return 0;
  449. Err:
  450. *pa = ea;
  451. return -1;
  452. }
  453. int
  454. nfs3WccUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Wcc *x)
  455. {
  456. if(sunUint1Unpack(a, ea, &a, &x->haveWccAttr) < 0) goto Err;
  457. switch(x->haveWccAttr){
  458. case 1:
  459. if(nfs3WccAttrUnpack(a, ea, &a, &x->wccAttr) < 0) goto Err;
  460. break;
  461. }
  462. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  463. switch(x->haveAttr){
  464. case 1:
  465. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  466. break;
  467. }
  468. *pa = a;
  469. return 0;
  470. Err:
  471. *pa = ea;
  472. return -1;
  473. }
  474. char*
  475. nfs3SetTimeStr(Nfs3SetTime x)
  476. {
  477. switch(x){
  478. case Nfs3SetTimeDont:
  479. return "Nfs3SetTimeDont";
  480. case Nfs3SetTimeServer:
  481. return "Nfs3SetTimeServer";
  482. case Nfs3SetTimeClient:
  483. return "Nfs3SetTimeClient";
  484. default:
  485. return "unknown";
  486. }
  487. }
  488. void
  489. nfs3SetAttrPrint(Fmt *fmt, Nfs3SetAttr *x)
  490. {
  491. fmtprint(fmt, "%s\n", "Nfs3SetAttr");
  492. fmtprint(fmt, "\t%s=", "setMode");
  493. fmtprint(fmt, "%d", x->setMode);
  494. fmtprint(fmt, "\n");
  495. switch(x->setMode){
  496. case 1:
  497. fmtprint(fmt, "\t%s=", "mode");
  498. fmtprint(fmt, "%ud", x->mode);
  499. fmtprint(fmt, "\n");
  500. break;
  501. }
  502. fmtprint(fmt, "\t%s=", "setUid");
  503. fmtprint(fmt, "%d", x->setUid);
  504. fmtprint(fmt, "\n");
  505. switch(x->setUid){
  506. case 1:
  507. fmtprint(fmt, "\t%s=", "uid");
  508. fmtprint(fmt, "%ud", x->uid);
  509. fmtprint(fmt, "\n");
  510. break;
  511. }
  512. fmtprint(fmt, "\t%s=", "setGid");
  513. fmtprint(fmt, "%d", x->setGid);
  514. fmtprint(fmt, "\n");
  515. switch(x->setGid){
  516. case 1:
  517. fmtprint(fmt, "\t%s=", "gid");
  518. fmtprint(fmt, "%ud", x->gid);
  519. fmtprint(fmt, "\n");
  520. break;
  521. }
  522. fmtprint(fmt, "\t%s=", "setSize");
  523. fmtprint(fmt, "%d", x->setSize);
  524. fmtprint(fmt, "\n");
  525. switch(x->setSize){
  526. case 1:
  527. fmtprint(fmt, "\t%s=", "size");
  528. fmtprint(fmt, "%llud", x->size);
  529. fmtprint(fmt, "\n");
  530. break;
  531. }
  532. fmtprint(fmt, "\t%s=", "setAtime");
  533. fmtprint(fmt, "%s", nfs3SetTimeStr(x->setAtime));
  534. fmtprint(fmt, "\n");
  535. switch(x->setAtime){
  536. case Nfs3SetTimeClient:
  537. fmtprint(fmt, "\t%s=", "atime");
  538. nfs3TimePrint(fmt, &x->atime);
  539. fmtprint(fmt, "\n");
  540. break;
  541. }
  542. fmtprint(fmt, "\t%s=", "setMtime");
  543. fmtprint(fmt, "%s", nfs3SetTimeStr(x->setMtime));
  544. fmtprint(fmt, "\n");
  545. switch(x->setMtime){
  546. case Nfs3SetTimeClient:
  547. fmtprint(fmt, "\t%s=", "mtime");
  548. nfs3TimePrint(fmt, &x->mtime);
  549. fmtprint(fmt, "\n");
  550. break;
  551. }
  552. }
  553. uint
  554. nfs3SetAttrSize(Nfs3SetAttr *x)
  555. {
  556. uint a;
  557. USED(x);
  558. a = 0 + 4;
  559. switch(x->setMode){
  560. case 1:
  561. a = a + 4;
  562. break;
  563. }
  564. a = a + 4;
  565. switch(x->setUid){
  566. case 1:
  567. a = a + 4;
  568. break;
  569. }
  570. a = a + 4;
  571. switch(x->setGid){
  572. case 1:
  573. a = a + 4;
  574. break;
  575. }
  576. a = a + 4;
  577. switch(x->setSize){
  578. case 1:
  579. a = a + 8;
  580. break;
  581. }
  582. a = a + 4;
  583. switch(x->setAtime){
  584. case Nfs3SetTimeClient:
  585. a = a + nfs3TimeSize(&x->atime);
  586. break;
  587. }
  588. a = a + 4;
  589. switch(x->setMtime){
  590. case Nfs3SetTimeClient:
  591. a = a + nfs3TimeSize(&x->mtime);
  592. break;
  593. }
  594. return a;
  595. }
  596. int
  597. nfs3SetAttrPack(uchar *a, uchar *ea, uchar **pa, Nfs3SetAttr *x)
  598. {
  599. int i;
  600. if(sunUint1Pack(a, ea, &a, &x->setMode) < 0) goto Err;
  601. switch(x->setMode){
  602. case 1:
  603. if(sunUint32Pack(a, ea, &a, &x->mode) < 0) goto Err;
  604. break;
  605. }
  606. if(sunUint1Pack(a, ea, &a, &x->setUid) < 0) goto Err;
  607. switch(x->setUid){
  608. case 1:
  609. if(sunUint32Pack(a, ea, &a, &x->uid) < 0) goto Err;
  610. break;
  611. }
  612. if(sunUint1Pack(a, ea, &a, &x->setGid) < 0) goto Err;
  613. switch(x->setGid){
  614. case 1:
  615. if(sunUint32Pack(a, ea, &a, &x->gid) < 0) goto Err;
  616. break;
  617. }
  618. if(sunUint1Pack(a, ea, &a, &x->setSize) < 0) goto Err;
  619. switch(x->setSize){
  620. case 1:
  621. if(sunUint64Pack(a, ea, &a, &x->size) < 0) goto Err;
  622. break;
  623. }
  624. if(i=x->setAtime, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  625. switch(x->setAtime){
  626. case Nfs3SetTimeClient:
  627. if(nfs3TimePack(a, ea, &a, &x->atime) < 0) goto Err;
  628. break;
  629. }
  630. if(i=x->setMtime, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  631. switch(x->setMtime){
  632. case Nfs3SetTimeClient:
  633. if(nfs3TimePack(a, ea, &a, &x->mtime) < 0) goto Err;
  634. break;
  635. }
  636. *pa = a;
  637. return 0;
  638. Err:
  639. *pa = ea;
  640. return -1;
  641. }
  642. int
  643. nfs3SetAttrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3SetAttr *x)
  644. {
  645. int i;
  646. if(sunUint1Unpack(a, ea, &a, &x->setMode) < 0) goto Err;
  647. switch(x->setMode){
  648. case 1:
  649. if(sunUint32Unpack(a, ea, &a, &x->mode) < 0) goto Err;
  650. break;
  651. }
  652. if(sunUint1Unpack(a, ea, &a, &x->setUid) < 0) goto Err;
  653. switch(x->setUid){
  654. case 1:
  655. if(sunUint32Unpack(a, ea, &a, &x->uid) < 0) goto Err;
  656. break;
  657. }
  658. if(sunUint1Unpack(a, ea, &a, &x->setGid) < 0) goto Err;
  659. switch(x->setGid){
  660. case 1:
  661. if(sunUint32Unpack(a, ea, &a, &x->gid) < 0) goto Err;
  662. break;
  663. }
  664. if(sunUint1Unpack(a, ea, &a, &x->setSize) < 0) goto Err;
  665. switch(x->setSize){
  666. case 1:
  667. if(sunUint64Unpack(a, ea, &a, &x->size) < 0) goto Err;
  668. break;
  669. }
  670. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->setAtime = i;
  671. switch(x->setAtime){
  672. case Nfs3SetTimeClient:
  673. if(nfs3TimeUnpack(a, ea, &a, &x->atime) < 0) goto Err;
  674. break;
  675. }
  676. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->setMtime = i;
  677. switch(x->setMtime){
  678. case Nfs3SetTimeClient:
  679. if(nfs3TimeUnpack(a, ea, &a, &x->mtime) < 0) goto Err;
  680. break;
  681. }
  682. *pa = a;
  683. return 0;
  684. Err:
  685. *pa = ea;
  686. return -1;
  687. }
  688. void
  689. nfs3TNullPrint(Fmt *fmt, Nfs3TNull *x)
  690. {
  691. USED(x);
  692. fmtprint(fmt, "%s\n", "Nfs3TNull");
  693. }
  694. uint
  695. nfs3TNullSize(Nfs3TNull *x)
  696. {
  697. uint a;
  698. USED(x);
  699. a = 0;
  700. return a;
  701. }
  702. int
  703. nfs3TNullPack(uchar *a, uchar *ea, uchar **pa, Nfs3TNull *x)
  704. {
  705. USED(x);
  706. USED(ea);
  707. *pa = a;
  708. return 0;
  709. }
  710. int
  711. nfs3TNullUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TNull *x)
  712. {
  713. USED(x);
  714. USED(ea);
  715. *pa = a;
  716. return 0;
  717. }
  718. void
  719. nfs3RNullPrint(Fmt *fmt, Nfs3RNull *x)
  720. {
  721. USED(x);
  722. fmtprint(fmt, "%s\n", "Nfs3RNull");
  723. }
  724. uint
  725. nfs3RNullSize(Nfs3RNull *x)
  726. {
  727. uint a;
  728. USED(x);
  729. a = 0;
  730. return a;
  731. }
  732. int
  733. nfs3RNullPack(uchar *a, uchar *ea, uchar **pa, Nfs3RNull *x)
  734. {
  735. USED(ea);
  736. USED(x);
  737. *pa = a;
  738. return 0;
  739. }
  740. int
  741. nfs3RNullUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RNull *x)
  742. {
  743. USED(ea);
  744. USED(x);
  745. *pa = a;
  746. return 0;
  747. }
  748. void
  749. nfs3TGetattrPrint(Fmt *fmt, Nfs3TGetattr *x)
  750. {
  751. fmtprint(fmt, "%s\n", "Nfs3TGetattr");
  752. fmtprint(fmt, "\t%s=", "handle");
  753. nfs3HandlePrint(fmt, &x->handle);
  754. fmtprint(fmt, "\n");
  755. }
  756. uint
  757. nfs3TGetattrSize(Nfs3TGetattr *x)
  758. {
  759. uint a;
  760. USED(x);
  761. a = 0 + nfs3HandleSize(&x->handle);
  762. return a;
  763. }
  764. int
  765. nfs3TGetattrPack(uchar *a, uchar *ea, uchar **pa, Nfs3TGetattr *x)
  766. {
  767. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  768. *pa = a;
  769. return 0;
  770. Err:
  771. *pa = ea;
  772. return -1;
  773. }
  774. int
  775. nfs3TGetattrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TGetattr *x)
  776. {
  777. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  778. *pa = a;
  779. return 0;
  780. Err:
  781. *pa = ea;
  782. return -1;
  783. }
  784. void
  785. nfs3RGetattrPrint(Fmt *fmt, Nfs3RGetattr *x)
  786. {
  787. fmtprint(fmt, "%s\n", "Nfs3RGetattr");
  788. fmtprint(fmt, "\t%s=", "status");
  789. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  790. fmtprint(fmt, "\n");
  791. switch(x->status){
  792. case Nfs3Ok:
  793. fmtprint(fmt, "\t%s=", "attr");
  794. nfs3AttrPrint(fmt, &x->attr);
  795. fmtprint(fmt, "\n");
  796. break;
  797. }
  798. }
  799. uint
  800. nfs3RGetattrSize(Nfs3RGetattr *x)
  801. {
  802. uint a;
  803. USED(x);
  804. a = 0 + 4;
  805. switch(x->status){
  806. case Nfs3Ok:
  807. a = a + nfs3AttrSize(&x->attr);
  808. break;
  809. }
  810. return a;
  811. }
  812. int
  813. nfs3RGetattrPack(uchar *a, uchar *ea, uchar **pa, Nfs3RGetattr *x)
  814. {
  815. int i;
  816. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  817. switch(x->status){
  818. case Nfs3Ok:
  819. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  820. break;
  821. }
  822. *pa = a;
  823. return 0;
  824. Err:
  825. *pa = ea;
  826. return -1;
  827. }
  828. int
  829. nfs3RGetattrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RGetattr *x)
  830. {
  831. int i;
  832. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  833. switch(x->status){
  834. case Nfs3Ok:
  835. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  836. break;
  837. }
  838. *pa = a;
  839. return 0;
  840. Err:
  841. *pa = ea;
  842. return -1;
  843. }
  844. void
  845. nfs3TSetattrPrint(Fmt *fmt, Nfs3TSetattr *x)
  846. {
  847. fmtprint(fmt, "%s\n", "Nfs3TSetattr");
  848. fmtprint(fmt, "\t%s=", "handle");
  849. nfs3HandlePrint(fmt, &x->handle);
  850. fmtprint(fmt, "\n");
  851. fmtprint(fmt, "\t%s=", "attr");
  852. nfs3SetAttrPrint(fmt, &x->attr);
  853. fmtprint(fmt, "\n");
  854. fmtprint(fmt, "\t%s=", "checkCtime");
  855. fmtprint(fmt, "%d", x->checkCtime);
  856. fmtprint(fmt, "\n");
  857. switch(x->checkCtime){
  858. case 1:
  859. fmtprint(fmt, "\t%s=", "ctime");
  860. nfs3TimePrint(fmt, &x->ctime);
  861. fmtprint(fmt, "\n");
  862. break;
  863. }
  864. }
  865. uint
  866. nfs3TSetattrSize(Nfs3TSetattr *x)
  867. {
  868. uint a;
  869. USED(x);
  870. a = 0 + nfs3HandleSize(&x->handle) + nfs3SetAttrSize(&x->attr) + 4;
  871. switch(x->checkCtime){
  872. case 1:
  873. a = a + nfs3TimeSize(&x->ctime);
  874. break;
  875. }
  876. return a;
  877. }
  878. int
  879. nfs3TSetattrPack(uchar *a, uchar *ea, uchar **pa, Nfs3TSetattr *x)
  880. {
  881. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  882. if(nfs3SetAttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  883. if(sunUint1Pack(a, ea, &a, &x->checkCtime) < 0) goto Err;
  884. switch(x->checkCtime){
  885. case 1:
  886. if(nfs3TimePack(a, ea, &a, &x->ctime) < 0) goto Err;
  887. break;
  888. }
  889. *pa = a;
  890. return 0;
  891. Err:
  892. *pa = ea;
  893. return -1;
  894. }
  895. int
  896. nfs3TSetattrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TSetattr *x)
  897. {
  898. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  899. if(nfs3SetAttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  900. if(sunUint1Unpack(a, ea, &a, &x->checkCtime) < 0) goto Err;
  901. switch(x->checkCtime){
  902. case 1:
  903. if(nfs3TimeUnpack(a, ea, &a, &x->ctime) < 0) goto Err;
  904. break;
  905. }
  906. *pa = a;
  907. return 0;
  908. Err:
  909. *pa = ea;
  910. return -1;
  911. }
  912. void
  913. nfs3RSetattrPrint(Fmt *fmt, Nfs3RSetattr *x)
  914. {
  915. fmtprint(fmt, "%s\n", "Nfs3RSetattr");
  916. fmtprint(fmt, "\t%s=", "status");
  917. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  918. fmtprint(fmt, "\n");
  919. fmtprint(fmt, "\t%s=", "wcc");
  920. nfs3WccPrint(fmt, &x->wcc);
  921. fmtprint(fmt, "\n");
  922. }
  923. uint
  924. nfs3RSetattrSize(Nfs3RSetattr *x)
  925. {
  926. uint a;
  927. USED(x);
  928. a = 0 + 4 + nfs3WccSize(&x->wcc);
  929. return a;
  930. }
  931. int
  932. nfs3RSetattrPack(uchar *a, uchar *ea, uchar **pa, Nfs3RSetattr *x)
  933. {
  934. int i;
  935. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  936. if(nfs3WccPack(a, ea, &a, &x->wcc) < 0) goto Err;
  937. *pa = a;
  938. return 0;
  939. Err:
  940. *pa = ea;
  941. return -1;
  942. }
  943. int
  944. nfs3RSetattrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RSetattr *x)
  945. {
  946. int i;
  947. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  948. if(nfs3WccUnpack(a, ea, &a, &x->wcc) < 0) goto Err;
  949. *pa = a;
  950. return 0;
  951. Err:
  952. *pa = ea;
  953. return -1;
  954. }
  955. void
  956. nfs3TLookupPrint(Fmt *fmt, Nfs3TLookup *x)
  957. {
  958. fmtprint(fmt, "%s\n", "Nfs3TLookup");
  959. fmtprint(fmt, "\t%s=", "handle");
  960. nfs3HandlePrint(fmt, &x->handle);
  961. fmtprint(fmt, "\n");
  962. fmtprint(fmt, "\t%s=", "name");
  963. fmtprint(fmt, "\"%s\"", x->name);
  964. fmtprint(fmt, "\n");
  965. }
  966. uint
  967. nfs3TLookupSize(Nfs3TLookup *x)
  968. {
  969. uint a;
  970. USED(x);
  971. a = 0 + nfs3HandleSize(&x->handle) + sunStringSize(x->name);
  972. return a;
  973. }
  974. int
  975. nfs3TLookupPack(uchar *a, uchar *ea, uchar **pa, Nfs3TLookup *x)
  976. {
  977. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  978. if(sunStringPack(a, ea, &a, &x->name, -1) < 0) goto Err;
  979. *pa = a;
  980. return 0;
  981. Err:
  982. *pa = ea;
  983. return -1;
  984. }
  985. int
  986. nfs3TLookupUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TLookup *x)
  987. {
  988. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  989. if(sunStringUnpack(a, ea, &a, &x->name, -1) < 0) goto Err;
  990. *pa = a;
  991. return 0;
  992. Err:
  993. *pa = ea;
  994. return -1;
  995. }
  996. void
  997. nfs3RLookupPrint(Fmt *fmt, Nfs3RLookup *x)
  998. {
  999. fmtprint(fmt, "%s\n", "Nfs3RLookup");
  1000. fmtprint(fmt, "\t%s=", "status");
  1001. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  1002. fmtprint(fmt, "\n");
  1003. switch(x->status){
  1004. case Nfs3Ok:
  1005. fmtprint(fmt, "\t%s=", "handle");
  1006. nfs3HandlePrint(fmt, &x->handle);
  1007. fmtprint(fmt, "\n");
  1008. fmtprint(fmt, "\t%s=", "haveAttr");
  1009. fmtprint(fmt, "%d", x->haveAttr);
  1010. fmtprint(fmt, "\n");
  1011. switch(x->haveAttr){
  1012. case 1:
  1013. fmtprint(fmt, "\t%s=", "attr");
  1014. nfs3AttrPrint(fmt, &x->attr);
  1015. fmtprint(fmt, "\n");
  1016. break;
  1017. }
  1018. break;
  1019. }
  1020. fmtprint(fmt, "\t%s=", "haveDirAttr");
  1021. fmtprint(fmt, "%d", x->haveDirAttr);
  1022. fmtprint(fmt, "\n");
  1023. switch(x->haveDirAttr){
  1024. case 1:
  1025. fmtprint(fmt, "\t%s=", "dirAttr");
  1026. nfs3AttrPrint(fmt, &x->dirAttr);
  1027. fmtprint(fmt, "\n");
  1028. break;
  1029. }
  1030. }
  1031. uint
  1032. nfs3RLookupSize(Nfs3RLookup *x)
  1033. {
  1034. uint a;
  1035. USED(x);
  1036. a = 0 + 4;
  1037. switch(x->status){
  1038. case Nfs3Ok:
  1039. a = a + nfs3HandleSize(&x->handle) + 4;
  1040. switch(x->haveAttr){
  1041. case 1:
  1042. a = a + nfs3AttrSize(&x->attr);
  1043. break;
  1044. }
  1045. break;
  1046. }
  1047. a = a + 4;
  1048. switch(x->haveDirAttr){
  1049. case 1:
  1050. a = a + nfs3AttrSize(&x->dirAttr);
  1051. break;
  1052. }
  1053. return a;
  1054. }
  1055. int
  1056. nfs3RLookupPack(uchar *a, uchar *ea, uchar **pa, Nfs3RLookup *x)
  1057. {
  1058. int i;
  1059. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1060. switch(x->status){
  1061. case Nfs3Ok:
  1062. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  1063. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1064. switch(x->haveAttr){
  1065. case 1:
  1066. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  1067. break;
  1068. }
  1069. break;
  1070. }
  1071. if(sunUint1Pack(a, ea, &a, &x->haveDirAttr) < 0) goto Err;
  1072. switch(x->haveDirAttr){
  1073. case 1:
  1074. if(nfs3AttrPack(a, ea, &a, &x->dirAttr) < 0) goto Err;
  1075. break;
  1076. }
  1077. *pa = a;
  1078. return 0;
  1079. Err:
  1080. *pa = ea;
  1081. return -1;
  1082. }
  1083. int
  1084. nfs3RLookupUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RLookup *x)
  1085. {
  1086. int i;
  1087. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  1088. switch(x->status){
  1089. case Nfs3Ok:
  1090. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  1091. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1092. switch(x->haveAttr){
  1093. case 1:
  1094. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  1095. break;
  1096. }
  1097. break;
  1098. }
  1099. if(sunUint1Unpack(a, ea, &a, &x->haveDirAttr) < 0) goto Err;
  1100. switch(x->haveDirAttr){
  1101. case 1:
  1102. if(nfs3AttrUnpack(a, ea, &a, &x->dirAttr) < 0) goto Err;
  1103. break;
  1104. }
  1105. *pa = a;
  1106. return 0;
  1107. Err:
  1108. *pa = ea;
  1109. return -1;
  1110. }
  1111. void
  1112. nfs3TAccessPrint(Fmt *fmt, Nfs3TAccess *x)
  1113. {
  1114. fmtprint(fmt, "%s\n", "Nfs3TAccess");
  1115. fmtprint(fmt, "\t%s=", "handle");
  1116. nfs3HandlePrint(fmt, &x->handle);
  1117. fmtprint(fmt, "\n");
  1118. fmtprint(fmt, "\t%s=", "access");
  1119. fmtprint(fmt, "%ud", x->access);
  1120. fmtprint(fmt, "\n");
  1121. }
  1122. uint
  1123. nfs3TAccessSize(Nfs3TAccess *x)
  1124. {
  1125. uint a;
  1126. USED(x);
  1127. a = 0 + nfs3HandleSize(&x->handle) + 4;
  1128. return a;
  1129. }
  1130. int
  1131. nfs3TAccessPack(uchar *a, uchar *ea, uchar **pa, Nfs3TAccess *x)
  1132. {
  1133. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  1134. if(sunUint32Pack(a, ea, &a, &x->access) < 0) goto Err;
  1135. *pa = a;
  1136. return 0;
  1137. Err:
  1138. *pa = ea;
  1139. return -1;
  1140. }
  1141. int
  1142. nfs3TAccessUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TAccess *x)
  1143. {
  1144. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  1145. if(sunUint32Unpack(a, ea, &a, &x->access) < 0) goto Err;
  1146. *pa = a;
  1147. return 0;
  1148. Err:
  1149. *pa = ea;
  1150. return -1;
  1151. }
  1152. void
  1153. nfs3RAccessPrint(Fmt *fmt, Nfs3RAccess *x)
  1154. {
  1155. fmtprint(fmt, "%s\n", "Nfs3RAccess");
  1156. fmtprint(fmt, "\t%s=", "status");
  1157. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  1158. fmtprint(fmt, "\n");
  1159. fmtprint(fmt, "\t%s=", "haveAttr");
  1160. fmtprint(fmt, "%d", x->haveAttr);
  1161. fmtprint(fmt, "\n");
  1162. switch(x->haveAttr){
  1163. case 1:
  1164. fmtprint(fmt, "\t%s=", "attr");
  1165. nfs3AttrPrint(fmt, &x->attr);
  1166. fmtprint(fmt, "\n");
  1167. break;
  1168. }
  1169. switch(x->status){
  1170. case Nfs3Ok:
  1171. fmtprint(fmt, "\t%s=", "access");
  1172. fmtprint(fmt, "%ud", x->access);
  1173. fmtprint(fmt, "\n");
  1174. break;
  1175. }
  1176. }
  1177. uint
  1178. nfs3RAccessSize(Nfs3RAccess *x)
  1179. {
  1180. uint a;
  1181. USED(x);
  1182. a = 0 + 4 + 4;
  1183. switch(x->haveAttr){
  1184. case 1:
  1185. a = a + nfs3AttrSize(&x->attr);
  1186. break;
  1187. }
  1188. switch(x->status){
  1189. case Nfs3Ok:
  1190. a = a + 4;
  1191. break;
  1192. }
  1193. return a;
  1194. }
  1195. int
  1196. nfs3RAccessPack(uchar *a, uchar *ea, uchar **pa, Nfs3RAccess *x)
  1197. {
  1198. int i;
  1199. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1200. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1201. switch(x->haveAttr){
  1202. case 1:
  1203. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  1204. break;
  1205. }
  1206. switch(x->status){
  1207. case Nfs3Ok:
  1208. if(sunUint32Pack(a, ea, &a, &x->access) < 0) goto Err;
  1209. break;
  1210. }
  1211. *pa = a;
  1212. return 0;
  1213. Err:
  1214. *pa = ea;
  1215. return -1;
  1216. }
  1217. int
  1218. nfs3RAccessUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RAccess *x)
  1219. {
  1220. int i;
  1221. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  1222. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1223. switch(x->haveAttr){
  1224. case 1:
  1225. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  1226. break;
  1227. }
  1228. switch(x->status){
  1229. case Nfs3Ok:
  1230. if(sunUint32Unpack(a, ea, &a, &x->access) < 0) goto Err;
  1231. break;
  1232. }
  1233. *pa = a;
  1234. return 0;
  1235. Err:
  1236. *pa = ea;
  1237. return -1;
  1238. }
  1239. void
  1240. nfs3TReadlinkPrint(Fmt *fmt, Nfs3TReadlink *x)
  1241. {
  1242. fmtprint(fmt, "%s\n", "Nfs3TReadlink");
  1243. fmtprint(fmt, "\t%s=", "handle");
  1244. nfs3HandlePrint(fmt, &x->handle);
  1245. fmtprint(fmt, "\n");
  1246. }
  1247. uint
  1248. nfs3TReadlinkSize(Nfs3TReadlink *x)
  1249. {
  1250. uint a;
  1251. USED(x);
  1252. a = 0 + nfs3HandleSize(&x->handle);
  1253. return a;
  1254. }
  1255. int
  1256. nfs3TReadlinkPack(uchar *a, uchar *ea, uchar **pa, Nfs3TReadlink *x)
  1257. {
  1258. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  1259. *pa = a;
  1260. return 0;
  1261. Err:
  1262. *pa = ea;
  1263. return -1;
  1264. }
  1265. int
  1266. nfs3TReadlinkUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TReadlink *x)
  1267. {
  1268. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  1269. *pa = a;
  1270. return 0;
  1271. Err:
  1272. *pa = ea;
  1273. return -1;
  1274. }
  1275. void
  1276. nfs3RReadlinkPrint(Fmt *fmt, Nfs3RReadlink *x)
  1277. {
  1278. fmtprint(fmt, "%s\n", "Nfs3RReadlink");
  1279. fmtprint(fmt, "\t%s=", "status");
  1280. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  1281. fmtprint(fmt, "\n");
  1282. fmtprint(fmt, "\t%s=", "haveAttr");
  1283. fmtprint(fmt, "%d", x->haveAttr);
  1284. fmtprint(fmt, "\n");
  1285. switch(x->haveAttr){
  1286. case 1:
  1287. fmtprint(fmt, "\t%s=", "attr");
  1288. nfs3AttrPrint(fmt, &x->attr);
  1289. fmtprint(fmt, "\n");
  1290. break;
  1291. }
  1292. switch(x->status){
  1293. case Nfs3Ok:
  1294. fmtprint(fmt, "\t%s=", "data");
  1295. fmtprint(fmt, "\"%s\"", x->data);
  1296. fmtprint(fmt, "\n");
  1297. break;
  1298. }
  1299. }
  1300. uint
  1301. nfs3RReadlinkSize(Nfs3RReadlink *x)
  1302. {
  1303. uint a;
  1304. USED(x);
  1305. a = 0 + 4 + 4;
  1306. switch(x->haveAttr){
  1307. case 1:
  1308. a = a + nfs3AttrSize(&x->attr);
  1309. break;
  1310. }
  1311. switch(x->status){
  1312. case Nfs3Ok:
  1313. a = a + sunStringSize(x->data);
  1314. break;
  1315. }
  1316. return a;
  1317. }
  1318. int
  1319. nfs3RReadlinkPack(uchar *a, uchar *ea, uchar **pa, Nfs3RReadlink *x)
  1320. {
  1321. int i;
  1322. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1323. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1324. switch(x->haveAttr){
  1325. case 1:
  1326. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  1327. break;
  1328. }
  1329. switch(x->status){
  1330. case Nfs3Ok:
  1331. if(sunStringPack(a, ea, &a, &x->data, -1) < 0) goto Err;
  1332. break;
  1333. }
  1334. *pa = a;
  1335. return 0;
  1336. Err:
  1337. *pa = ea;
  1338. return -1;
  1339. }
  1340. int
  1341. nfs3RReadlinkUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RReadlink *x)
  1342. {
  1343. int i;
  1344. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  1345. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1346. switch(x->haveAttr){
  1347. case 1:
  1348. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  1349. break;
  1350. }
  1351. switch(x->status){
  1352. case Nfs3Ok:
  1353. if(sunStringUnpack(a, ea, &a, &x->data, -1) < 0) goto Err;
  1354. break;
  1355. }
  1356. *pa = a;
  1357. return 0;
  1358. Err:
  1359. *pa = ea;
  1360. return -1;
  1361. }
  1362. void
  1363. nfs3TReadPrint(Fmt *fmt, Nfs3TRead *x)
  1364. {
  1365. fmtprint(fmt, "%s\n", "Nfs3TRead");
  1366. fmtprint(fmt, "\t%s=", "handle");
  1367. nfs3HandlePrint(fmt, &x->handle);
  1368. fmtprint(fmt, "\n");
  1369. fmtprint(fmt, "\t%s=", "offset");
  1370. fmtprint(fmt, "%llud", x->offset);
  1371. fmtprint(fmt, "\n");
  1372. fmtprint(fmt, "\t%s=", "count");
  1373. fmtprint(fmt, "%ud", x->count);
  1374. fmtprint(fmt, "\n");
  1375. }
  1376. uint
  1377. nfs3TReadSize(Nfs3TRead *x)
  1378. {
  1379. uint a;
  1380. USED(x);
  1381. a = 0 + nfs3HandleSize(&x->handle) + 8 + 4;
  1382. return a;
  1383. }
  1384. int
  1385. nfs3TReadPack(uchar *a, uchar *ea, uchar **pa, Nfs3TRead *x)
  1386. {
  1387. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  1388. if(sunUint64Pack(a, ea, &a, &x->offset) < 0) goto Err;
  1389. if(sunUint32Pack(a, ea, &a, &x->count) < 0) goto Err;
  1390. *pa = a;
  1391. return 0;
  1392. Err:
  1393. *pa = ea;
  1394. return -1;
  1395. }
  1396. int
  1397. nfs3TReadUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TRead *x)
  1398. {
  1399. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  1400. if(sunUint64Unpack(a, ea, &a, &x->offset) < 0) goto Err;
  1401. if(sunUint32Unpack(a, ea, &a, &x->count) < 0) goto Err;
  1402. *pa = a;
  1403. return 0;
  1404. Err:
  1405. *pa = ea;
  1406. return -1;
  1407. }
  1408. void
  1409. nfs3RReadPrint(Fmt *fmt, Nfs3RRead *x)
  1410. {
  1411. fmtprint(fmt, "%s\n", "Nfs3RRead");
  1412. fmtprint(fmt, "\t%s=", "status");
  1413. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  1414. fmtprint(fmt, "\n");
  1415. fmtprint(fmt, "\t%s=", "haveAttr");
  1416. fmtprint(fmt, "%d", x->haveAttr);
  1417. fmtprint(fmt, "\n");
  1418. switch(x->haveAttr){
  1419. case 1:
  1420. fmtprint(fmt, "\t%s=", "attr");
  1421. nfs3AttrPrint(fmt, &x->attr);
  1422. fmtprint(fmt, "\n");
  1423. break;
  1424. }
  1425. switch(x->status){
  1426. case Nfs3Ok:
  1427. fmtprint(fmt, "\t%s=", "count");
  1428. fmtprint(fmt, "%ud", x->count);
  1429. fmtprint(fmt, "\n");
  1430. fmtprint(fmt, "\t%s=", "eof");
  1431. fmtprint(fmt, "%d", x->eof);
  1432. fmtprint(fmt, "\n");
  1433. fmtprint(fmt, "\t%s=", "data");
  1434. if(x->ndata <= 32)
  1435. fmtprint(fmt, "%.*H", x->ndata, x->data);
  1436. else
  1437. fmtprint(fmt, "%.32H...", x->data);
  1438. fmtprint(fmt, "\n");
  1439. break;
  1440. }
  1441. }
  1442. uint
  1443. nfs3RReadSize(Nfs3RRead *x)
  1444. {
  1445. uint a;
  1446. USED(x);
  1447. a = 0 + 4 + 4;
  1448. switch(x->haveAttr){
  1449. case 1:
  1450. a = a + nfs3AttrSize(&x->attr);
  1451. break;
  1452. }
  1453. switch(x->status){
  1454. case Nfs3Ok:
  1455. a = a + 4 + 4 + sunVarOpaqueSize(x->ndata);
  1456. break;
  1457. }
  1458. return a;
  1459. }
  1460. int
  1461. nfs3RReadPack(uchar *a, uchar *ea, uchar **pa, Nfs3RRead *x)
  1462. {
  1463. int i;
  1464. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1465. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1466. switch(x->haveAttr){
  1467. case 1:
  1468. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  1469. break;
  1470. }
  1471. switch(x->status){
  1472. case Nfs3Ok:
  1473. if(sunUint32Pack(a, ea, &a, &x->count) < 0) goto Err;
  1474. if(sunUint1Pack(a, ea, &a, &x->eof) < 0) goto Err;
  1475. if(sunVarOpaquePack(a, ea, &a, &x->data, &x->ndata, x->count) < 0) goto Err;
  1476. break;
  1477. }
  1478. *pa = a;
  1479. return 0;
  1480. Err:
  1481. *pa = ea;
  1482. return -1;
  1483. }
  1484. int
  1485. nfs3RReadUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RRead *x)
  1486. {
  1487. int i;
  1488. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  1489. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1490. switch(x->haveAttr){
  1491. case 1:
  1492. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  1493. break;
  1494. }
  1495. switch(x->status){
  1496. case Nfs3Ok:
  1497. if(sunUint32Unpack(a, ea, &a, &x->count) < 0) goto Err;
  1498. if(sunUint1Unpack(a, ea, &a, &x->eof) < 0) goto Err;
  1499. if(sunVarOpaqueUnpack(a, ea, &a, &x->data, &x->ndata, x->count) < 0) goto Err;
  1500. break;
  1501. }
  1502. *pa = a;
  1503. return 0;
  1504. Err:
  1505. *pa = ea;
  1506. return -1;
  1507. }
  1508. char*
  1509. nfs3SyncStr(Nfs3Sync x)
  1510. {
  1511. switch(x){
  1512. case Nfs3SyncNone:
  1513. return "Nfs3SyncNone";
  1514. case Nfs3SyncData:
  1515. return "Nfs3SyncData";
  1516. case Nfs3SyncFile:
  1517. return "Nfs3SyncFile";
  1518. default:
  1519. return "unknown";
  1520. }
  1521. }
  1522. void
  1523. nfs3TWritePrint(Fmt *fmt, Nfs3TWrite *x)
  1524. {
  1525. fmtprint(fmt, "%s\n", "Nfs3TWrite");
  1526. fmtprint(fmt, "\t%s=", "file");
  1527. nfs3HandlePrint(fmt, &x->handle);
  1528. fmtprint(fmt, "\n");
  1529. fmtprint(fmt, "\t%s=", "offset");
  1530. fmtprint(fmt, "%llud", x->offset);
  1531. fmtprint(fmt, "\n");
  1532. fmtprint(fmt, "\t%s=", "count");
  1533. fmtprint(fmt, "%ud", x->count);
  1534. fmtprint(fmt, "\n");
  1535. fmtprint(fmt, "\t%s=", "stable");
  1536. fmtprint(fmt, "%s", nfs3SyncStr(x->stable));
  1537. fmtprint(fmt, "\n");
  1538. fmtprint(fmt, "\t%s=", "data");
  1539. if(x->ndata > 32)
  1540. fmtprint(fmt, "%.32H... (%d)", x->data, x->ndata);
  1541. else
  1542. fmtprint(fmt, "%.*H", x->ndata, x->data);
  1543. fmtprint(fmt, "\n");
  1544. }
  1545. uint
  1546. nfs3TWriteSize(Nfs3TWrite *x)
  1547. {
  1548. uint a;
  1549. USED(x);
  1550. a = 0 + nfs3HandleSize(&x->handle) + 8 + 4 + 4 + sunVarOpaqueSize(x->ndata);
  1551. return a;
  1552. }
  1553. int
  1554. nfs3TWritePack(uchar *a, uchar *ea, uchar **pa, Nfs3TWrite *x)
  1555. {
  1556. int i;
  1557. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  1558. if(sunUint64Pack(a, ea, &a, &x->offset) < 0) goto Err;
  1559. if(sunUint32Pack(a, ea, &a, &x->count) < 0) goto Err;
  1560. if(i=x->stable, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1561. if(sunVarOpaquePack(a, ea, &a, &x->data, &x->ndata, x->count) < 0) goto Err;
  1562. *pa = a;
  1563. return 0;
  1564. Err:
  1565. *pa = ea;
  1566. return -1;
  1567. }
  1568. int
  1569. nfs3TWriteUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TWrite *x)
  1570. {
  1571. int i;
  1572. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  1573. if(sunUint64Unpack(a, ea, &a, &x->offset) < 0) goto Err;
  1574. if(sunUint32Unpack(a, ea, &a, &x->count) < 0) goto Err;
  1575. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->stable = i;
  1576. if(sunVarOpaqueUnpack(a, ea, &a, &x->data, &x->ndata, x->count) < 0) goto Err;
  1577. *pa = a;
  1578. return 0;
  1579. Err:
  1580. *pa = ea;
  1581. return -1;
  1582. }
  1583. void
  1584. nfs3RWritePrint(Fmt *fmt, Nfs3RWrite *x)
  1585. {
  1586. fmtprint(fmt, "%s\n", "Nfs3RWrite");
  1587. fmtprint(fmt, "\t%s=", "status");
  1588. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  1589. fmtprint(fmt, "\n");
  1590. fmtprint(fmt, "\t%s=", "wcc");
  1591. nfs3WccPrint(fmt, &x->wcc);
  1592. fmtprint(fmt, "\n");
  1593. switch(x->status){
  1594. case Nfs3Ok:
  1595. fmtprint(fmt, "\t%s=", "count");
  1596. fmtprint(fmt, "%ud", x->count);
  1597. fmtprint(fmt, "\n");
  1598. fmtprint(fmt, "\t%s=", "committed");
  1599. fmtprint(fmt, "%s", nfs3SyncStr(x->committed));
  1600. fmtprint(fmt, "\n");
  1601. fmtprint(fmt, "\t%s=", "verf");
  1602. fmtprint(fmt, "%.*H", Nfs3WriteVerfSize, x->verf);
  1603. fmtprint(fmt, "\n");
  1604. break;
  1605. }
  1606. }
  1607. uint
  1608. nfs3RWriteSize(Nfs3RWrite *x)
  1609. {
  1610. uint a;
  1611. USED(x);
  1612. a = 0 + 4 + nfs3WccSize(&x->wcc);
  1613. switch(x->status){
  1614. case Nfs3Ok:
  1615. a = a + 4 + 4 + Nfs3WriteVerfSize;
  1616. break;
  1617. }
  1618. return a;
  1619. }
  1620. int
  1621. nfs3RWritePack(uchar *a, uchar *ea, uchar **pa, Nfs3RWrite *x)
  1622. {
  1623. int i;
  1624. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1625. if(nfs3WccPack(a, ea, &a, &x->wcc) < 0) goto Err;
  1626. switch(x->status){
  1627. case Nfs3Ok:
  1628. if(sunUint32Pack(a, ea, &a, &x->count) < 0) goto Err;
  1629. if(i=x->committed, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1630. if(sunFixedOpaquePack(a, ea, &a, x->verf, Nfs3WriteVerfSize) < 0) goto Err;
  1631. break;
  1632. }
  1633. *pa = a;
  1634. return 0;
  1635. Err:
  1636. *pa = ea;
  1637. return -1;
  1638. }
  1639. int
  1640. nfs3RWriteUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RWrite *x)
  1641. {
  1642. int i;
  1643. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  1644. if(nfs3WccUnpack(a, ea, &a, &x->wcc) < 0) goto Err;
  1645. switch(x->status){
  1646. case Nfs3Ok:
  1647. if(sunUint32Unpack(a, ea, &a, &x->count) < 0) goto Err;
  1648. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->committed = i;
  1649. if(sunFixedOpaqueUnpack(a, ea, &a, x->verf, Nfs3WriteVerfSize) < 0) goto Err;
  1650. break;
  1651. }
  1652. *pa = a;
  1653. return 0;
  1654. Err:
  1655. *pa = ea;
  1656. return -1;
  1657. }
  1658. char*
  1659. nfs3CreateStr(Nfs3Create x)
  1660. {
  1661. switch(x){
  1662. case Nfs3CreateUnchecked:
  1663. return "Nfs3CreateUnchecked";
  1664. case Nfs3CreateGuarded:
  1665. return "Nfs3CreateGuarded";
  1666. case Nfs3CreateExclusive:
  1667. return "Nfs3CreateExclusive";
  1668. default:
  1669. return "unknown";
  1670. }
  1671. }
  1672. void
  1673. nfs3TCreatePrint(Fmt *fmt, Nfs3TCreate *x)
  1674. {
  1675. fmtprint(fmt, "%s\n", "Nfs3TCreate");
  1676. fmtprint(fmt, "\t%s=", "handle");
  1677. nfs3HandlePrint(fmt, &x->handle);
  1678. fmtprint(fmt, "\n");
  1679. fmtprint(fmt, "\t%s=", "name");
  1680. fmtprint(fmt, "\"%s\"", x->name);
  1681. fmtprint(fmt, "\n");
  1682. fmtprint(fmt, "\t%s=", "mode");
  1683. fmtprint(fmt, "%s", nfs3CreateStr(x->mode));
  1684. fmtprint(fmt, "\n");
  1685. switch(x->mode){
  1686. case Nfs3CreateUnchecked:
  1687. case Nfs3CreateGuarded:
  1688. fmtprint(fmt, "\t%s=", "attr");
  1689. nfs3SetAttrPrint(fmt, &x->attr);
  1690. fmtprint(fmt, "\n");
  1691. break;
  1692. case Nfs3CreateExclusive:
  1693. fmtprint(fmt, "\t%s=", "verf");
  1694. fmtprint(fmt, "%.*H", Nfs3CreateVerfSize, x->verf);
  1695. fmtprint(fmt, "\n");
  1696. break;
  1697. }
  1698. }
  1699. uint
  1700. nfs3TCreateSize(Nfs3TCreate *x)
  1701. {
  1702. uint a;
  1703. USED(x);
  1704. a = 0 + nfs3HandleSize(&x->handle) + sunStringSize(x->name) + 4;
  1705. switch(x->mode){
  1706. case Nfs3CreateUnchecked:
  1707. case Nfs3CreateGuarded:
  1708. a = a + nfs3SetAttrSize(&x->attr);
  1709. break;
  1710. case Nfs3CreateExclusive:
  1711. a = a + Nfs3CreateVerfSize;
  1712. break;
  1713. }
  1714. return a;
  1715. }
  1716. int
  1717. nfs3TCreatePack(uchar *a, uchar *ea, uchar **pa, Nfs3TCreate *x)
  1718. {
  1719. int i;
  1720. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  1721. if(sunStringPack(a, ea, &a, &x->name, -1) < 0) goto Err;
  1722. if(i=x->mode, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1723. switch(x->mode){
  1724. case Nfs3CreateUnchecked:
  1725. case Nfs3CreateGuarded:
  1726. if(nfs3SetAttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  1727. break;
  1728. case Nfs3CreateExclusive:
  1729. if(sunFixedOpaquePack(a, ea, &a, x->verf, Nfs3CreateVerfSize) < 0) goto Err;
  1730. break;
  1731. }
  1732. *pa = a;
  1733. return 0;
  1734. Err:
  1735. *pa = ea;
  1736. return -1;
  1737. }
  1738. int
  1739. nfs3TCreateUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TCreate *x)
  1740. {
  1741. int i;
  1742. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  1743. if(sunStringUnpack(a, ea, &a, &x->name, -1) < 0) goto Err;
  1744. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->mode = i;
  1745. switch(x->mode){
  1746. case Nfs3CreateUnchecked:
  1747. case Nfs3CreateGuarded:
  1748. if(nfs3SetAttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  1749. break;
  1750. case Nfs3CreateExclusive:
  1751. if(sunFixedOpaqueUnpack(a, ea, &a, x->verf, Nfs3CreateVerfSize) < 0) goto Err;
  1752. break;
  1753. }
  1754. *pa = a;
  1755. return 0;
  1756. Err:
  1757. *pa = ea;
  1758. return -1;
  1759. }
  1760. void
  1761. nfs3RCreatePrint(Fmt *fmt, Nfs3RCreate *x)
  1762. {
  1763. fmtprint(fmt, "%s\n", "Nfs3RCreate");
  1764. fmtprint(fmt, "\t%s=", "status");
  1765. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  1766. fmtprint(fmt, "\n");
  1767. switch(x->status){
  1768. case Nfs3Ok:
  1769. fmtprint(fmt, "\t%s=", "haveHandle");
  1770. fmtprint(fmt, "%d", x->haveHandle);
  1771. fmtprint(fmt, "\n");
  1772. switch(x->haveHandle){
  1773. case 1:
  1774. fmtprint(fmt, "\t%s=", "handle");
  1775. nfs3HandlePrint(fmt, &x->handle);
  1776. fmtprint(fmt, "\n");
  1777. break;
  1778. }
  1779. fmtprint(fmt, "\t%s=", "haveAttr");
  1780. fmtprint(fmt, "%d", x->haveAttr);
  1781. fmtprint(fmt, "\n");
  1782. switch(x->haveAttr){
  1783. case 1:
  1784. fmtprint(fmt, "\t%s=", "attr");
  1785. nfs3AttrPrint(fmt, &x->attr);
  1786. fmtprint(fmt, "\n");
  1787. break;
  1788. }
  1789. break;
  1790. }
  1791. fmtprint(fmt, "\t%s=", "dirWcc");
  1792. nfs3WccPrint(fmt, &x->dirWcc);
  1793. fmtprint(fmt, "\n");
  1794. }
  1795. uint
  1796. nfs3RCreateSize(Nfs3RCreate *x)
  1797. {
  1798. uint a;
  1799. USED(x);
  1800. a = 0 + 4;
  1801. switch(x->status){
  1802. case Nfs3Ok:
  1803. a = a + 4;
  1804. switch(x->haveHandle){
  1805. case 1:
  1806. a = a + nfs3HandleSize(&x->handle);
  1807. break;
  1808. }
  1809. a = a + 4;
  1810. switch(x->haveAttr){
  1811. case 1:
  1812. a = a + nfs3AttrSize(&x->attr);
  1813. break;
  1814. }
  1815. break;
  1816. }
  1817. a = a + nfs3WccSize(&x->dirWcc);
  1818. return a;
  1819. }
  1820. int
  1821. nfs3RCreatePack(uchar *a, uchar *ea, uchar **pa, Nfs3RCreate *x)
  1822. {
  1823. int i;
  1824. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1825. switch(x->status){
  1826. case Nfs3Ok:
  1827. if(sunUint1Pack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  1828. switch(x->haveHandle){
  1829. case 1:
  1830. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  1831. break;
  1832. }
  1833. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1834. switch(x->haveAttr){
  1835. case 1:
  1836. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  1837. break;
  1838. }
  1839. break;
  1840. }
  1841. if(nfs3WccPack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  1842. *pa = a;
  1843. return 0;
  1844. Err:
  1845. *pa = ea;
  1846. return -1;
  1847. }
  1848. int
  1849. nfs3RCreateUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RCreate *x)
  1850. {
  1851. int i;
  1852. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  1853. switch(x->status){
  1854. case Nfs3Ok:
  1855. if(sunUint1Unpack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  1856. switch(x->haveHandle){
  1857. case 1:
  1858. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  1859. break;
  1860. }
  1861. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1862. switch(x->haveAttr){
  1863. case 1:
  1864. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  1865. break;
  1866. }
  1867. break;
  1868. }
  1869. if(nfs3WccUnpack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  1870. *pa = a;
  1871. return 0;
  1872. Err:
  1873. *pa = ea;
  1874. return -1;
  1875. }
  1876. void
  1877. nfs3TMkdirPrint(Fmt *fmt, Nfs3TMkdir *x)
  1878. {
  1879. fmtprint(fmt, "%s\n", "Nfs3TMkdir");
  1880. fmtprint(fmt, "\t%s=", "handle");
  1881. nfs3HandlePrint(fmt, &x->handle);
  1882. fmtprint(fmt, "\n");
  1883. fmtprint(fmt, "\t%s=", "name");
  1884. fmtprint(fmt, "\"%s\"", x->name);
  1885. fmtprint(fmt, "\n");
  1886. fmtprint(fmt, "\t%s=", "attr");
  1887. nfs3SetAttrPrint(fmt, &x->attr);
  1888. fmtprint(fmt, "\n");
  1889. }
  1890. uint
  1891. nfs3TMkdirSize(Nfs3TMkdir *x)
  1892. {
  1893. uint a;
  1894. USED(x);
  1895. a = 0 + nfs3HandleSize(&x->handle) + sunStringSize(x->name) + nfs3SetAttrSize(&x->attr);
  1896. return a;
  1897. }
  1898. int
  1899. nfs3TMkdirPack(uchar *a, uchar *ea, uchar **pa, Nfs3TMkdir *x)
  1900. {
  1901. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  1902. if(sunStringPack(a, ea, &a, &x->name, -1) < 0) goto Err;
  1903. if(nfs3SetAttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  1904. *pa = a;
  1905. return 0;
  1906. Err:
  1907. *pa = ea;
  1908. return -1;
  1909. }
  1910. int
  1911. nfs3TMkdirUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TMkdir *x)
  1912. {
  1913. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  1914. if(sunStringUnpack(a, ea, &a, &x->name, -1) < 0) goto Err;
  1915. if(nfs3SetAttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  1916. *pa = a;
  1917. return 0;
  1918. Err:
  1919. *pa = ea;
  1920. return -1;
  1921. }
  1922. void
  1923. nfs3RMkdirPrint(Fmt *fmt, Nfs3RMkdir *x)
  1924. {
  1925. fmtprint(fmt, "%s\n", "Nfs3RMkdir");
  1926. fmtprint(fmt, "\t%s=", "status");
  1927. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  1928. fmtprint(fmt, "\n");
  1929. switch(x->status){
  1930. case Nfs3Ok:
  1931. fmtprint(fmt, "\t%s=", "haveHandle");
  1932. fmtprint(fmt, "%d", x->haveHandle);
  1933. fmtprint(fmt, "\n");
  1934. switch(x->haveHandle){
  1935. case 1:
  1936. fmtprint(fmt, "\t%s=", "handle");
  1937. nfs3HandlePrint(fmt, &x->handle);
  1938. fmtprint(fmt, "\n");
  1939. break;
  1940. }
  1941. fmtprint(fmt, "\t%s=", "haveAttr");
  1942. fmtprint(fmt, "%d", x->haveAttr);
  1943. fmtprint(fmt, "\n");
  1944. switch(x->haveAttr){
  1945. case 1:
  1946. fmtprint(fmt, "\t%s=", "attr");
  1947. nfs3AttrPrint(fmt, &x->attr);
  1948. fmtprint(fmt, "\n");
  1949. break;
  1950. }
  1951. break;
  1952. }
  1953. fmtprint(fmt, "\t%s=", "dirWcc");
  1954. nfs3WccPrint(fmt, &x->dirWcc);
  1955. fmtprint(fmt, "\n");
  1956. }
  1957. uint
  1958. nfs3RMkdirSize(Nfs3RMkdir *x)
  1959. {
  1960. uint a;
  1961. USED(x);
  1962. a = 0 + 4;
  1963. switch(x->status){
  1964. case Nfs3Ok:
  1965. a = a + 4;
  1966. switch(x->haveHandle){
  1967. case 1:
  1968. a = a + nfs3HandleSize(&x->handle);
  1969. break;
  1970. }
  1971. a = a + 4;
  1972. switch(x->haveAttr){
  1973. case 1:
  1974. a = a + nfs3AttrSize(&x->attr);
  1975. break;
  1976. }
  1977. break;
  1978. }
  1979. a = a + nfs3WccSize(&x->dirWcc);
  1980. return a;
  1981. }
  1982. int
  1983. nfs3RMkdirPack(uchar *a, uchar *ea, uchar **pa, Nfs3RMkdir *x)
  1984. {
  1985. int i;
  1986. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  1987. switch(x->status){
  1988. case Nfs3Ok:
  1989. if(sunUint1Pack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  1990. switch(x->haveHandle){
  1991. case 1:
  1992. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  1993. break;
  1994. }
  1995. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  1996. switch(x->haveAttr){
  1997. case 1:
  1998. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  1999. break;
  2000. }
  2001. break;
  2002. }
  2003. if(nfs3WccPack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  2004. *pa = a;
  2005. return 0;
  2006. Err:
  2007. *pa = ea;
  2008. return -1;
  2009. }
  2010. int
  2011. nfs3RMkdirUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RMkdir *x)
  2012. {
  2013. int i;
  2014. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  2015. switch(x->status){
  2016. case Nfs3Ok:
  2017. if(sunUint1Unpack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  2018. switch(x->haveHandle){
  2019. case 1:
  2020. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  2021. break;
  2022. }
  2023. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  2024. switch(x->haveAttr){
  2025. case 1:
  2026. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  2027. break;
  2028. }
  2029. break;
  2030. }
  2031. if(nfs3WccUnpack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  2032. *pa = a;
  2033. return 0;
  2034. Err:
  2035. *pa = ea;
  2036. return -1;
  2037. }
  2038. void
  2039. nfs3TSymlinkPrint(Fmt *fmt, Nfs3TSymlink *x)
  2040. {
  2041. fmtprint(fmt, "%s\n", "Nfs3TSymlink");
  2042. fmtprint(fmt, "\t%s=", "handle");
  2043. nfs3HandlePrint(fmt, &x->handle);
  2044. fmtprint(fmt, "\n");
  2045. fmtprint(fmt, "\t%s=", "name");
  2046. fmtprint(fmt, "\"%s\"", x->name);
  2047. fmtprint(fmt, "\n");
  2048. fmtprint(fmt, "\t%s=", "attr");
  2049. nfs3SetAttrPrint(fmt, &x->attr);
  2050. fmtprint(fmt, "\n");
  2051. fmtprint(fmt, "\t%s=", "data");
  2052. fmtprint(fmt, "\"%s\"", x->data);
  2053. fmtprint(fmt, "\n");
  2054. }
  2055. uint
  2056. nfs3TSymlinkSize(Nfs3TSymlink *x)
  2057. {
  2058. uint a;
  2059. USED(x);
  2060. a = 0 + nfs3HandleSize(&x->handle) + sunStringSize(x->name) + nfs3SetAttrSize(&x->attr) + sunStringSize(x->data);
  2061. return a;
  2062. }
  2063. int
  2064. nfs3TSymlinkPack(uchar *a, uchar *ea, uchar **pa, Nfs3TSymlink *x)
  2065. {
  2066. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  2067. if(sunStringPack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2068. if(nfs3SetAttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  2069. if(sunStringPack(a, ea, &a, &x->data, -1) < 0) goto Err;
  2070. *pa = a;
  2071. return 0;
  2072. Err:
  2073. *pa = ea;
  2074. return -1;
  2075. }
  2076. int
  2077. nfs3TSymlinkUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TSymlink *x)
  2078. {
  2079. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  2080. if(sunStringUnpack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2081. if(nfs3SetAttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  2082. if(sunStringUnpack(a, ea, &a, &x->data, -1) < 0) goto Err;
  2083. *pa = a;
  2084. return 0;
  2085. Err:
  2086. *pa = ea;
  2087. return -1;
  2088. }
  2089. void
  2090. nfs3RSymlinkPrint(Fmt *fmt, Nfs3RSymlink *x)
  2091. {
  2092. fmtprint(fmt, "%s\n", "Nfs3RSymlink");
  2093. fmtprint(fmt, "\t%s=", "status");
  2094. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  2095. fmtprint(fmt, "\n");
  2096. switch(x->status){
  2097. case Nfs3Ok:
  2098. fmtprint(fmt, "\t%s=", "haveHandle");
  2099. fmtprint(fmt, "%d", x->haveHandle);
  2100. fmtprint(fmt, "\n");
  2101. switch(x->haveHandle){
  2102. case 1:
  2103. fmtprint(fmt, "\t%s=", "handle");
  2104. nfs3HandlePrint(fmt, &x->handle);
  2105. fmtprint(fmt, "\n");
  2106. break;
  2107. }
  2108. fmtprint(fmt, "\t%s=", "haveAttr");
  2109. fmtprint(fmt, "%d", x->haveAttr);
  2110. fmtprint(fmt, "\n");
  2111. switch(x->haveAttr){
  2112. case 1:
  2113. fmtprint(fmt, "\t%s=", "attr");
  2114. nfs3AttrPrint(fmt, &x->attr);
  2115. fmtprint(fmt, "\n");
  2116. break;
  2117. }
  2118. break;
  2119. }
  2120. fmtprint(fmt, "\t%s=", "dirWcc");
  2121. nfs3WccPrint(fmt, &x->dirWcc);
  2122. fmtprint(fmt, "\n");
  2123. }
  2124. uint
  2125. nfs3RSymlinkSize(Nfs3RSymlink *x)
  2126. {
  2127. uint a;
  2128. USED(x);
  2129. a = 0 + 4;
  2130. switch(x->status){
  2131. case Nfs3Ok:
  2132. a = a + 4;
  2133. switch(x->haveHandle){
  2134. case 1:
  2135. a = a + nfs3HandleSize(&x->handle);
  2136. break;
  2137. }
  2138. a = a + 4;
  2139. switch(x->haveAttr){
  2140. case 1:
  2141. a = a + nfs3AttrSize(&x->attr);
  2142. break;
  2143. }
  2144. break;
  2145. }
  2146. a = a + nfs3WccSize(&x->dirWcc);
  2147. return a;
  2148. }
  2149. int
  2150. nfs3RSymlinkPack(uchar *a, uchar *ea, uchar **pa, Nfs3RSymlink *x)
  2151. {
  2152. int i;
  2153. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  2154. switch(x->status){
  2155. case Nfs3Ok:
  2156. if(sunUint1Pack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  2157. switch(x->haveHandle){
  2158. case 1:
  2159. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  2160. break;
  2161. }
  2162. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  2163. switch(x->haveAttr){
  2164. case 1:
  2165. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  2166. break;
  2167. }
  2168. break;
  2169. }
  2170. if(nfs3WccPack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  2171. *pa = a;
  2172. return 0;
  2173. Err:
  2174. *pa = ea;
  2175. return -1;
  2176. }
  2177. int
  2178. nfs3RSymlinkUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RSymlink *x)
  2179. {
  2180. int i;
  2181. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  2182. switch(x->status){
  2183. case Nfs3Ok:
  2184. if(sunUint1Unpack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  2185. switch(x->haveHandle){
  2186. case 1:
  2187. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  2188. break;
  2189. }
  2190. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  2191. switch(x->haveAttr){
  2192. case 1:
  2193. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  2194. break;
  2195. }
  2196. break;
  2197. }
  2198. if(nfs3WccUnpack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  2199. *pa = a;
  2200. return 0;
  2201. Err:
  2202. *pa = ea;
  2203. return -1;
  2204. }
  2205. void
  2206. nfs3TMknodPrint(Fmt *fmt, Nfs3TMknod *x)
  2207. {
  2208. fmtprint(fmt, "%s\n", "Nfs3TMknod");
  2209. fmtprint(fmt, "\t%s=", "handle");
  2210. nfs3HandlePrint(fmt, &x->handle);
  2211. fmtprint(fmt, "\n");
  2212. fmtprint(fmt, "\t%s=", "name");
  2213. fmtprint(fmt, "\"%s\"", x->name);
  2214. fmtprint(fmt, "\n");
  2215. fmtprint(fmt, "\t%s=", "type");
  2216. fmtprint(fmt, "%s", nfs3FileTypeStr(x->type));
  2217. fmtprint(fmt, "\n");
  2218. switch(x->type){
  2219. case Nfs3FileChar:
  2220. case Nfs3FileBlock:
  2221. fmtprint(fmt, "\t%s=", "attr");
  2222. nfs3SetAttrPrint(fmt, &x->attr);
  2223. fmtprint(fmt, "\n");
  2224. fmtprint(fmt, "\t%s=", "major");
  2225. fmtprint(fmt, "%ud", x->major);
  2226. fmtprint(fmt, "\n");
  2227. fmtprint(fmt, "\t%s=", "minor");
  2228. fmtprint(fmt, "%ud", x->minor);
  2229. fmtprint(fmt, "\n");
  2230. break;
  2231. case Nfs3FileSocket:
  2232. case Nfs3FileFifo:
  2233. fmtprint(fmt, "\t%s=", "attr");
  2234. nfs3SetAttrPrint(fmt, &x->attr);
  2235. fmtprint(fmt, "\n");
  2236. break;
  2237. }
  2238. }
  2239. uint
  2240. nfs3TMknodSize(Nfs3TMknod *x)
  2241. {
  2242. uint a;
  2243. USED(x);
  2244. a = 0 + nfs3HandleSize(&x->handle) + sunStringSize(x->name) + 4;
  2245. switch(x->type){
  2246. case Nfs3FileChar:
  2247. case Nfs3FileBlock:
  2248. a = a + nfs3SetAttrSize(&x->attr) + 4 + 4;
  2249. break;
  2250. case Nfs3FileSocket:
  2251. case Nfs3FileFifo:
  2252. a = a + nfs3SetAttrSize(&x->attr);
  2253. break;
  2254. }
  2255. return a;
  2256. }
  2257. int
  2258. nfs3TMknodPack(uchar *a, uchar *ea, uchar **pa, Nfs3TMknod *x)
  2259. {
  2260. int i;
  2261. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  2262. if(sunStringPack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2263. if(i=x->type, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  2264. switch(x->type){
  2265. case Nfs3FileChar:
  2266. case Nfs3FileBlock:
  2267. if(nfs3SetAttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  2268. if(sunUint32Pack(a, ea, &a, &x->major) < 0) goto Err;
  2269. if(sunUint32Pack(a, ea, &a, &x->minor) < 0) goto Err;
  2270. break;
  2271. case Nfs3FileSocket:
  2272. case Nfs3FileFifo:
  2273. if(nfs3SetAttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  2274. break;
  2275. }
  2276. *pa = a;
  2277. return 0;
  2278. Err:
  2279. *pa = ea;
  2280. return -1;
  2281. }
  2282. int
  2283. nfs3TMknodUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TMknod *x)
  2284. {
  2285. int i;
  2286. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  2287. if(sunStringUnpack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2288. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->type = i;
  2289. switch(x->type){
  2290. case Nfs3FileChar:
  2291. case Nfs3FileBlock:
  2292. if(nfs3SetAttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  2293. if(sunUint32Unpack(a, ea, &a, &x->major) < 0) goto Err;
  2294. if(sunUint32Unpack(a, ea, &a, &x->minor) < 0) goto Err;
  2295. break;
  2296. case Nfs3FileSocket:
  2297. case Nfs3FileFifo:
  2298. if(nfs3SetAttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  2299. break;
  2300. }
  2301. *pa = a;
  2302. return 0;
  2303. Err:
  2304. *pa = ea;
  2305. return -1;
  2306. }
  2307. void
  2308. nfs3RMknodPrint(Fmt *fmt, Nfs3RMknod *x)
  2309. {
  2310. fmtprint(fmt, "%s\n", "Nfs3RMknod");
  2311. fmtprint(fmt, "\t%s=", "status");
  2312. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  2313. fmtprint(fmt, "\n");
  2314. switch(x->status){
  2315. case Nfs3Ok:
  2316. fmtprint(fmt, "\t%s=", "haveHandle");
  2317. fmtprint(fmt, "%d", x->haveHandle);
  2318. fmtprint(fmt, "\n");
  2319. switch(x->haveHandle){
  2320. case 1:
  2321. fmtprint(fmt, "\t%s=", "handle");
  2322. nfs3HandlePrint(fmt, &x->handle);
  2323. fmtprint(fmt, "\n");
  2324. break;
  2325. }
  2326. fmtprint(fmt, "\t%s=", "haveAttr");
  2327. fmtprint(fmt, "%d", x->haveAttr);
  2328. fmtprint(fmt, "\n");
  2329. switch(x->haveAttr){
  2330. case 1:
  2331. fmtprint(fmt, "\t%s=", "attr");
  2332. nfs3AttrPrint(fmt, &x->attr);
  2333. fmtprint(fmt, "\n");
  2334. break;
  2335. }
  2336. break;
  2337. }
  2338. fmtprint(fmt, "\t%s=", "dirWcc");
  2339. nfs3WccPrint(fmt, &x->dirWcc);
  2340. fmtprint(fmt, "\n");
  2341. }
  2342. uint
  2343. nfs3RMknodSize(Nfs3RMknod *x)
  2344. {
  2345. uint a;
  2346. USED(x);
  2347. a = 0 + 4;
  2348. switch(x->status){
  2349. case Nfs3Ok:
  2350. a = a + 4;
  2351. switch(x->haveHandle){
  2352. case 1:
  2353. a = a + nfs3HandleSize(&x->handle);
  2354. break;
  2355. }
  2356. a = a + 4;
  2357. switch(x->haveAttr){
  2358. case 1:
  2359. a = a + nfs3AttrSize(&x->attr);
  2360. break;
  2361. }
  2362. break;
  2363. }
  2364. a = a + nfs3WccSize(&x->dirWcc);
  2365. return a;
  2366. }
  2367. int
  2368. nfs3RMknodPack(uchar *a, uchar *ea, uchar **pa, Nfs3RMknod *x)
  2369. {
  2370. int i;
  2371. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  2372. switch(x->status){
  2373. case Nfs3Ok:
  2374. if(sunUint1Pack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  2375. switch(x->haveHandle){
  2376. case 1:
  2377. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  2378. break;
  2379. }
  2380. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  2381. switch(x->haveAttr){
  2382. case 1:
  2383. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  2384. break;
  2385. }
  2386. break;
  2387. }
  2388. if(nfs3WccPack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  2389. *pa = a;
  2390. return 0;
  2391. Err:
  2392. *pa = ea;
  2393. return -1;
  2394. }
  2395. int
  2396. nfs3RMknodUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RMknod *x)
  2397. {
  2398. int i;
  2399. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  2400. switch(x->status){
  2401. case Nfs3Ok:
  2402. if(sunUint1Unpack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  2403. switch(x->haveHandle){
  2404. case 1:
  2405. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  2406. break;
  2407. }
  2408. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  2409. switch(x->haveAttr){
  2410. case 1:
  2411. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  2412. break;
  2413. }
  2414. break;
  2415. }
  2416. if(nfs3WccUnpack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  2417. *pa = a;
  2418. return 0;
  2419. Err:
  2420. *pa = ea;
  2421. return -1;
  2422. }
  2423. void
  2424. nfs3TRemovePrint(Fmt *fmt, Nfs3TRemove *x)
  2425. {
  2426. fmtprint(fmt, "%s\n", "Nfs3TRemove");
  2427. fmtprint(fmt, "\t%s=", "handle");
  2428. nfs3HandlePrint(fmt, &x->handle);
  2429. fmtprint(fmt, "\n");
  2430. fmtprint(fmt, "\t%s=", "name");
  2431. fmtprint(fmt, "\"%s\"", x->name);
  2432. fmtprint(fmt, "\n");
  2433. }
  2434. uint
  2435. nfs3TRemoveSize(Nfs3TRemove *x)
  2436. {
  2437. uint a;
  2438. USED(x);
  2439. a = 0 + nfs3HandleSize(&x->handle) + sunStringSize(x->name);
  2440. return a;
  2441. }
  2442. int
  2443. nfs3TRemovePack(uchar *a, uchar *ea, uchar **pa, Nfs3TRemove *x)
  2444. {
  2445. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  2446. if(sunStringPack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2447. *pa = a;
  2448. return 0;
  2449. Err:
  2450. *pa = ea;
  2451. return -1;
  2452. }
  2453. int
  2454. nfs3TRemoveUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TRemove *x)
  2455. {
  2456. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  2457. if(sunStringUnpack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2458. *pa = a;
  2459. return 0;
  2460. Err:
  2461. *pa = ea;
  2462. return -1;
  2463. }
  2464. void
  2465. nfs3RRemovePrint(Fmt *fmt, Nfs3RRemove *x)
  2466. {
  2467. fmtprint(fmt, "%s\n", "Nfs3RRemove");
  2468. fmtprint(fmt, "\t%s=", "status");
  2469. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  2470. fmtprint(fmt, "\n");
  2471. fmtprint(fmt, "\t%s=", "wcc");
  2472. nfs3WccPrint(fmt, &x->wcc);
  2473. fmtprint(fmt, "\n");
  2474. }
  2475. uint
  2476. nfs3RRemoveSize(Nfs3RRemove *x)
  2477. {
  2478. uint a;
  2479. USED(x);
  2480. a = 0 + 4 + nfs3WccSize(&x->wcc);
  2481. return a;
  2482. }
  2483. int
  2484. nfs3RRemovePack(uchar *a, uchar *ea, uchar **pa, Nfs3RRemove *x)
  2485. {
  2486. int i;
  2487. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  2488. if(nfs3WccPack(a, ea, &a, &x->wcc) < 0) goto Err;
  2489. *pa = a;
  2490. return 0;
  2491. Err:
  2492. *pa = ea;
  2493. return -1;
  2494. }
  2495. int
  2496. nfs3RRemoveUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RRemove *x)
  2497. {
  2498. int i;
  2499. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  2500. if(nfs3WccUnpack(a, ea, &a, &x->wcc) < 0) goto Err;
  2501. *pa = a;
  2502. return 0;
  2503. Err:
  2504. *pa = ea;
  2505. return -1;
  2506. }
  2507. void
  2508. nfs3TRmdirPrint(Fmt *fmt, Nfs3TRmdir *x)
  2509. {
  2510. fmtprint(fmt, "%s\n", "Nfs3TRmdir");
  2511. fmtprint(fmt, "\t%s=", "handle");
  2512. nfs3HandlePrint(fmt, &x->handle);
  2513. fmtprint(fmt, "\n");
  2514. fmtprint(fmt, "\t%s=", "name");
  2515. fmtprint(fmt, "\"%s\"", x->name);
  2516. fmtprint(fmt, "\n");
  2517. }
  2518. uint
  2519. nfs3TRmdirSize(Nfs3TRmdir *x)
  2520. {
  2521. uint a;
  2522. USED(x);
  2523. a = 0 + nfs3HandleSize(&x->handle) + sunStringSize(x->name);
  2524. return a;
  2525. }
  2526. int
  2527. nfs3TRmdirPack(uchar *a, uchar *ea, uchar **pa, Nfs3TRmdir *x)
  2528. {
  2529. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  2530. if(sunStringPack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2531. *pa = a;
  2532. return 0;
  2533. Err:
  2534. *pa = ea;
  2535. return -1;
  2536. }
  2537. int
  2538. nfs3TRmdirUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TRmdir *x)
  2539. {
  2540. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  2541. if(sunStringUnpack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2542. *pa = a;
  2543. return 0;
  2544. Err:
  2545. *pa = ea;
  2546. return -1;
  2547. }
  2548. void
  2549. nfs3RRmdirPrint(Fmt *fmt, Nfs3RRmdir *x)
  2550. {
  2551. fmtprint(fmt, "%s\n", "Nfs3RRmdir");
  2552. fmtprint(fmt, "\t%s=", "status");
  2553. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  2554. fmtprint(fmt, "\n");
  2555. fmtprint(fmt, "\t%s=", "wcc");
  2556. nfs3WccPrint(fmt, &x->wcc);
  2557. fmtprint(fmt, "\n");
  2558. }
  2559. uint
  2560. nfs3RRmdirSize(Nfs3RRmdir *x)
  2561. {
  2562. uint a;
  2563. USED(x);
  2564. a = 0 + 4 + nfs3WccSize(&x->wcc);
  2565. return a;
  2566. }
  2567. int
  2568. nfs3RRmdirPack(uchar *a, uchar *ea, uchar **pa, Nfs3RRmdir *x)
  2569. {
  2570. int i;
  2571. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  2572. if(nfs3WccPack(a, ea, &a, &x->wcc) < 0) goto Err;
  2573. *pa = a;
  2574. return 0;
  2575. Err:
  2576. *pa = ea;
  2577. return -1;
  2578. }
  2579. int
  2580. nfs3RRmdirUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RRmdir *x)
  2581. {
  2582. int i;
  2583. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  2584. if(nfs3WccUnpack(a, ea, &a, &x->wcc) < 0) goto Err;
  2585. *pa = a;
  2586. return 0;
  2587. Err:
  2588. *pa = ea;
  2589. return -1;
  2590. }
  2591. void
  2592. nfs3TRenamePrint(Fmt *fmt, Nfs3TRename *x)
  2593. {
  2594. fmtprint(fmt, "%s\n", "Nfs3TRename");
  2595. fmtprint(fmt, "\t%s=", "from");
  2596. fmtprint(fmt, "{\n");
  2597. fmtprint(fmt, "\t\t%s=", "handle");
  2598. nfs3HandlePrint(fmt, &x->from.handle);
  2599. fmtprint(fmt, "\n");
  2600. fmtprint(fmt, "\t\t%s=", "name");
  2601. fmtprint(fmt, "\"%s\"", x->from.name);
  2602. fmtprint(fmt, "\n");
  2603. fmtprint(fmt, "\t}");
  2604. fmtprint(fmt, "\n");
  2605. fmtprint(fmt, "\t%s=", "to");
  2606. fmtprint(fmt, "{\n");
  2607. fmtprint(fmt, "\t\t%s=", "handle");
  2608. nfs3HandlePrint(fmt, &x->to.handle);
  2609. fmtprint(fmt, "\n");
  2610. fmtprint(fmt, "\t\t%s=", "name");
  2611. fmtprint(fmt, "\"%s\"", x->to.name);
  2612. fmtprint(fmt, "\n");
  2613. fmtprint(fmt, "\t}");
  2614. fmtprint(fmt, "\n");
  2615. }
  2616. uint
  2617. nfs3TRenameSize(Nfs3TRename *x)
  2618. {
  2619. uint a;
  2620. USED(x);
  2621. a = 0 + nfs3HandleSize(&x->from.handle) + sunStringSize(x->from.name) + nfs3HandleSize(&x->to.handle) + sunStringSize(x->to.name);
  2622. return a;
  2623. }
  2624. int
  2625. nfs3TRenamePack(uchar *a, uchar *ea, uchar **pa, Nfs3TRename *x)
  2626. {
  2627. if(nfs3HandlePack(a, ea, &a, &x->from.handle) < 0) goto Err;
  2628. if(sunStringPack(a, ea, &a, &x->from.name, -1) < 0) goto Err;
  2629. if(nfs3HandlePack(a, ea, &a, &x->to.handle) < 0) goto Err;
  2630. if(sunStringPack(a, ea, &a, &x->to.name, -1) < 0) goto Err;
  2631. *pa = a;
  2632. return 0;
  2633. Err:
  2634. *pa = ea;
  2635. return -1;
  2636. }
  2637. int
  2638. nfs3TRenameUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TRename *x)
  2639. {
  2640. if(nfs3HandleUnpack(a, ea, &a, &x->from.handle) < 0) goto Err;
  2641. if(sunStringUnpack(a, ea, &a, &x->from.name, -1) < 0) goto Err;
  2642. if(nfs3HandleUnpack(a, ea, &a, &x->to.handle) < 0) goto Err;
  2643. if(sunStringUnpack(a, ea, &a, &x->to.name, -1) < 0) goto Err;
  2644. *pa = a;
  2645. return 0;
  2646. Err:
  2647. *pa = ea;
  2648. return -1;
  2649. }
  2650. void
  2651. nfs3RRenamePrint(Fmt *fmt, Nfs3RRename *x)
  2652. {
  2653. fmtprint(fmt, "%s\n", "Nfs3RRename");
  2654. fmtprint(fmt, "\t%s=", "status");
  2655. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  2656. fmtprint(fmt, "\n");
  2657. fmtprint(fmt, "\t%s=", "fromWcc");
  2658. nfs3WccPrint(fmt, &x->fromWcc);
  2659. fmtprint(fmt, "\n");
  2660. fmtprint(fmt, "\t%s=", "toWcc");
  2661. nfs3WccPrint(fmt, &x->toWcc);
  2662. fmtprint(fmt, "\n");
  2663. }
  2664. uint
  2665. nfs3RRenameSize(Nfs3RRename *x)
  2666. {
  2667. uint a;
  2668. USED(x);
  2669. a = 0 + 4 + nfs3WccSize(&x->fromWcc) + nfs3WccSize(&x->toWcc);
  2670. return a;
  2671. }
  2672. int
  2673. nfs3RRenamePack(uchar *a, uchar *ea, uchar **pa, Nfs3RRename *x)
  2674. {
  2675. int i;
  2676. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  2677. if(nfs3WccPack(a, ea, &a, &x->fromWcc) < 0) goto Err;
  2678. if(nfs3WccPack(a, ea, &a, &x->toWcc) < 0) goto Err;
  2679. *pa = a;
  2680. return 0;
  2681. Err:
  2682. *pa = ea;
  2683. return -1;
  2684. }
  2685. int
  2686. nfs3RRenameUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RRename *x)
  2687. {
  2688. int i;
  2689. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  2690. if(nfs3WccUnpack(a, ea, &a, &x->fromWcc) < 0) goto Err;
  2691. if(nfs3WccUnpack(a, ea, &a, &x->toWcc) < 0) goto Err;
  2692. *pa = a;
  2693. return 0;
  2694. Err:
  2695. *pa = ea;
  2696. return -1;
  2697. }
  2698. void
  2699. nfs3TLinkPrint(Fmt *fmt, Nfs3TLink *x)
  2700. {
  2701. fmtprint(fmt, "%s\n", "Nfs3TLink");
  2702. fmtprint(fmt, "\t%s=", "handle");
  2703. nfs3HandlePrint(fmt, &x->handle);
  2704. fmtprint(fmt, "\n");
  2705. fmtprint(fmt, "\t%s=", "link");
  2706. fmtprint(fmt, "{\n");
  2707. fmtprint(fmt, "\t\t%s=", "handle");
  2708. nfs3HandlePrint(fmt, &x->link.handle);
  2709. fmtprint(fmt, "\n");
  2710. fmtprint(fmt, "\t\t%s=", "name");
  2711. fmtprint(fmt, "\"%s\"", x->link.name);
  2712. fmtprint(fmt, "\n");
  2713. fmtprint(fmt, "\t}");
  2714. fmtprint(fmt, "\n");
  2715. }
  2716. uint
  2717. nfs3TLinkSize(Nfs3TLink *x)
  2718. {
  2719. uint a;
  2720. USED(x);
  2721. a = 0 + nfs3HandleSize(&x->handle) + nfs3HandleSize(&x->link.handle) + sunStringSize(x->link.name);
  2722. return a;
  2723. }
  2724. int
  2725. nfs3TLinkPack(uchar *a, uchar *ea, uchar **pa, Nfs3TLink *x)
  2726. {
  2727. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  2728. if(nfs3HandlePack(a, ea, &a, &x->link.handle) < 0) goto Err;
  2729. if(sunStringPack(a, ea, &a, &x->link.name, -1) < 0) goto Err;
  2730. *pa = a;
  2731. return 0;
  2732. Err:
  2733. *pa = ea;
  2734. return -1;
  2735. }
  2736. int
  2737. nfs3TLinkUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TLink *x)
  2738. {
  2739. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  2740. if(nfs3HandleUnpack(a, ea, &a, &x->link.handle) < 0) goto Err;
  2741. if(sunStringUnpack(a, ea, &a, &x->link.name, -1) < 0) goto Err;
  2742. *pa = a;
  2743. return 0;
  2744. Err:
  2745. *pa = ea;
  2746. return -1;
  2747. }
  2748. void
  2749. nfs3RLinkPrint(Fmt *fmt, Nfs3RLink *x)
  2750. {
  2751. fmtprint(fmt, "%s\n", "Nfs3RLink");
  2752. fmtprint(fmt, "\t%s=", "status");
  2753. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  2754. fmtprint(fmt, "\n");
  2755. fmtprint(fmt, "\t%s=", "haveAttr");
  2756. fmtprint(fmt, "%d", x->haveAttr);
  2757. fmtprint(fmt, "\n");
  2758. switch(x->haveAttr){
  2759. case 1:
  2760. fmtprint(fmt, "\t%s=", "attr");
  2761. nfs3AttrPrint(fmt, &x->attr);
  2762. fmtprint(fmt, "\n");
  2763. break;
  2764. }
  2765. fmtprint(fmt, "\t%s=", "dirWcc");
  2766. nfs3WccPrint(fmt, &x->dirWcc);
  2767. fmtprint(fmt, "\n");
  2768. }
  2769. uint
  2770. nfs3RLinkSize(Nfs3RLink *x)
  2771. {
  2772. uint a;
  2773. USED(x);
  2774. a = 0 + 4 + 4;
  2775. switch(x->haveAttr){
  2776. case 1:
  2777. a = a + nfs3AttrSize(&x->attr);
  2778. break;
  2779. }
  2780. a = a + nfs3WccSize(&x->dirWcc);
  2781. return a;
  2782. }
  2783. int
  2784. nfs3RLinkPack(uchar *a, uchar *ea, uchar **pa, Nfs3RLink *x)
  2785. {
  2786. int i;
  2787. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  2788. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  2789. switch(x->haveAttr){
  2790. case 1:
  2791. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  2792. break;
  2793. }
  2794. if(nfs3WccPack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  2795. *pa = a;
  2796. return 0;
  2797. Err:
  2798. *pa = ea;
  2799. return -1;
  2800. }
  2801. int
  2802. nfs3RLinkUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RLink *x)
  2803. {
  2804. int i;
  2805. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  2806. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  2807. switch(x->haveAttr){
  2808. case 1:
  2809. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  2810. break;
  2811. }
  2812. if(nfs3WccUnpack(a, ea, &a, &x->dirWcc) < 0) goto Err;
  2813. *pa = a;
  2814. return 0;
  2815. Err:
  2816. *pa = ea;
  2817. return -1;
  2818. }
  2819. void
  2820. nfs3TReadDirPrint(Fmt *fmt, Nfs3TReadDir *x)
  2821. {
  2822. fmtprint(fmt, "%s\n", "Nfs3TReadDir");
  2823. fmtprint(fmt, "\t%s=", "handle");
  2824. nfs3HandlePrint(fmt, &x->handle);
  2825. fmtprint(fmt, "\n");
  2826. fmtprint(fmt, "\t%s=", "cookie");
  2827. fmtprint(fmt, "%llud", x->cookie);
  2828. fmtprint(fmt, "\n");
  2829. fmtprint(fmt, "\t%s=", "verf");
  2830. fmtprint(fmt, "%.*H", Nfs3CookieVerfSize, x->verf);
  2831. fmtprint(fmt, "\n");
  2832. fmtprint(fmt, "\t%s=", "count");
  2833. fmtprint(fmt, "%ud", x->count);
  2834. fmtprint(fmt, "\n");
  2835. }
  2836. uint
  2837. nfs3TReadDirSize(Nfs3TReadDir *x)
  2838. {
  2839. uint a;
  2840. USED(x);
  2841. a = 0 + nfs3HandleSize(&x->handle) + 8 + Nfs3CookieVerfSize + 4;
  2842. return a;
  2843. }
  2844. int
  2845. nfs3TReadDirPack(uchar *a, uchar *ea, uchar **pa, Nfs3TReadDir *x)
  2846. {
  2847. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  2848. if(sunUint64Pack(a, ea, &a, &x->cookie) < 0) goto Err;
  2849. if(sunFixedOpaquePack(a, ea, &a, x->verf, Nfs3CookieVerfSize) < 0) goto Err;
  2850. if(sunUint32Pack(a, ea, &a, &x->count) < 0) goto Err;
  2851. *pa = a;
  2852. return 0;
  2853. Err:
  2854. *pa = ea;
  2855. return -1;
  2856. }
  2857. int
  2858. nfs3TReadDirUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TReadDir *x)
  2859. {
  2860. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  2861. if(sunUint64Unpack(a, ea, &a, &x->cookie) < 0) goto Err;
  2862. if(sunFixedOpaqueUnpack(a, ea, &a, x->verf, Nfs3CookieVerfSize) < 0) goto Err;
  2863. if(sunUint32Unpack(a, ea, &a, &x->count) < 0) goto Err;
  2864. *pa = a;
  2865. return 0;
  2866. Err:
  2867. *pa = ea;
  2868. return -1;
  2869. }
  2870. void
  2871. nfs3EntryPrint(Fmt *fmt, Nfs3Entry *x)
  2872. {
  2873. fmtprint(fmt, "%s\n", "Nfs3Entry");
  2874. fmtprint(fmt, "\t%s=", "fileid");
  2875. fmtprint(fmt, "%llud", x->fileid);
  2876. fmtprint(fmt, "\n");
  2877. fmtprint(fmt, "\t%s=", "name");
  2878. fmtprint(fmt, "\"%s\"", x->name);
  2879. fmtprint(fmt, "\n");
  2880. fmtprint(fmt, "\t%s=", "cookie");
  2881. fmtprint(fmt, "%llud", x->cookie);
  2882. fmtprint(fmt, "\n");
  2883. }
  2884. uint
  2885. nfs3EntrySize(Nfs3Entry *x)
  2886. {
  2887. uint a;
  2888. USED(x);
  2889. a = 0 + 4 + 8 + sunStringSize(x->name) + 8;
  2890. return a;
  2891. }
  2892. int
  2893. nfs3EntryPack(uchar *a, uchar *ea, uchar **pa, Nfs3Entry *x)
  2894. {
  2895. u1int one;
  2896. one = 1;
  2897. if(sunUint1Pack(a, ea, &a, &one) < 0) goto Err;
  2898. if(sunUint64Pack(a, ea, &a, &x->fileid) < 0) goto Err;
  2899. if(sunStringPack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2900. if(sunUint64Pack(a, ea, &a, &x->cookie) < 0) goto Err;
  2901. *pa = a;
  2902. return 0;
  2903. Err:
  2904. *pa = ea;
  2905. return -1;
  2906. }
  2907. int
  2908. nfs3EntryUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Entry *x)
  2909. {
  2910. u1int one;
  2911. memset(x, 0, sizeof *x);
  2912. if(sunUint1Unpack(a, ea, &a, &one) < 0 || one != 1) goto Err;
  2913. if(sunUint64Unpack(a, ea, &a, &x->fileid) < 0) goto Err;
  2914. if(sunStringUnpack(a, ea, &a, &x->name, -1) < 0) goto Err;
  2915. if(sunUint64Unpack(a, ea, &a, &x->cookie) < 0) goto Err;
  2916. *pa = a;
  2917. return 0;
  2918. Err:
  2919. *pa = ea;
  2920. return -1;
  2921. }
  2922. void
  2923. nfs3RReadDirPrint(Fmt *fmt, Nfs3RReadDir *x)
  2924. {
  2925. fmtprint(fmt, "%s\n", "Nfs3RReadDir");
  2926. fmtprint(fmt, "\t%s=", "status");
  2927. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  2928. fmtprint(fmt, "\n");
  2929. fmtprint(fmt, "\t%s=", "haveAttr");
  2930. fmtprint(fmt, "%d", x->haveAttr);
  2931. fmtprint(fmt, "\n");
  2932. switch(x->haveAttr){
  2933. case 1:
  2934. fmtprint(fmt, "\t%s=", "attr");
  2935. nfs3AttrPrint(fmt, &x->attr);
  2936. fmtprint(fmt, "\n");
  2937. break;
  2938. }
  2939. switch(x->status){
  2940. case Nfs3Ok:
  2941. fmtprint(fmt, "\t%s=", "verf");
  2942. fmtprint(fmt, "%.*H", Nfs3CookieVerfSize, x->verf);
  2943. fmtprint(fmt, "\n");
  2944. fmtprint(fmt, "\t%s=%ud\n", "count", x->count);
  2945. fmtprint(fmt, "\t%s=", "eof");
  2946. fmtprint(fmt, "%d", x->eof);
  2947. fmtprint(fmt, "\n");
  2948. break;
  2949. }
  2950. }
  2951. uint
  2952. nfs3RReadDirSize(Nfs3RReadDir *x)
  2953. {
  2954. uint a;
  2955. USED(x);
  2956. a = 0 + 4 + 4;
  2957. switch(x->haveAttr){
  2958. case 1:
  2959. a = a + nfs3AttrSize(&x->attr);
  2960. break;
  2961. }
  2962. switch(x->status){
  2963. case Nfs3Ok:
  2964. a = a + Nfs3CookieVerfSize;
  2965. a += x->count;
  2966. a += 4 + 4;
  2967. break;
  2968. }
  2969. return a;
  2970. }
  2971. int
  2972. nfs3RReadDirPack(uchar *a, uchar *ea, uchar **pa, Nfs3RReadDir *x)
  2973. {
  2974. int i;
  2975. u1int zero;
  2976. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  2977. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  2978. switch(x->haveAttr){
  2979. case 1:
  2980. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  2981. break;
  2982. }
  2983. switch(x->status){
  2984. case Nfs3Ok:
  2985. if(sunFixedOpaquePack(a, ea, &a, x->verf, Nfs3CookieVerfSize) < 0) goto Err;
  2986. if(sunFixedOpaquePack(a, ea, &a, x->data, x->count) < 0) goto Err;
  2987. zero = 0;
  2988. if(sunUint1Pack(a, ea, &a, &zero) < 0) goto Err;
  2989. if(sunUint1Pack(a, ea, &a, &x->eof) < 0) goto Err;
  2990. break;
  2991. }
  2992. *pa = a;
  2993. return 0;
  2994. Err:
  2995. *pa = ea;
  2996. return -1;
  2997. }
  2998. static int
  2999. countEntry(uchar *a, uchar *ea, uchar **pa, u32int *n)
  3000. {
  3001. uchar *oa;
  3002. u64int u64;
  3003. u32int u32;
  3004. u1int u1;
  3005. oa = a;
  3006. for(;;){
  3007. if(sunUint1Unpack(a, ea, &a, &u1) < 0)
  3008. return -1;
  3009. if(u1 == 0)
  3010. break;
  3011. if(sunUint64Unpack(a, ea, &a, &u64) < 0
  3012. || sunUint32Unpack(a, ea, &a, &u32) < 0)
  3013. return -1;
  3014. a += (u32+3)&~3;
  3015. if(a >= ea)
  3016. return -1;
  3017. if(sunUint64Unpack(a, ea, &a, &u64) < 0)
  3018. return -1;
  3019. }
  3020. *n = (a-4) - oa;
  3021. *pa = a;
  3022. return 0;
  3023. }
  3024. int
  3025. nfs3RReadDirUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RReadDir *x)
  3026. {
  3027. int i;
  3028. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  3029. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3030. switch(x->haveAttr){
  3031. case 1:
  3032. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  3033. break;
  3034. }
  3035. if(x->status == Nfs3Ok){
  3036. if(sunFixedOpaqueUnpack(a, ea, &a, x->verf, Nfs3CookieVerfSize) < 0) goto Err;
  3037. x->data = a;
  3038. if(countEntry(a, ea, &a, &x->count) < 0) goto Err;
  3039. if(sunUint1Unpack(a, ea, &a, &x->eof) < 0) goto Err;
  3040. }
  3041. *pa = a;
  3042. return 0;
  3043. Err:
  3044. *pa = ea;
  3045. return -1;
  3046. }
  3047. void
  3048. nfs3TReadDirPlusPrint(Fmt *fmt, Nfs3TReadDirPlus *x)
  3049. {
  3050. fmtprint(fmt, "%s\n", "Nfs3TReadDirPlus");
  3051. fmtprint(fmt, "\t%s=", "handle");
  3052. nfs3HandlePrint(fmt, &x->handle);
  3053. fmtprint(fmt, "\n");
  3054. fmtprint(fmt, "\t%s=", "cookie");
  3055. fmtprint(fmt, "%llud", x->cookie);
  3056. fmtprint(fmt, "\n");
  3057. fmtprint(fmt, "\t%s=", "verf");
  3058. fmtprint(fmt, "%.*H", Nfs3CookieVerfSize, x->verf);
  3059. fmtprint(fmt, "\n");
  3060. fmtprint(fmt, "\t%s=", "dirCount");
  3061. fmtprint(fmt, "%ud", x->dirCount);
  3062. fmtprint(fmt, "\n");
  3063. fmtprint(fmt, "\t%s=", "maxCount");
  3064. fmtprint(fmt, "%ud", x->maxCount);
  3065. fmtprint(fmt, "\n");
  3066. }
  3067. uint
  3068. nfs3TReadDirPlusSize(Nfs3TReadDirPlus *x)
  3069. {
  3070. uint a;
  3071. USED(x);
  3072. a = 0 + nfs3HandleSize(&x->handle) + 8 + Nfs3CookieVerfSize + 4 + 4;
  3073. return a;
  3074. }
  3075. int
  3076. nfs3TReadDirPlusPack(uchar *a, uchar *ea, uchar **pa, Nfs3TReadDirPlus *x)
  3077. {
  3078. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  3079. if(sunUint64Pack(a, ea, &a, &x->cookie) < 0) goto Err;
  3080. if(sunFixedOpaquePack(a, ea, &a, x->verf, Nfs3CookieVerfSize) < 0) goto Err;
  3081. if(sunUint32Pack(a, ea, &a, &x->dirCount) < 0) goto Err;
  3082. if(sunUint32Pack(a, ea, &a, &x->maxCount) < 0) goto Err;
  3083. *pa = a;
  3084. return 0;
  3085. Err:
  3086. *pa = ea;
  3087. return -1;
  3088. }
  3089. int
  3090. nfs3TReadDirPlusUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TReadDirPlus *x)
  3091. {
  3092. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  3093. if(sunUint64Unpack(a, ea, &a, &x->cookie) < 0) goto Err;
  3094. if(sunFixedOpaqueUnpack(a, ea, &a, x->verf, Nfs3CookieVerfSize) < 0) goto Err;
  3095. if(sunUint32Unpack(a, ea, &a, &x->dirCount) < 0) goto Err;
  3096. if(sunUint32Unpack(a, ea, &a, &x->maxCount) < 0) goto Err;
  3097. *pa = a;
  3098. return 0;
  3099. Err:
  3100. *pa = ea;
  3101. return -1;
  3102. }
  3103. void
  3104. nfs3EntryPlusPrint(Fmt *fmt, Nfs3Entry *x)
  3105. {
  3106. fmtprint(fmt, "%s\n", "Nfs3EntryPlus");
  3107. fmtprint(fmt, "\t%s=", "fileid");
  3108. fmtprint(fmt, "%llud", x->fileid);
  3109. fmtprint(fmt, "\n");
  3110. fmtprint(fmt, "\t%s=", "name");
  3111. fmtprint(fmt, "\"%s\"", x->name);
  3112. fmtprint(fmt, "\n");
  3113. fmtprint(fmt, "\t%s=", "cookie");
  3114. fmtprint(fmt, "%llud", x->cookie);
  3115. fmtprint(fmt, "\n");
  3116. fmtprint(fmt, "\t%s=", "haveAttr");
  3117. fmtprint(fmt, "%d", x->haveAttr);
  3118. fmtprint(fmt, "\n");
  3119. switch(x->haveAttr){
  3120. case 1:
  3121. fmtprint(fmt, "\t%s=", "attr");
  3122. nfs3AttrPrint(fmt, &x->attr);
  3123. fmtprint(fmt, "\n");
  3124. break;
  3125. }
  3126. fmtprint(fmt, "\t%s=", "haveHandle");
  3127. fmtprint(fmt, "%d", x->haveHandle);
  3128. fmtprint(fmt, "\n");
  3129. switch(x->haveHandle){
  3130. case 1:
  3131. fmtprint(fmt, "\t%s=", "handle");
  3132. nfs3HandlePrint(fmt, &x->handle);
  3133. fmtprint(fmt, "\n");
  3134. break;
  3135. }
  3136. }
  3137. uint
  3138. nfs3EntryPlusSize(Nfs3Entry *x)
  3139. {
  3140. uint a;
  3141. USED(x);
  3142. a = 0 + 8 + sunStringSize(x->name) + 8 + 4;
  3143. switch(x->haveAttr){
  3144. case 1:
  3145. a = a + nfs3AttrSize(&x->attr);
  3146. break;
  3147. }
  3148. a = a + 4;
  3149. switch(x->haveHandle){
  3150. case 1:
  3151. a = a + nfs3HandleSize(&x->handle);
  3152. break;
  3153. }
  3154. return a;
  3155. }
  3156. int
  3157. nfs3EntryPlusPack(uchar *a, uchar *ea, uchar **pa, Nfs3Entry *x)
  3158. {
  3159. u1int u1;
  3160. if(sunUint1Pack(a, ea, &a, &u1) < 0) goto Err;
  3161. if(sunUint64Pack(a, ea, &a, &x->fileid) < 0) goto Err;
  3162. if(sunStringPack(a, ea, &a, &x->name, -1) < 0) goto Err;
  3163. if(sunUint64Pack(a, ea, &a, &x->cookie) < 0) goto Err;
  3164. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3165. switch(x->haveAttr){
  3166. case 1:
  3167. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  3168. break;
  3169. }
  3170. if(sunUint1Pack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  3171. switch(x->haveHandle){
  3172. case 1:
  3173. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  3174. break;
  3175. }
  3176. *pa = a;
  3177. return 0;
  3178. Err:
  3179. *pa = ea;
  3180. return -1;
  3181. }
  3182. int
  3183. nfs3EntryPlusUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Entry *x)
  3184. {
  3185. u1int u1;
  3186. if(sunUint1Unpack(a, ea, &a, &u1) < 0 || u1 != 1) goto Err;
  3187. if(sunUint64Unpack(a, ea, &a, &x->fileid) < 0) goto Err;
  3188. if(sunStringUnpack(a, ea, &a, &x->name, -1) < 0) goto Err;
  3189. if(sunUint64Unpack(a, ea, &a, &x->cookie) < 0) goto Err;
  3190. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3191. switch(x->haveAttr){
  3192. case 1:
  3193. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  3194. break;
  3195. }
  3196. if(sunUint1Unpack(a, ea, &a, &x->haveHandle) < 0) goto Err;
  3197. switch(x->haveHandle){
  3198. case 1:
  3199. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  3200. break;
  3201. }
  3202. *pa = a;
  3203. return 0;
  3204. Err:
  3205. *pa = ea;
  3206. return -1;
  3207. }
  3208. void
  3209. nfs3RReadDirPlusPrint(Fmt *fmt, Nfs3RReadDirPlus *x)
  3210. {
  3211. fmtprint(fmt, "%s\n", "Nfs3RReadDirPlus");
  3212. fmtprint(fmt, "\t%s=", "status");
  3213. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  3214. fmtprint(fmt, "\n");
  3215. fmtprint(fmt, "\t%s=", "haveAttr");
  3216. fmtprint(fmt, "%d", x->haveAttr);
  3217. fmtprint(fmt, "\n");
  3218. switch(x->haveAttr){
  3219. case 1:
  3220. fmtprint(fmt, "\t%s=", "attr");
  3221. nfs3AttrPrint(fmt, &x->attr);
  3222. fmtprint(fmt, "\n");
  3223. break;
  3224. }
  3225. switch(x->status){
  3226. case Nfs3Ok:
  3227. fmtprint(fmt, "\t%s=", "verf");
  3228. fmtprint(fmt, "%.*H", Nfs3CookieVerfSize, x->verf);
  3229. fmtprint(fmt, "\n");
  3230. fmtprint(fmt, "\tcount=%ud\n", x->count);
  3231. fmtprint(fmt, "\t%s=", "eof");
  3232. fmtprint(fmt, "%d", x->eof);
  3233. fmtprint(fmt, "\n");
  3234. break;
  3235. }
  3236. }
  3237. uint
  3238. nfs3RReadDirPlusSize(Nfs3RReadDirPlus *x)
  3239. {
  3240. uint a;
  3241. USED(x);
  3242. a = 0 + 4 + 4;
  3243. switch(x->haveAttr){
  3244. case 1:
  3245. a = a + nfs3AttrSize(&x->attr);
  3246. break;
  3247. }
  3248. switch(x->status){
  3249. case Nfs3Ok:
  3250. a = a + Nfs3CookieVerfSize;
  3251. a += x->count;
  3252. a += 4 + 4;
  3253. break;
  3254. }
  3255. return a;
  3256. }
  3257. int
  3258. nfs3RReadDirPlusPack(uchar *a, uchar *ea, uchar **pa, Nfs3RReadDirPlus *x)
  3259. {
  3260. int i;
  3261. u1int zero;
  3262. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  3263. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3264. switch(x->haveAttr){
  3265. case 1:
  3266. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  3267. break;
  3268. }
  3269. switch(x->status){
  3270. case Nfs3Ok:
  3271. if(sunFixedOpaquePack(a, ea, &a, x->verf, Nfs3CookieVerfSize) < 0) goto Err;
  3272. if(sunFixedOpaquePack(a, ea, &a, x->data, x->count) < 0) goto Err;
  3273. zero = 0;
  3274. if(sunUint1Pack(a, ea, &a, &zero) < 0) goto Err;
  3275. if(sunUint1Pack(a, ea, &a, &x->eof) < 0) goto Err;
  3276. break;
  3277. }
  3278. *pa = a;
  3279. return 0;
  3280. Err:
  3281. *pa = ea;
  3282. return -1;
  3283. }
  3284. static int
  3285. countEntryPlus(uchar *a, uchar *ea, uchar **pa, u32int *n)
  3286. {
  3287. uchar *oa;
  3288. u64int u64;
  3289. u32int u32;
  3290. u1int u1;
  3291. Nfs3Handle h;
  3292. Nfs3Attr attr;
  3293. oa = a;
  3294. for(;;){
  3295. if(sunUint1Unpack(a, ea, &a, &u1) < 0)
  3296. return -1;
  3297. if(u1 == 0)
  3298. break;
  3299. if(sunUint64Unpack(a, ea, &a, &u64) < 0
  3300. || sunUint32Unpack(a, ea, &a, &u32) < 0)
  3301. return -1;
  3302. a += (u32+3)&~3;
  3303. if(a >= ea)
  3304. return -1;
  3305. if(sunUint64Unpack(a, ea, &a, &u64) < 0
  3306. || sunUint1Unpack(a, ea, &a, &u1) < 0
  3307. || (u1 && nfs3AttrUnpack(a, ea, &a, &attr) < 0)
  3308. || sunUint1Unpack(a, ea, &a, &u1) < 0
  3309. || (u1 && nfs3HandleUnpack(a, ea, &a, &h) < 0))
  3310. return -1;
  3311. }
  3312. *n = (a-4) - oa;
  3313. *pa = a;
  3314. return 0;
  3315. }
  3316. int
  3317. nfs3RReadDirPlusUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RReadDirPlus *x)
  3318. {
  3319. int i;
  3320. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  3321. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3322. switch(x->haveAttr){
  3323. case 1:
  3324. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  3325. break;
  3326. }
  3327. if(x->status == Nfs3Ok){
  3328. if(sunFixedOpaqueUnpack(a, ea, &a, x->verf, Nfs3CookieVerfSize) < 0) goto Err;
  3329. x->data = a;
  3330. if(countEntryPlus(a, ea, &a, &x->count) < 0) goto Err;
  3331. if(sunUint1Unpack(a, ea, &a, &x->eof) < 0) goto Err;
  3332. }
  3333. *pa = a;
  3334. return 0;
  3335. Err:
  3336. *pa = ea;
  3337. return -1;
  3338. }
  3339. void
  3340. nfs3TFsStatPrint(Fmt *fmt, Nfs3TFsStat *x)
  3341. {
  3342. fmtprint(fmt, "%s\n", "Nfs3TFsStat");
  3343. fmtprint(fmt, "\t%s=", "handle");
  3344. nfs3HandlePrint(fmt, &x->handle);
  3345. fmtprint(fmt, "\n");
  3346. }
  3347. uint
  3348. nfs3TFsStatSize(Nfs3TFsStat *x)
  3349. {
  3350. uint a;
  3351. USED(x);
  3352. a = 0 + nfs3HandleSize(&x->handle);
  3353. return a;
  3354. }
  3355. int
  3356. nfs3TFsStatPack(uchar *a, uchar *ea, uchar **pa, Nfs3TFsStat *x)
  3357. {
  3358. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  3359. *pa = a;
  3360. return 0;
  3361. Err:
  3362. *pa = ea;
  3363. return -1;
  3364. }
  3365. int
  3366. nfs3TFsStatUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TFsStat *x)
  3367. {
  3368. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  3369. *pa = a;
  3370. return 0;
  3371. Err:
  3372. *pa = ea;
  3373. return -1;
  3374. }
  3375. void
  3376. nfs3RFsStatPrint(Fmt *fmt, Nfs3RFsStat *x)
  3377. {
  3378. fmtprint(fmt, "%s\n", "Nfs3RFsStat");
  3379. fmtprint(fmt, "\t%s=", "status");
  3380. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  3381. fmtprint(fmt, "\n");
  3382. fmtprint(fmt, "\t%s=", "haveAttr");
  3383. fmtprint(fmt, "%d", x->haveAttr);
  3384. fmtprint(fmt, "\n");
  3385. switch(x->haveAttr){
  3386. case 1:
  3387. fmtprint(fmt, "\t%s=", "attr");
  3388. nfs3AttrPrint(fmt, &x->attr);
  3389. fmtprint(fmt, "\n");
  3390. break;
  3391. }
  3392. switch(x->status){
  3393. case Nfs3Ok:
  3394. fmtprint(fmt, "\t%s=", "totalBytes");
  3395. fmtprint(fmt, "%llud", x->totalBytes);
  3396. fmtprint(fmt, "\n");
  3397. fmtprint(fmt, "\t%s=", "freeBytes");
  3398. fmtprint(fmt, "%llud", x->freeBytes);
  3399. fmtprint(fmt, "\n");
  3400. fmtprint(fmt, "\t%s=", "availBytes");
  3401. fmtprint(fmt, "%llud", x->availBytes);
  3402. fmtprint(fmt, "\n");
  3403. fmtprint(fmt, "\t%s=", "totalFiles");
  3404. fmtprint(fmt, "%llud", x->totalFiles);
  3405. fmtprint(fmt, "\n");
  3406. fmtprint(fmt, "\t%s=", "freeFiles");
  3407. fmtprint(fmt, "%llud", x->freeFiles);
  3408. fmtprint(fmt, "\n");
  3409. fmtprint(fmt, "\t%s=", "availFiles");
  3410. fmtprint(fmt, "%llud", x->availFiles);
  3411. fmtprint(fmt, "\n");
  3412. fmtprint(fmt, "\t%s=", "invarSec");
  3413. fmtprint(fmt, "%ud", x->invarSec);
  3414. fmtprint(fmt, "\n");
  3415. break;
  3416. }
  3417. }
  3418. uint
  3419. nfs3RFsStatSize(Nfs3RFsStat *x)
  3420. {
  3421. uint a;
  3422. USED(x);
  3423. a = 0 + 4 + 4;
  3424. switch(x->haveAttr){
  3425. case 1:
  3426. a = a + nfs3AttrSize(&x->attr);
  3427. break;
  3428. }
  3429. switch(x->status){
  3430. case Nfs3Ok:
  3431. a = a + 8 + 8 + 8 + 8 + 8 + 8 + 4;
  3432. break;
  3433. }
  3434. return a;
  3435. }
  3436. int
  3437. nfs3RFsStatPack(uchar *a, uchar *ea, uchar **pa, Nfs3RFsStat *x)
  3438. {
  3439. int i;
  3440. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  3441. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3442. switch(x->haveAttr){
  3443. case 1:
  3444. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  3445. break;
  3446. }
  3447. switch(x->status){
  3448. case Nfs3Ok:
  3449. if(sunUint64Pack(a, ea, &a, &x->totalBytes) < 0) goto Err;
  3450. if(sunUint64Pack(a, ea, &a, &x->freeBytes) < 0) goto Err;
  3451. if(sunUint64Pack(a, ea, &a, &x->availBytes) < 0) goto Err;
  3452. if(sunUint64Pack(a, ea, &a, &x->totalFiles) < 0) goto Err;
  3453. if(sunUint64Pack(a, ea, &a, &x->freeFiles) < 0) goto Err;
  3454. if(sunUint64Pack(a, ea, &a, &x->availFiles) < 0) goto Err;
  3455. if(sunUint32Pack(a, ea, &a, &x->invarSec) < 0) goto Err;
  3456. break;
  3457. }
  3458. *pa = a;
  3459. return 0;
  3460. Err:
  3461. *pa = ea;
  3462. return -1;
  3463. }
  3464. int
  3465. nfs3RFsStatUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RFsStat *x)
  3466. {
  3467. int i;
  3468. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  3469. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3470. switch(x->haveAttr){
  3471. case 1:
  3472. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  3473. break;
  3474. }
  3475. switch(x->status){
  3476. case Nfs3Ok:
  3477. if(sunUint64Unpack(a, ea, &a, &x->totalBytes) < 0) goto Err;
  3478. if(sunUint64Unpack(a, ea, &a, &x->freeBytes) < 0) goto Err;
  3479. if(sunUint64Unpack(a, ea, &a, &x->availBytes) < 0) goto Err;
  3480. if(sunUint64Unpack(a, ea, &a, &x->totalFiles) < 0) goto Err;
  3481. if(sunUint64Unpack(a, ea, &a, &x->freeFiles) < 0) goto Err;
  3482. if(sunUint64Unpack(a, ea, &a, &x->availFiles) < 0) goto Err;
  3483. if(sunUint32Unpack(a, ea, &a, &x->invarSec) < 0) goto Err;
  3484. break;
  3485. }
  3486. *pa = a;
  3487. return 0;
  3488. Err:
  3489. *pa = ea;
  3490. return -1;
  3491. }
  3492. void
  3493. nfs3TFsInfoPrint(Fmt *fmt, Nfs3TFsInfo *x)
  3494. {
  3495. fmtprint(fmt, "%s\n", "Nfs3TFsInfo");
  3496. fmtprint(fmt, "\t%s=", "handle");
  3497. nfs3HandlePrint(fmt, &x->handle);
  3498. fmtprint(fmt, "\n");
  3499. }
  3500. uint
  3501. nfs3TFsInfoSize(Nfs3TFsInfo *x)
  3502. {
  3503. uint a;
  3504. USED(x);
  3505. a = 0 + nfs3HandleSize(&x->handle);
  3506. return a;
  3507. }
  3508. int
  3509. nfs3TFsInfoPack(uchar *a, uchar *ea, uchar **pa, Nfs3TFsInfo *x)
  3510. {
  3511. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  3512. *pa = a;
  3513. return 0;
  3514. Err:
  3515. *pa = ea;
  3516. return -1;
  3517. }
  3518. int
  3519. nfs3TFsInfoUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TFsInfo *x)
  3520. {
  3521. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  3522. *pa = a;
  3523. return 0;
  3524. Err:
  3525. *pa = ea;
  3526. return -1;
  3527. }
  3528. void
  3529. nfs3RFsInfoPrint(Fmt *fmt, Nfs3RFsInfo *x)
  3530. {
  3531. fmtprint(fmt, "%s\n", "Nfs3RFsInfo");
  3532. fmtprint(fmt, "\t%s=", "status");
  3533. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  3534. fmtprint(fmt, "\n");
  3535. fmtprint(fmt, "\t%s=", "haveAttr");
  3536. fmtprint(fmt, "%d", x->haveAttr);
  3537. fmtprint(fmt, "\n");
  3538. switch(x->haveAttr){
  3539. case 1:
  3540. fmtprint(fmt, "\t%s=", "attr");
  3541. nfs3AttrPrint(fmt, &x->attr);
  3542. fmtprint(fmt, "\n");
  3543. break;
  3544. }
  3545. switch(x->status){
  3546. case Nfs3Ok:
  3547. fmtprint(fmt, "\t%s=", "readMax");
  3548. fmtprint(fmt, "%ud", x->readMax);
  3549. fmtprint(fmt, "\n");
  3550. fmtprint(fmt, "\t%s=", "readPref");
  3551. fmtprint(fmt, "%ud", x->readPref);
  3552. fmtprint(fmt, "\n");
  3553. fmtprint(fmt, "\t%s=", "readMult");
  3554. fmtprint(fmt, "%ud", x->readMult);
  3555. fmtprint(fmt, "\n");
  3556. fmtprint(fmt, "\t%s=", "writeMax");
  3557. fmtprint(fmt, "%ud", x->writeMax);
  3558. fmtprint(fmt, "\n");
  3559. fmtprint(fmt, "\t%s=", "writePref");
  3560. fmtprint(fmt, "%ud", x->writePref);
  3561. fmtprint(fmt, "\n");
  3562. fmtprint(fmt, "\t%s=", "writeMult");
  3563. fmtprint(fmt, "%ud", x->writeMult);
  3564. fmtprint(fmt, "\n");
  3565. fmtprint(fmt, "\t%s=", "readDirPref");
  3566. fmtprint(fmt, "%ud", x->readDirPref);
  3567. fmtprint(fmt, "\n");
  3568. fmtprint(fmt, "\t%s=", "maxFileSize");
  3569. fmtprint(fmt, "%llud", x->maxFileSize);
  3570. fmtprint(fmt, "\n");
  3571. fmtprint(fmt, "\t%s=", "timePrec");
  3572. nfs3TimePrint(fmt, &x->timePrec);
  3573. fmtprint(fmt, "\n");
  3574. fmtprint(fmt, "\t%s=", "flags");
  3575. fmtprint(fmt, "%ud", x->flags);
  3576. fmtprint(fmt, "\n");
  3577. break;
  3578. }
  3579. }
  3580. uint
  3581. nfs3RFsInfoSize(Nfs3RFsInfo *x)
  3582. {
  3583. uint a;
  3584. USED(x);
  3585. a = 0 + 4 + 4;
  3586. switch(x->haveAttr){
  3587. case 1:
  3588. a = a + nfs3AttrSize(&x->attr);
  3589. break;
  3590. }
  3591. switch(x->status){
  3592. case Nfs3Ok:
  3593. a = a + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 8 + nfs3TimeSize(&x->timePrec) + 4;
  3594. break;
  3595. }
  3596. return a;
  3597. }
  3598. int
  3599. nfs3RFsInfoPack(uchar *a, uchar *ea, uchar **pa, Nfs3RFsInfo *x)
  3600. {
  3601. int i;
  3602. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  3603. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3604. switch(x->haveAttr){
  3605. case 1:
  3606. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  3607. break;
  3608. }
  3609. switch(x->status){
  3610. case Nfs3Ok:
  3611. if(sunUint32Pack(a, ea, &a, &x->readMax) < 0) goto Err;
  3612. if(sunUint32Pack(a, ea, &a, &x->readPref) < 0) goto Err;
  3613. if(sunUint32Pack(a, ea, &a, &x->readMult) < 0) goto Err;
  3614. if(sunUint32Pack(a, ea, &a, &x->writeMax) < 0) goto Err;
  3615. if(sunUint32Pack(a, ea, &a, &x->writePref) < 0) goto Err;
  3616. if(sunUint32Pack(a, ea, &a, &x->writeMult) < 0) goto Err;
  3617. if(sunUint32Pack(a, ea, &a, &x->readDirPref) < 0) goto Err;
  3618. if(sunUint64Pack(a, ea, &a, &x->maxFileSize) < 0) goto Err;
  3619. if(nfs3TimePack(a, ea, &a, &x->timePrec) < 0) goto Err;
  3620. if(sunUint32Pack(a, ea, &a, &x->flags) < 0) goto Err;
  3621. break;
  3622. }
  3623. *pa = a;
  3624. return 0;
  3625. Err:
  3626. *pa = ea;
  3627. return -1;
  3628. }
  3629. int
  3630. nfs3RFsInfoUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RFsInfo *x)
  3631. {
  3632. int i;
  3633. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  3634. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3635. switch(x->haveAttr){
  3636. case 1:
  3637. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  3638. break;
  3639. }
  3640. switch(x->status){
  3641. case Nfs3Ok:
  3642. if(sunUint32Unpack(a, ea, &a, &x->readMax) < 0) goto Err;
  3643. if(sunUint32Unpack(a, ea, &a, &x->readPref) < 0) goto Err;
  3644. if(sunUint32Unpack(a, ea, &a, &x->readMult) < 0) goto Err;
  3645. if(sunUint32Unpack(a, ea, &a, &x->writeMax) < 0) goto Err;
  3646. if(sunUint32Unpack(a, ea, &a, &x->writePref) < 0) goto Err;
  3647. if(sunUint32Unpack(a, ea, &a, &x->writeMult) < 0) goto Err;
  3648. if(sunUint32Unpack(a, ea, &a, &x->readDirPref) < 0) goto Err;
  3649. if(sunUint64Unpack(a, ea, &a, &x->maxFileSize) < 0) goto Err;
  3650. if(nfs3TimeUnpack(a, ea, &a, &x->timePrec) < 0) goto Err;
  3651. if(sunUint32Unpack(a, ea, &a, &x->flags) < 0) goto Err;
  3652. break;
  3653. }
  3654. *pa = a;
  3655. return 0;
  3656. Err:
  3657. *pa = ea;
  3658. return -1;
  3659. }
  3660. void
  3661. nfs3TPathconfPrint(Fmt *fmt, Nfs3TPathconf *x)
  3662. {
  3663. fmtprint(fmt, "%s\n", "Nfs3TPathconf");
  3664. fmtprint(fmt, "\t%s=", "handle");
  3665. nfs3HandlePrint(fmt, &x->handle);
  3666. fmtprint(fmt, "\n");
  3667. }
  3668. uint
  3669. nfs3TPathconfSize(Nfs3TPathconf *x)
  3670. {
  3671. uint a;
  3672. USED(x);
  3673. a = 0 + nfs3HandleSize(&x->handle);
  3674. return a;
  3675. }
  3676. int
  3677. nfs3TPathconfPack(uchar *a, uchar *ea, uchar **pa, Nfs3TPathconf *x)
  3678. {
  3679. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  3680. *pa = a;
  3681. return 0;
  3682. Err:
  3683. *pa = ea;
  3684. return -1;
  3685. }
  3686. int
  3687. nfs3TPathconfUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TPathconf *x)
  3688. {
  3689. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  3690. *pa = a;
  3691. return 0;
  3692. Err:
  3693. *pa = ea;
  3694. return -1;
  3695. }
  3696. void
  3697. nfs3RPathconfPrint(Fmt *fmt, Nfs3RPathconf *x)
  3698. {
  3699. fmtprint(fmt, "%s\n", "Nfs3RPathconf");
  3700. fmtprint(fmt, "\t%s=", "status");
  3701. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  3702. fmtprint(fmt, "\n");
  3703. fmtprint(fmt, "\t%s=", "haveAttr");
  3704. fmtprint(fmt, "%d", x->haveAttr);
  3705. fmtprint(fmt, "\n");
  3706. switch(x->haveAttr){
  3707. case 1:
  3708. fmtprint(fmt, "\t%s=", "attr");
  3709. nfs3AttrPrint(fmt, &x->attr);
  3710. fmtprint(fmt, "\n");
  3711. break;
  3712. }
  3713. switch(x->status){
  3714. case Nfs3Ok:
  3715. fmtprint(fmt, "\t%s=", "maxLink");
  3716. fmtprint(fmt, "%ud", x->maxLink);
  3717. fmtprint(fmt, "\n");
  3718. fmtprint(fmt, "\t%s=", "maxName");
  3719. fmtprint(fmt, "%ud", x->maxName);
  3720. fmtprint(fmt, "\n");
  3721. fmtprint(fmt, "\t%s=", "noTrunc");
  3722. fmtprint(fmt, "%d", x->noTrunc);
  3723. fmtprint(fmt, "\n");
  3724. fmtprint(fmt, "\t%s=", "chownRestricted");
  3725. fmtprint(fmt, "%d", x->chownRestricted);
  3726. fmtprint(fmt, "\n");
  3727. fmtprint(fmt, "\t%s=", "caseInsensitive");
  3728. fmtprint(fmt, "%d", x->caseInsensitive);
  3729. fmtprint(fmt, "\n");
  3730. fmtprint(fmt, "\t%s=", "casePreserving");
  3731. fmtprint(fmt, "%d", x->casePreserving);
  3732. fmtprint(fmt, "\n");
  3733. break;
  3734. }
  3735. }
  3736. uint
  3737. nfs3RPathconfSize(Nfs3RPathconf *x)
  3738. {
  3739. uint a;
  3740. USED(x);
  3741. a = 0 + 4 + 4;
  3742. switch(x->haveAttr){
  3743. case 1:
  3744. a = a + nfs3AttrSize(&x->attr);
  3745. break;
  3746. }
  3747. switch(x->status){
  3748. case Nfs3Ok:
  3749. a = a + 4 + 4 + 4 + 4 + 4 + 4;
  3750. break;
  3751. }
  3752. return a;
  3753. }
  3754. int
  3755. nfs3RPathconfPack(uchar *a, uchar *ea, uchar **pa, Nfs3RPathconf *x)
  3756. {
  3757. int i;
  3758. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  3759. if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3760. switch(x->haveAttr){
  3761. case 1:
  3762. if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err;
  3763. break;
  3764. }
  3765. switch(x->status){
  3766. case Nfs3Ok:
  3767. if(sunUint32Pack(a, ea, &a, &x->maxLink) < 0) goto Err;
  3768. if(sunUint32Pack(a, ea, &a, &x->maxName) < 0) goto Err;
  3769. if(sunUint1Pack(a, ea, &a, &x->noTrunc) < 0) goto Err;
  3770. if(sunUint1Pack(a, ea, &a, &x->chownRestricted) < 0) goto Err;
  3771. if(sunUint1Pack(a, ea, &a, &x->caseInsensitive) < 0) goto Err;
  3772. if(sunUint1Pack(a, ea, &a, &x->casePreserving) < 0) goto Err;
  3773. break;
  3774. }
  3775. *pa = a;
  3776. return 0;
  3777. Err:
  3778. *pa = ea;
  3779. return -1;
  3780. }
  3781. int
  3782. nfs3RPathconfUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RPathconf *x)
  3783. {
  3784. int i;
  3785. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  3786. if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err;
  3787. switch(x->haveAttr){
  3788. case 1:
  3789. if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err;
  3790. break;
  3791. }
  3792. switch(x->status){
  3793. case Nfs3Ok:
  3794. if(sunUint32Unpack(a, ea, &a, &x->maxLink) < 0) goto Err;
  3795. if(sunUint32Unpack(a, ea, &a, &x->maxName) < 0) goto Err;
  3796. if(sunUint1Unpack(a, ea, &a, &x->noTrunc) < 0) goto Err;
  3797. if(sunUint1Unpack(a, ea, &a, &x->chownRestricted) < 0) goto Err;
  3798. if(sunUint1Unpack(a, ea, &a, &x->caseInsensitive) < 0) goto Err;
  3799. if(sunUint1Unpack(a, ea, &a, &x->casePreserving) < 0) goto Err;
  3800. break;
  3801. }
  3802. *pa = a;
  3803. return 0;
  3804. Err:
  3805. *pa = ea;
  3806. return -1;
  3807. }
  3808. void
  3809. nfs3TCommitPrint(Fmt *fmt, Nfs3TCommit *x)
  3810. {
  3811. fmtprint(fmt, "%s\n", "Nfs3TCommit");
  3812. fmtprint(fmt, "\t%s=", "handle");
  3813. nfs3HandlePrint(fmt, &x->handle);
  3814. fmtprint(fmt, "\n");
  3815. fmtprint(fmt, "\t%s=", "offset");
  3816. fmtprint(fmt, "%llud", x->offset);
  3817. fmtprint(fmt, "\n");
  3818. fmtprint(fmt, "\t%s=", "count");
  3819. fmtprint(fmt, "%ud", x->count);
  3820. fmtprint(fmt, "\n");
  3821. }
  3822. uint
  3823. nfs3TCommitSize(Nfs3TCommit *x)
  3824. {
  3825. uint a;
  3826. USED(x);
  3827. a = 0 + nfs3HandleSize(&x->handle) + 8 + 4;
  3828. return a;
  3829. }
  3830. int
  3831. nfs3TCommitPack(uchar *a, uchar *ea, uchar **pa, Nfs3TCommit *x)
  3832. {
  3833. if(nfs3HandlePack(a, ea, &a, &x->handle) < 0) goto Err;
  3834. if(sunUint64Pack(a, ea, &a, &x->offset) < 0) goto Err;
  3835. if(sunUint32Pack(a, ea, &a, &x->count) < 0) goto Err;
  3836. *pa = a;
  3837. return 0;
  3838. Err:
  3839. *pa = ea;
  3840. return -1;
  3841. }
  3842. int
  3843. nfs3TCommitUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3TCommit *x)
  3844. {
  3845. if(nfs3HandleUnpack(a, ea, &a, &x->handle) < 0) goto Err;
  3846. if(sunUint64Unpack(a, ea, &a, &x->offset) < 0) goto Err;
  3847. if(sunUint32Unpack(a, ea, &a, &x->count) < 0) goto Err;
  3848. *pa = a;
  3849. return 0;
  3850. Err:
  3851. *pa = ea;
  3852. return -1;
  3853. }
  3854. void
  3855. nfs3RCommitPrint(Fmt *fmt, Nfs3RCommit *x)
  3856. {
  3857. fmtprint(fmt, "%s\n", "Nfs3RCommit");
  3858. fmtprint(fmt, "\t%s=", "status");
  3859. fmtprint(fmt, "%s", nfs3StatusStr(x->status));
  3860. fmtprint(fmt, "\n");
  3861. fmtprint(fmt, "\t%s=", "wcc");
  3862. nfs3WccPrint(fmt, &x->wcc);
  3863. fmtprint(fmt, "\n");
  3864. switch(x->status){
  3865. case Nfs3Ok:
  3866. fmtprint(fmt, "\t%s=", "verf");
  3867. fmtprint(fmt, "%.*H", Nfs3WriteVerfSize, x->verf);
  3868. fmtprint(fmt, "\n");
  3869. break;
  3870. }
  3871. }
  3872. uint
  3873. nfs3RCommitSize(Nfs3RCommit *x)
  3874. {
  3875. uint a;
  3876. USED(x);
  3877. a = 0 + 4 + nfs3WccSize(&x->wcc);
  3878. switch(x->status){
  3879. case Nfs3Ok:
  3880. a = a + Nfs3WriteVerfSize;
  3881. break;
  3882. }
  3883. return a;
  3884. }
  3885. int
  3886. nfs3RCommitPack(uchar *a, uchar *ea, uchar **pa, Nfs3RCommit *x)
  3887. {
  3888. int i;
  3889. if(i=x->status, sunEnumPack(a, ea, &a, &i) < 0) goto Err;
  3890. if(nfs3WccPack(a, ea, &a, &x->wcc) < 0) goto Err;
  3891. switch(x->status){
  3892. case Nfs3Ok:
  3893. if(sunFixedOpaquePack(a, ea, &a, x->verf, Nfs3WriteVerfSize) < 0) goto Err;
  3894. break;
  3895. }
  3896. *pa = a;
  3897. return 0;
  3898. Err:
  3899. *pa = ea;
  3900. return -1;
  3901. }
  3902. int
  3903. nfs3RCommitUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3RCommit *x)
  3904. {
  3905. int i;
  3906. if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->status = i;
  3907. if(nfs3WccUnpack(a, ea, &a, &x->wcc) < 0) goto Err;
  3908. switch(x->status){
  3909. case Nfs3Ok:
  3910. if(sunFixedOpaqueUnpack(a, ea, &a, x->verf, Nfs3WriteVerfSize) < 0) goto Err;
  3911. break;
  3912. }
  3913. *pa = a;
  3914. return 0;
  3915. Err:
  3916. *pa = ea;
  3917. return -1;
  3918. }
  3919. typedef int (*P)(uchar*, uchar*, uchar**, SunCall*);
  3920. typedef void (*F)(Fmt*, SunCall*);
  3921. typedef uint (*S)(SunCall*);
  3922. static SunProc proc[] = {
  3923. (P)nfs3TNullPack, (P)nfs3TNullUnpack, (S)nfs3TNullSize, (F)nfs3TNullPrint, sizeof(Nfs3TNull),
  3924. (P)nfs3RNullPack, (P)nfs3RNullUnpack, (S)nfs3RNullSize, (F)nfs3RNullPrint, sizeof(Nfs3RNull),
  3925. (P)nfs3TGetattrPack, (P)nfs3TGetattrUnpack, (S)nfs3TGetattrSize, (F)nfs3TGetattrPrint, sizeof(Nfs3TGetattr),
  3926. (P)nfs3RGetattrPack, (P)nfs3RGetattrUnpack, (S)nfs3RGetattrSize, (F)nfs3RGetattrPrint, sizeof(Nfs3RGetattr),
  3927. (P)nfs3TSetattrPack, (P)nfs3TSetattrUnpack, (S)nfs3TSetattrSize, (F)nfs3TSetattrPrint, sizeof(Nfs3TSetattr),
  3928. (P)nfs3RSetattrPack, (P)nfs3RSetattrUnpack, (S)nfs3RSetattrSize, (F)nfs3RSetattrPrint, sizeof(Nfs3RSetattr),
  3929. (P)nfs3TLookupPack, (P)nfs3TLookupUnpack, (S)nfs3TLookupSize, (F)nfs3TLookupPrint, sizeof(Nfs3TLookup),
  3930. (P)nfs3RLookupPack, (P)nfs3RLookupUnpack, (S)nfs3RLookupSize, (F)nfs3RLookupPrint, sizeof(Nfs3RLookup),
  3931. (P)nfs3TAccessPack, (P)nfs3TAccessUnpack, (S)nfs3TAccessSize, (F)nfs3TAccessPrint, sizeof(Nfs3TAccess),
  3932. (P)nfs3RAccessPack, (P)nfs3RAccessUnpack, (S)nfs3RAccessSize, (F)nfs3RAccessPrint, sizeof(Nfs3RAccess),
  3933. (P)nfs3TReadlinkPack, (P)nfs3TReadlinkUnpack, (S)nfs3TReadlinkSize, (F)nfs3TReadlinkPrint, sizeof(Nfs3TReadlink),
  3934. (P)nfs3RReadlinkPack, (P)nfs3RReadlinkUnpack, (S)nfs3RReadlinkSize, (F)nfs3RReadlinkPrint, sizeof(Nfs3RReadlink),
  3935. (P)nfs3TReadPack, (P)nfs3TReadUnpack, (S)nfs3TReadSize, (F)nfs3TReadPrint, sizeof(Nfs3TRead),
  3936. (P)nfs3RReadPack, (P)nfs3RReadUnpack, (S)nfs3RReadSize, (F)nfs3RReadPrint, sizeof(Nfs3RRead),
  3937. (P)nfs3TWritePack, (P)nfs3TWriteUnpack, (S)nfs3TWriteSize, (F)nfs3TWritePrint, sizeof(Nfs3TWrite),
  3938. (P)nfs3RWritePack, (P)nfs3RWriteUnpack, (S)nfs3RWriteSize, (F)nfs3RWritePrint, sizeof(Nfs3RWrite),
  3939. (P)nfs3TCreatePack, (P)nfs3TCreateUnpack, (S)nfs3TCreateSize, (F)nfs3TCreatePrint, sizeof(Nfs3TCreate),
  3940. (P)nfs3RCreatePack, (P)nfs3RCreateUnpack, (S)nfs3RCreateSize, (F)nfs3RCreatePrint, sizeof(Nfs3RCreate),
  3941. (P)nfs3TMkdirPack, (P)nfs3TMkdirUnpack, (S)nfs3TMkdirSize, (F)nfs3TMkdirPrint, sizeof(Nfs3TMkdir),
  3942. (P)nfs3RMkdirPack, (P)nfs3RMkdirUnpack, (S)nfs3RMkdirSize, (F)nfs3RMkdirPrint, sizeof(Nfs3RMkdir),
  3943. (P)nfs3TSymlinkPack, (P)nfs3TSymlinkUnpack, (S)nfs3TSymlinkSize, (F)nfs3TSymlinkPrint, sizeof(Nfs3TSymlink),
  3944. (P)nfs3RSymlinkPack, (P)nfs3RSymlinkUnpack, (S)nfs3RSymlinkSize, (F)nfs3RSymlinkPrint, sizeof(Nfs3RSymlink),
  3945. (P)nfs3TMknodPack, (P)nfs3TMknodUnpack, (S)nfs3TMknodSize, (F)nfs3TMknodPrint, sizeof(Nfs3TMknod),
  3946. (P)nfs3RMknodPack, (P)nfs3RMknodUnpack, (S)nfs3RMknodSize, (F)nfs3RMknodPrint, sizeof(Nfs3RMknod),
  3947. (P)nfs3TRemovePack, (P)nfs3TRemoveUnpack, (S)nfs3TRemoveSize, (F)nfs3TRemovePrint, sizeof(Nfs3TRemove),
  3948. (P)nfs3RRemovePack, (P)nfs3RRemoveUnpack, (S)nfs3RRemoveSize, (F)nfs3RRemovePrint, sizeof(Nfs3RRemove),
  3949. (P)nfs3TRmdirPack, (P)nfs3TRmdirUnpack, (S)nfs3TRmdirSize, (F)nfs3TRmdirPrint, sizeof(Nfs3TRmdir),
  3950. (P)nfs3RRmdirPack, (P)nfs3RRmdirUnpack, (S)nfs3RRmdirSize, (F)nfs3RRmdirPrint, sizeof(Nfs3RRmdir),
  3951. (P)nfs3TRenamePack, (P)nfs3TRenameUnpack, (S)nfs3TRenameSize, (F)nfs3TRenamePrint, sizeof(Nfs3TRename),
  3952. (P)nfs3RRenamePack, (P)nfs3RRenameUnpack, (S)nfs3RRenameSize, (F)nfs3RRenamePrint, sizeof(Nfs3RRename),
  3953. (P)nfs3TLinkPack, (P)nfs3TLinkUnpack, (S)nfs3TLinkSize, (F)nfs3TLinkPrint, sizeof(Nfs3TLink),
  3954. (P)nfs3RLinkPack, (P)nfs3RLinkUnpack, (S)nfs3RLinkSize, (F)nfs3RLinkPrint, sizeof(Nfs3RLink),
  3955. (P)nfs3TReadDirPack, (P)nfs3TReadDirUnpack, (S)nfs3TReadDirSize, (F)nfs3TReadDirPrint, sizeof(Nfs3TReadDir),
  3956. (P)nfs3RReadDirPack, (P)nfs3RReadDirUnpack, (S)nfs3RReadDirSize, (F)nfs3RReadDirPrint, sizeof(Nfs3RReadDir),
  3957. (P)nfs3TReadDirPlusPack, (P)nfs3TReadDirPlusUnpack, (S)nfs3TReadDirPlusSize, (F)nfs3TReadDirPlusPrint, sizeof(Nfs3TReadDirPlus),
  3958. (P)nfs3RReadDirPlusPack, (P)nfs3RReadDirPlusUnpack, (S)nfs3RReadDirPlusSize, (F)nfs3RReadDirPlusPrint, sizeof(Nfs3RReadDirPlus),
  3959. (P)nfs3TFsStatPack, (P)nfs3TFsStatUnpack, (S)nfs3TFsStatSize, (F)nfs3TFsStatPrint, sizeof(Nfs3TFsStat),
  3960. (P)nfs3RFsStatPack, (P)nfs3RFsStatUnpack, (S)nfs3RFsStatSize, (F)nfs3RFsStatPrint, sizeof(Nfs3RFsStat),
  3961. (P)nfs3TFsInfoPack, (P)nfs3TFsInfoUnpack, (S)nfs3TFsInfoSize, (F)nfs3TFsInfoPrint, sizeof(Nfs3TFsInfo),
  3962. (P)nfs3RFsInfoPack, (P)nfs3RFsInfoUnpack, (S)nfs3RFsInfoSize, (F)nfs3RFsInfoPrint, sizeof(Nfs3RFsInfo),
  3963. (P)nfs3TPathconfPack, (P)nfs3TPathconfUnpack, (S)nfs3TPathconfSize, (F)nfs3TPathconfPrint, sizeof(Nfs3TPathconf),
  3964. (P)nfs3RPathconfPack, (P)nfs3RPathconfUnpack, (S)nfs3RPathconfSize, (F)nfs3RPathconfPrint, sizeof(Nfs3RPathconf),
  3965. (P)nfs3TCommitPack, (P)nfs3TCommitUnpack, (S)nfs3TCommitSize, (F)nfs3TCommitPrint, sizeof(Nfs3TCommit),
  3966. (P)nfs3RCommitPack, (P)nfs3RCommitUnpack, (S)nfs3RCommitSize, (F)nfs3RCommitPrint, sizeof(Nfs3RCommit)
  3967. };
  3968. SunProg nfs3Prog =
  3969. {
  3970. Nfs3Program,
  3971. Nfs3Version,
  3972. proc,
  3973. nelem(proc),
  3974. };