summaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4xdr_gen.c
blob: d77835033a8c242ebe39b658d6f0fec854765216 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
// SPDX-License-Identifier: GPL-2.0
// Generated by xdrgen. Manual edits will be lost.
// XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x
// XDR specification modification time: Tue Jun 30 11:57:21 2026

#include <linux/sunrpc/svc.h>

#include "nfs4xdr_gen.h"

static bool __maybe_unused
xdrgen_decode_int32_t(struct xdr_stream *xdr, int32_t *ptr)
{
	return xdrgen_decode_int(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_uint32_t(struct xdr_stream *xdr, uint32_t *ptr)
{
	return xdrgen_decode_unsigned_int(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_int64_t(struct xdr_stream *xdr, int64_t *ptr)
{
	return xdrgen_decode_hyper(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_uint64_t(struct xdr_stream *xdr, uint64_t *ptr)
{
	return xdrgen_decode_unsigned_hyper(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_nfsstat4(struct xdr_stream *xdr, nfsstat4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case NFS4_OK:
	case NFS4ERR_PERM:
	case NFS4ERR_NOENT:
	case NFS4ERR_IO:
	case NFS4ERR_NXIO:
	case NFS4ERR_ACCESS:
	case NFS4ERR_EXIST:
	case NFS4ERR_XDEV:
	case NFS4ERR_NOTDIR:
	case NFS4ERR_ISDIR:
	case NFS4ERR_INVAL:
	case NFS4ERR_FBIG:
	case NFS4ERR_NOSPC:
	case NFS4ERR_ROFS:
	case NFS4ERR_MLINK:
	case NFS4ERR_NAMETOOLONG:
	case NFS4ERR_NOTEMPTY:
	case NFS4ERR_DQUOT:
	case NFS4ERR_STALE:
	case NFS4ERR_BADHANDLE:
	case NFS4ERR_BAD_COOKIE:
	case NFS4ERR_NOTSUPP:
	case NFS4ERR_TOOSMALL:
	case NFS4ERR_SERVERFAULT:
	case NFS4ERR_BADTYPE:
	case NFS4ERR_DELAY:
	case NFS4ERR_SAME:
	case NFS4ERR_DENIED:
	case NFS4ERR_EXPIRED:
	case NFS4ERR_LOCKED:
	case NFS4ERR_GRACE:
	case NFS4ERR_FHEXPIRED:
	case NFS4ERR_SHARE_DENIED:
	case NFS4ERR_WRONGSEC:
	case NFS4ERR_CLID_INUSE:
	case NFS4ERR_RESOURCE:
	case NFS4ERR_MOVED:
	case NFS4ERR_NOFILEHANDLE:
	case NFS4ERR_MINOR_VERS_MISMATCH:
	case NFS4ERR_STALE_CLIENTID:
	case NFS4ERR_STALE_STATEID:
	case NFS4ERR_OLD_STATEID:
	case NFS4ERR_BAD_STATEID:
	case NFS4ERR_BAD_SEQID:
	case NFS4ERR_NOT_SAME:
	case NFS4ERR_LOCK_RANGE:
	case NFS4ERR_SYMLINK:
	case NFS4ERR_RESTOREFH:
	case NFS4ERR_LEASE_MOVED:
	case NFS4ERR_ATTRNOTSUPP:
	case NFS4ERR_NO_GRACE:
	case NFS4ERR_RECLAIM_BAD:
	case NFS4ERR_RECLAIM_CONFLICT:
	case NFS4ERR_BADXDR:
	case NFS4ERR_LOCKS_HELD:
	case NFS4ERR_OPENMODE:
	case NFS4ERR_BADOWNER:
	case NFS4ERR_BADCHAR:
	case NFS4ERR_BADNAME:
	case NFS4ERR_BAD_RANGE:
	case NFS4ERR_LOCK_NOTSUPP:
	case NFS4ERR_OP_ILLEGAL:
	case NFS4ERR_DEADLOCK:
	case NFS4ERR_FILE_OPEN:
	case NFS4ERR_ADMIN_REVOKED:
	case NFS4ERR_CB_PATH_DOWN:
	case NFS4ERR_BADIOMODE:
	case NFS4ERR_BADLAYOUT:
	case NFS4ERR_BAD_SESSION_DIGEST:
	case NFS4ERR_BADSESSION:
	case NFS4ERR_BADSLOT:
	case NFS4ERR_COMPLETE_ALREADY:
	case NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
	case NFS4ERR_DELEG_ALREADY_WANTED:
	case NFS4ERR_BACK_CHAN_BUSY:
	case NFS4ERR_LAYOUTTRYLATER:
	case NFS4ERR_LAYOUTUNAVAILABLE:
	case NFS4ERR_NOMATCHING_LAYOUT:
	case NFS4ERR_RECALLCONFLICT:
	case NFS4ERR_UNKNOWN_LAYOUTTYPE:
	case NFS4ERR_SEQ_MISORDERED:
	case NFS4ERR_SEQUENCE_POS:
	case NFS4ERR_REQ_TOO_BIG:
	case NFS4ERR_REP_TOO_BIG:
	case NFS4ERR_REP_TOO_BIG_TO_CACHE:
	case NFS4ERR_RETRY_UNCACHED_REP:
	case NFS4ERR_UNSAFE_COMPOUND:
	case NFS4ERR_TOO_MANY_OPS:
	case NFS4ERR_OP_NOT_IN_SESSION:
	case NFS4ERR_HASH_ALG_UNSUPP:
	case NFS4ERR_CLIENTID_BUSY:
	case NFS4ERR_PNFS_IO_HOLE:
	case NFS4ERR_SEQ_FALSE_RETRY:
	case NFS4ERR_BAD_HIGH_SLOT:
	case NFS4ERR_DEADSESSION:
	case NFS4ERR_ENCR_ALG_UNSUPP:
	case NFS4ERR_PNFS_NO_LAYOUT:
	case NFS4ERR_NOT_ONLY_OP:
	case NFS4ERR_WRONG_CRED:
	case NFS4ERR_WRONG_TYPE:
	case NFS4ERR_DIRDELEG_UNAVAIL:
	case NFS4ERR_REJECT_DELEG:
	case NFS4ERR_RETURNCONFLICT:
	case NFS4ERR_DELEG_REVOKED:
	case NFS4ERR_PARTNER_NOTSUPP:
	case NFS4ERR_PARTNER_NO_AUTH:
	case NFS4ERR_UNION_NOTSUPP:
	case NFS4ERR_OFFLOAD_DENIED:
	case NFS4ERR_WRONG_LFS:
	case NFS4ERR_BADLABEL:
	case NFS4ERR_OFFLOAD_NO_REQS:
	case NFS4ERR_NOXATTR:
	case NFS4ERR_XATTR2BIG:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

static bool __maybe_unused
xdrgen_decode_attrlist4(struct xdr_stream *xdr, attrlist4 *ptr)
{
	return xdrgen_decode_opaque(xdr, ptr, 0);
}

static bool __maybe_unused
xdrgen_decode_bitmap4(struct xdr_stream *xdr, bitmap4 *ptr)
{
	if (xdr_stream_decode_u32(xdr, &ptr->count) < 0)
		return false;
	for (u32 i = 0; i < ptr->count; i++)
		if (!xdrgen_decode_uint32_t(xdr, &ptr->element[i]))
			return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_verifier4(struct xdr_stream *xdr, verifier4 *ptr)
{
	return xdr_stream_decode_opaque_fixed(xdr, ptr, NFS4_VERIFIER_SIZE) == 0;
}

static bool __maybe_unused
xdrgen_decode_nfs_cookie4(struct xdr_stream *xdr, nfs_cookie4 *ptr)
{
	return xdrgen_decode_uint64_t(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_nfs_fh4(struct xdr_stream *xdr, nfs_fh4 *ptr)
{
	return xdrgen_decode_opaque(xdr, ptr, NFS4_FHSIZE);
}

static bool __maybe_unused
xdrgen_decode_utf8string(struct xdr_stream *xdr, utf8string *ptr)
{
	return xdrgen_decode_opaque(xdr, ptr, 0);
}

static bool __maybe_unused
xdrgen_decode_utf8str_cis(struct xdr_stream *xdr, utf8str_cis *ptr)
{
	return xdrgen_decode_utf8string(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_utf8str_cs(struct xdr_stream *xdr, utf8str_cs *ptr)
{
	return xdrgen_decode_utf8string(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_utf8str_mixed(struct xdr_stream *xdr, utf8str_mixed *ptr)
{
	return xdrgen_decode_utf8string(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_component4(struct xdr_stream *xdr, component4 *ptr)
{
	return xdrgen_decode_utf8str_cs(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_linktext4(struct xdr_stream *xdr, linktext4 *ptr)
{
	return xdrgen_decode_utf8str_cs(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_pathname4(struct xdr_stream *xdr, pathname4 *ptr)
{
	if (xdr_stream_decode_u32(xdr, &ptr->count) < 0)
		return false;
	for (u32 i = 0; i < ptr->count; i++)
		if (!xdrgen_decode_component4(xdr, &ptr->element[i]))
			return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_nfstime4(struct xdr_stream *xdr, struct nfstime4 *ptr)
{
	if (!xdrgen_decode_int64_t(xdr, &ptr->seconds))
		return false;
	if (!xdrgen_decode_uint32_t(xdr, &ptr->nseconds))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_fattr4(struct xdr_stream *xdr, struct fattr4 *ptr)
{
	if (!xdrgen_decode_bitmap4(xdr, &ptr->attrmask))
		return false;
	if (!xdrgen_decode_attrlist4(xdr, &ptr->attr_vals))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_stateid4(struct xdr_stream *xdr, struct stateid4 *ptr)
{
	if (!xdrgen_decode_uint32_t(xdr, &ptr->seqid))
		return false;
	if (xdr_stream_decode_opaque_fixed(xdr, ptr->other, 12) < 0)
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_fattr4_offline(struct xdr_stream *xdr, fattr4_offline *ptr)
{
	return xdrgen_decode_bool(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_open_arguments4(struct xdr_stream *xdr, struct open_arguments4 *ptr)
{
	if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_share_access))
		return false;
	if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_share_deny))
		return false;
	if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_share_access_want))
		return false;
	if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_open_claim))
		return false;
	if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_create_mode))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_open_args_share_access4(struct xdr_stream *xdr, open_args_share_access4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case OPEN_ARGS_SHARE_ACCESS_READ:
	case OPEN_ARGS_SHARE_ACCESS_WRITE:
	case OPEN_ARGS_SHARE_ACCESS_BOTH:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

static bool __maybe_unused
xdrgen_decode_open_args_share_deny4(struct xdr_stream *xdr, open_args_share_deny4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case OPEN_ARGS_SHARE_DENY_NONE:
	case OPEN_ARGS_SHARE_DENY_READ:
	case OPEN_ARGS_SHARE_DENY_WRITE:
	case OPEN_ARGS_SHARE_DENY_BOTH:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

static bool __maybe_unused
xdrgen_decode_open_args_share_access_want4(struct xdr_stream *xdr, open_args_share_access_want4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG:
	case OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG:
	case OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL:
	case OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL:
	case OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED:
	case OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS:
	case OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

static bool __maybe_unused
xdrgen_decode_open_args_open_claim4(struct xdr_stream *xdr, open_args_open_claim4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case OPEN_ARGS_OPEN_CLAIM_NULL:
	case OPEN_ARGS_OPEN_CLAIM_PREVIOUS:
	case OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR:
	case OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV:
	case OPEN_ARGS_OPEN_CLAIM_FH:
	case OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH:
	case OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

static bool __maybe_unused
xdrgen_decode_open_args_createmode4(struct xdr_stream *xdr, open_args_createmode4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case OPEN_ARGS_CREATEMODE_UNCHECKED4:
	case OPEN_ARGS_CREATE_MODE_GUARDED:
	case OPEN_ARGS_CREATEMODE_EXCLUSIVE4:
	case OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

bool
xdrgen_decode_fattr4_open_arguments(struct xdr_stream *xdr, fattr4_open_arguments *ptr)
{
	return xdrgen_decode_open_arguments4(xdr, ptr);
}

/*
 * Determine what OPEN supports.
 */

bool
xdrgen_decode_fattr4_time_deleg_access(struct xdr_stream *xdr, fattr4_time_deleg_access *ptr)
{
	return xdrgen_decode_nfstime4(xdr, ptr);
}

bool
xdrgen_decode_fattr4_time_deleg_modify(struct xdr_stream *xdr, fattr4_time_deleg_modify *ptr)
{
	return xdrgen_decode_nfstime4(xdr, ptr);
}

/*
 * New RECOMMENDED Attribute for
 * delegation caching of times
 */

static bool __maybe_unused
xdrgen_decode_open_delegation_type4(struct xdr_stream *xdr, open_delegation_type4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case OPEN_DELEGATE_NONE:
	case OPEN_DELEGATE_READ:
	case OPEN_DELEGATE_WRITE:
	case OPEN_DELEGATE_NONE_EXT:
	case OPEN_DELEGATE_READ_ATTRS_DELEG:
	case OPEN_DELEGATE_WRITE_ATTRS_DELEG:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

bool
xdrgen_decode_aclmodel4(struct xdr_stream *xdr, aclmodel4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case ACL_MODEL_NFS4:
	case ACL_MODEL_POSIX_DRAFT:
	case ACL_MODEL_NONE:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

bool
xdrgen_decode_aclscope4(struct xdr_stream *xdr, aclscope4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case ACL_SCOPE_FILE_OBJECT:
	case ACL_SCOPE_FILE_SYSTEM:
	case ACL_SCOPE_SERVER:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

bool
xdrgen_decode_posixacetag4(struct xdr_stream *xdr, posixacetag4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case POSIXACE4_TAG_USER_OBJ:
	case POSIXACE4_TAG_USER:
	case POSIXACE4_TAG_GROUP_OBJ:
	case POSIXACE4_TAG_GROUP:
	case POSIXACE4_TAG_MASK:
	case POSIXACE4_TAG_OTHER:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

bool
xdrgen_decode_posixaceperm4(struct xdr_stream *xdr, posixaceperm4 *ptr)
{
	return xdrgen_decode_uint32_t(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_posixace4(struct xdr_stream *xdr, struct posixace4 *ptr)
{
	if (!xdrgen_decode_posixacetag4(xdr, &ptr->tag))
		return false;
	if (!xdrgen_decode_posixaceperm4(xdr, &ptr->perm))
		return false;
	if (!xdrgen_decode_utf8str_mixed(xdr, &ptr->who))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_fattr4_acl_trueform(struct xdr_stream *xdr, fattr4_acl_trueform *ptr)
{
	return xdrgen_decode_aclmodel4(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_fattr4_acl_trueform_scope(struct xdr_stream *xdr, fattr4_acl_trueform_scope *ptr)
{
	return xdrgen_decode_aclscope4(xdr, ptr);
}

static bool __maybe_unused
xdrgen_decode_fattr4_posix_default_acl(struct xdr_stream *xdr, fattr4_posix_default_acl *ptr)
{
	if (xdr_stream_decode_u32(xdr, &ptr->count) < 0)
		return false;
	for (u32 i = 0; i < ptr->count; i++)
		if (!xdrgen_decode_posixace4(xdr, &ptr->element[i]))
			return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_fattr4_posix_access_acl(struct xdr_stream *xdr, fattr4_posix_access_acl *ptr)
{
	if (xdr_stream_decode_u32(xdr, &ptr->count) < 0)
		return false;
	for (u32 i = 0; i < ptr->count; i++)
		if (!xdrgen_decode_posixace4(xdr, &ptr->element[i]))
			return false;
	return true;
}

/*
 * New for POSIX ACL extension
 */

static bool __maybe_unused
xdrgen_decode_notify_type4(struct xdr_stream *xdr, notify_type4 *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case NOTIFY4_CHANGE_CHILD_ATTRS:
	case NOTIFY4_CHANGE_DIR_ATTRS:
	case NOTIFY4_REMOVE_ENTRY:
	case NOTIFY4_ADD_ENTRY:
	case NOTIFY4_RENAME_ENTRY:
	case NOTIFY4_CHANGE_COOKIE_VERIFIER:
	case NOTIFY4_GFLAG_EXTEND:
	case NOTIFY4_AUFLAG_VALID:
	case NOTIFY4_AUFLAG_USER:
	case NOTIFY4_AUFLAG_GROUP:
	case NOTIFY4_AUFLAG_OTHER:
	case NOTIFY4_CHANGE_AUTH:
	case NOTIFY4_CFLAG_ORDER:
	case NOTIFY4_AUFLAG_GANOW:
	case NOTIFY4_AUFLAG_GALATER:
	case NOTIFY4_CHANGE_GA:
	case NOTIFY4_CHANGE_AMASK:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

static bool __maybe_unused
xdrgen_decode_notify_entry4(struct xdr_stream *xdr, struct notify_entry4 *ptr)
{
	if (!xdrgen_decode_component4(xdr, &ptr->ne_file))
		return false;
	if (!xdrgen_decode_fattr4(xdr, &ptr->ne_attrs))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_prev_entry4(struct xdr_stream *xdr, struct prev_entry4 *ptr)
{
	if (!xdrgen_decode_notify_entry4(xdr, &ptr->pe_prev_entry))
		return false;
	if (!xdrgen_decode_nfs_cookie4(xdr, &ptr->pe_prev_entry_cookie))
		return false;
	return true;
}

bool
xdrgen_decode_notify_remove4(struct xdr_stream *xdr, struct notify_remove4 *ptr)
{
	if (!xdrgen_decode_notify_entry4(xdr, &ptr->nrm_old_entry))
		return false;
	if (!xdrgen_decode_nfs_cookie4(xdr, &ptr->nrm_old_entry_cookie))
		return false;
	return true;
}

bool
xdrgen_decode_notify_add4(struct xdr_stream *xdr, struct notify_add4 *ptr)
{
	if (xdr_stream_decode_u32(xdr, &ptr->nad_old_entry.count) < 0)
		return false;
	if (ptr->nad_old_entry.count > 1)
		return false;
	for (u32 i = 0; i < ptr->nad_old_entry.count; i++)
		if (!xdrgen_decode_notify_remove4(xdr, &ptr->nad_old_entry.element[i]))
			return false;
	if (!xdrgen_decode_notify_entry4(xdr, &ptr->nad_new_entry))
		return false;
	if (xdr_stream_decode_u32(xdr, &ptr->nad_new_entry_cookie.count) < 0)
		return false;
	if (ptr->nad_new_entry_cookie.count > 1)
		return false;
	for (u32 i = 0; i < ptr->nad_new_entry_cookie.count; i++)
		if (!xdrgen_decode_nfs_cookie4(xdr, &ptr->nad_new_entry_cookie.element[i]))
			return false;
	if (xdr_stream_decode_u32(xdr, &ptr->nad_prev_entry.count) < 0)
		return false;
	if (ptr->nad_prev_entry.count > 1)
		return false;
	for (u32 i = 0; i < ptr->nad_prev_entry.count; i++)
		if (!xdrgen_decode_prev_entry4(xdr, &ptr->nad_prev_entry.element[i]))
			return false;
	if (!xdrgen_decode_bool(xdr, &ptr->nad_last_entry))
		return false;
	return true;
}

bool
xdrgen_decode_notify_attr4(struct xdr_stream *xdr, struct notify_attr4 *ptr)
{
	if (!xdrgen_decode_notify_entry4(xdr, &ptr->na_changed_entry))
		return false;
	return true;
}

bool
xdrgen_decode_notify_rename4(struct xdr_stream *xdr, struct notify_rename4 *ptr)
{
	if (!xdrgen_decode_notify_remove4(xdr, &ptr->nrn_old_entry))
		return false;
	if (!xdrgen_decode_notify_add4(xdr, &ptr->nrn_new_entry))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_notify_verifier4(struct xdr_stream *xdr, struct notify_verifier4 *ptr)
{
	if (!xdrgen_decode_verifier4(xdr, &ptr->nv_old_cookieverf))
		return false;
	if (!xdrgen_decode_verifier4(xdr, &ptr->nv_new_cookieverf))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_notifylist4(struct xdr_stream *xdr, notifylist4 *ptr)
{
	return xdrgen_decode_opaque(xdr, ptr, 0);
}

static bool __maybe_unused
xdrgen_decode_notify4(struct xdr_stream *xdr, struct notify4 *ptr)
{
	if (!xdrgen_decode_bitmap4(xdr, &ptr->notify_mask))
		return false;
	if (!xdrgen_decode_notifylist4(xdr, &ptr->notify_vals))
		return false;
	return true;
}

bool
xdrgen_decode_CB_NOTIFY4args(struct xdr_stream *xdr, struct CB_NOTIFY4args *ptr)
{
	if (!xdrgen_decode_stateid4(xdr, &ptr->cna_stateid))
		return false;
	if (!xdrgen_decode_nfs_fh4(xdr, &ptr->cna_fh))
		return false;
	if (xdr_stream_decode_u32(xdr, &ptr->cna_changes.count) < 0)
		return false;
	for (u32 i = 0; i < ptr->cna_changes.count; i++)
		if (!xdrgen_decode_notify4(xdr, &ptr->cna_changes.element[i]))
			return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_CB_NOTIFY4res(struct xdr_stream *xdr, struct CB_NOTIFY4res *ptr)
{
	if (!xdrgen_decode_nfsstat4(xdr, &ptr->cnr_status))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_int32_t(struct xdr_stream *xdr, const int32_t value)
{
	return xdrgen_encode_int(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_uint32_t(struct xdr_stream *xdr, const uint32_t value)
{
	return xdrgen_encode_unsigned_int(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_int64_t(struct xdr_stream *xdr, const int64_t value)
{
	return xdrgen_encode_hyper(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_uint64_t(struct xdr_stream *xdr, const uint64_t value)
{
	return xdrgen_encode_unsigned_hyper(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_nfsstat4(struct xdr_stream *xdr, nfsstat4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

static bool __maybe_unused
xdrgen_encode_attrlist4(struct xdr_stream *xdr, const attrlist4 value)
{
	return xdr_stream_encode_opaque(xdr, value.data, value.len) >= 0;
}

static bool __maybe_unused
xdrgen_encode_bitmap4(struct xdr_stream *xdr, const bitmap4 value)
{
	if (xdr_stream_encode_u32(xdr, value.count) != XDR_UNIT)
		return false;
	for (u32 i = 0; i < value.count; i++)
		if (!xdrgen_encode_uint32_t(xdr, value.element[i]))
			return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_verifier4(struct xdr_stream *xdr, const verifier4 value)
{
	return xdr_stream_encode_opaque_fixed(xdr, value, NFS4_VERIFIER_SIZE) >= 0;
}

static bool __maybe_unused
xdrgen_encode_nfs_cookie4(struct xdr_stream *xdr, const nfs_cookie4 value)
{
	return xdrgen_encode_uint64_t(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_nfs_fh4(struct xdr_stream *xdr, const nfs_fh4 value)
{
	return xdr_stream_encode_opaque(xdr, value.data, value.len) >= 0;
}

static bool __maybe_unused
xdrgen_encode_utf8string(struct xdr_stream *xdr, const utf8string value)
{
	return xdr_stream_encode_opaque(xdr, value.data, value.len) >= 0;
}

static bool __maybe_unused
xdrgen_encode_utf8str_cis(struct xdr_stream *xdr, const utf8str_cis value)
{
	return xdrgen_encode_utf8string(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_utf8str_cs(struct xdr_stream *xdr, const utf8str_cs value)
{
	return xdrgen_encode_utf8string(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_utf8str_mixed(struct xdr_stream *xdr, const utf8str_mixed value)
{
	return xdrgen_encode_utf8string(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_component4(struct xdr_stream *xdr, const component4 value)
{
	return xdrgen_encode_utf8str_cs(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_linktext4(struct xdr_stream *xdr, const linktext4 value)
{
	return xdrgen_encode_utf8str_cs(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_pathname4(struct xdr_stream *xdr, const pathname4 value)
{
	if (xdr_stream_encode_u32(xdr, value.count) != XDR_UNIT)
		return false;
	for (u32 i = 0; i < value.count; i++)
		if (!xdrgen_encode_component4(xdr, value.element[i]))
			return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_nfstime4(struct xdr_stream *xdr, const struct nfstime4 *value)
{
	if (!xdrgen_encode_int64_t(xdr, value->seconds))
		return false;
	if (!xdrgen_encode_uint32_t(xdr, value->nseconds))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_fattr4(struct xdr_stream *xdr, const struct fattr4 *value)
{
	if (!xdrgen_encode_bitmap4(xdr, value->attrmask))
		return false;
	if (!xdrgen_encode_attrlist4(xdr, value->attr_vals))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_stateid4(struct xdr_stream *xdr, const struct stateid4 *value)
{
	if (!xdrgen_encode_uint32_t(xdr, value->seqid))
		return false;
	if (xdr_stream_encode_opaque_fixed(xdr, value->other, 12) < 0)
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_fattr4_offline(struct xdr_stream *xdr, const fattr4_offline value)
{
	return xdrgen_encode_bool(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_open_arguments4(struct xdr_stream *xdr, const struct open_arguments4 *value)
{
	if (!xdrgen_encode_bitmap4(xdr, value->oa_share_access))
		return false;
	if (!xdrgen_encode_bitmap4(xdr, value->oa_share_deny))
		return false;
	if (!xdrgen_encode_bitmap4(xdr, value->oa_share_access_want))
		return false;
	if (!xdrgen_encode_bitmap4(xdr, value->oa_open_claim))
		return false;
	if (!xdrgen_encode_bitmap4(xdr, value->oa_create_mode))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_open_args_share_access4(struct xdr_stream *xdr, open_args_share_access4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

static bool __maybe_unused
xdrgen_encode_open_args_share_deny4(struct xdr_stream *xdr, open_args_share_deny4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

static bool __maybe_unused
xdrgen_encode_open_args_share_access_want4(struct xdr_stream *xdr, open_args_share_access_want4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

static bool __maybe_unused
xdrgen_encode_open_args_open_claim4(struct xdr_stream *xdr, open_args_open_claim4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

static bool __maybe_unused
xdrgen_encode_open_args_createmode4(struct xdr_stream *xdr, open_args_createmode4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

bool
xdrgen_encode_fattr4_open_arguments(struct xdr_stream *xdr, const fattr4_open_arguments *value)
{
	return xdrgen_encode_open_arguments4(xdr, value);
}

bool
xdrgen_encode_fattr4_time_deleg_access(struct xdr_stream *xdr, const fattr4_time_deleg_access *value)
{
	return xdrgen_encode_nfstime4(xdr, value);
}

bool
xdrgen_encode_fattr4_time_deleg_modify(struct xdr_stream *xdr, const fattr4_time_deleg_modify *value)
{
	return xdrgen_encode_nfstime4(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_open_delegation_type4(struct xdr_stream *xdr, open_delegation_type4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

bool
xdrgen_encode_aclmodel4(struct xdr_stream *xdr, aclmodel4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

bool
xdrgen_encode_aclscope4(struct xdr_stream *xdr, aclscope4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

bool
xdrgen_encode_posixacetag4(struct xdr_stream *xdr, posixacetag4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

bool
xdrgen_encode_posixaceperm4(struct xdr_stream *xdr, const posixaceperm4 value)
{
	return xdrgen_encode_uint32_t(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_posixace4(struct xdr_stream *xdr, const struct posixace4 *value)
{
	if (!xdrgen_encode_posixacetag4(xdr, value->tag))
		return false;
	if (!xdrgen_encode_posixaceperm4(xdr, value->perm))
		return false;
	if (!xdrgen_encode_utf8str_mixed(xdr, value->who))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_fattr4_acl_trueform(struct xdr_stream *xdr, const fattr4_acl_trueform value)
{
	return xdrgen_encode_aclmodel4(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_fattr4_acl_trueform_scope(struct xdr_stream *xdr, const fattr4_acl_trueform_scope value)
{
	return xdrgen_encode_aclscope4(xdr, value);
}

static bool __maybe_unused
xdrgen_encode_fattr4_posix_default_acl(struct xdr_stream *xdr, const fattr4_posix_default_acl value)
{
	if (xdr_stream_encode_u32(xdr, value.count) != XDR_UNIT)
		return false;
	for (u32 i = 0; i < value.count; i++)
		if (!xdrgen_encode_posixace4(xdr, &value.element[i]))
			return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_fattr4_posix_access_acl(struct xdr_stream *xdr, const fattr4_posix_access_acl value)
{
	if (xdr_stream_encode_u32(xdr, value.count) != XDR_UNIT)
		return false;
	for (u32 i = 0; i < value.count; i++)
		if (!xdrgen_encode_posixace4(xdr, &value.element[i]))
			return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_notify_type4(struct xdr_stream *xdr, notify_type4 value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

static bool __maybe_unused
xdrgen_encode_notify_entry4(struct xdr_stream *xdr, const struct notify_entry4 *value)
{
	if (!xdrgen_encode_component4(xdr, value->ne_file))
		return false;
	if (!xdrgen_encode_fattr4(xdr, &value->ne_attrs))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_prev_entry4(struct xdr_stream *xdr, const struct prev_entry4 *value)
{
	if (!xdrgen_encode_notify_entry4(xdr, &value->pe_prev_entry))
		return false;
	if (!xdrgen_encode_nfs_cookie4(xdr, value->pe_prev_entry_cookie))
		return false;
	return true;
}

bool
xdrgen_encode_notify_remove4(struct xdr_stream *xdr, const struct notify_remove4 *value)
{
	if (!xdrgen_encode_notify_entry4(xdr, &value->nrm_old_entry))
		return false;
	if (!xdrgen_encode_nfs_cookie4(xdr, value->nrm_old_entry_cookie))
		return false;
	return true;
}

bool
xdrgen_encode_notify_add4(struct xdr_stream *xdr, const struct notify_add4 *value)
{
	if (value->nad_old_entry.count > 1)
		return false;
	if (xdr_stream_encode_u32(xdr, value->nad_old_entry.count) != XDR_UNIT)
		return false;
	for (u32 i = 0; i < value->nad_old_entry.count; i++)
		if (!xdrgen_encode_notify_remove4(xdr, &value->nad_old_entry.element[i]))
			return false;
	if (!xdrgen_encode_notify_entry4(xdr, &value->nad_new_entry))
		return false;
	if (value->nad_new_entry_cookie.count > 1)
		return false;
	if (xdr_stream_encode_u32(xdr, value->nad_new_entry_cookie.count) != XDR_UNIT)
		return false;
	for (u32 i = 0; i < value->nad_new_entry_cookie.count; i++)
		if (!xdrgen_encode_nfs_cookie4(xdr, value->nad_new_entry_cookie.element[i]))
			return false;
	if (value->nad_prev_entry.count > 1)
		return false;
	if (xdr_stream_encode_u32(xdr, value->nad_prev_entry.count) != XDR_UNIT)
		return false;
	for (u32 i = 0; i < value->nad_prev_entry.count; i++)
		if (!xdrgen_encode_prev_entry4(xdr, &value->nad_prev_entry.element[i]))
			return false;
	if (!xdrgen_encode_bool(xdr, value->nad_last_entry))
		return false;
	return true;
}

bool
xdrgen_encode_notify_attr4(struct xdr_stream *xdr, const struct notify_attr4 *value)
{
	if (!xdrgen_encode_notify_entry4(xdr, &value->na_changed_entry))
		return false;
	return true;
}

bool
xdrgen_encode_notify_rename4(struct xdr_stream *xdr, const struct notify_rename4 *value)
{
	if (!xdrgen_encode_notify_remove4(xdr, &value->nrn_old_entry))
		return false;
	if (!xdrgen_encode_notify_add4(xdr, &value->nrn_new_entry))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_notify_verifier4(struct xdr_stream *xdr, const struct notify_verifier4 *value)
{
	if (!xdrgen_encode_verifier4(xdr, value->nv_old_cookieverf))
		return false;
	if (!xdrgen_encode_verifier4(xdr, value->nv_new_cookieverf))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_notifylist4(struct xdr_stream *xdr, const notifylist4 value)
{
	return xdr_stream_encode_opaque(xdr, value.data, value.len) >= 0;
}

static bool __maybe_unused
xdrgen_encode_notify4(struct xdr_stream *xdr, const struct notify4 *value)
{
	if (!xdrgen_encode_bitmap4(xdr, value->notify_mask))
		return false;
	if (!xdrgen_encode_notifylist4(xdr, value->notify_vals))
		return false;
	return true;
}

bool
xdrgen_encode_CB_NOTIFY4args(struct xdr_stream *xdr, const struct CB_NOTIFY4args *value)
{
	if (!xdrgen_encode_stateid4(xdr, &value->cna_stateid))
		return false;
	if (!xdrgen_encode_nfs_fh4(xdr, value->cna_fh))
		return false;
	if (xdr_stream_encode_u32(xdr, value->cna_changes.count) != XDR_UNIT)
		return false;
	for (u32 i = 0; i < value->cna_changes.count; i++)
		if (!xdrgen_encode_notify4(xdr, &value->cna_changes.element[i]))
			return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_CB_NOTIFY4res(struct xdr_stream *xdr, const struct CB_NOTIFY4res *value)
{
	if (!xdrgen_encode_nfsstat4(xdr, value->cnr_status))
		return false;
	return true;
}