/
nfs.py
1143 lines (970 loc) · 31.1 KB
/
nfs.py
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
"""
Basic NFS implementation.
"""
from xdr import xdr_int, xdr_uint, xdr_hyper, xdr_uhyper, xdr_opaque, xdr_array
from xdr import xdr_enum, xdr_struct, xdr_union, xdr_bool, xdr_string, xdr_void
from xdr import xdr_optional
from rpc import rpc_program, rpc_version, rpc_procedure
from rpc import auth_flavor as rpc_auth_flavor
int32_t = xdr_int
uint32_t = xdr_uint
int64_t = xdr_hyper
uint64_t = xdr_uhyper
NFS4_FHSIZE = 128
NFS4_VERIFIER_SIZE = 8
NFS4_OPAQUE_LIMIT = 1024
attrlist4 = xdr_opaque()
bitmap4 = xdr_array(uint32_t)
changeid4 = uint64_t
clientid4 = uint64_t
utf8str_cs = xdr_opaque()
component4 = utf8str_cs
count4 = uint32_t
length4 = uint64_t
linktext4 = utf8str_cs
mode4 = uint32_t
nfs_cookie4 = uint64_t
nfs_fh4 = xdr_opaque(max=NFS4_FHSIZE)
class nfs_ftype4(xdr_enum):
NF4REG = 1 # Regular File
NF4DIR = 2 # Directory
NF4BLK = 3 # Special File - block device
NF4CHR = 4 # Special File - character device
NF4LNK = 5 # Symbolic Link
NF4SOCK = 6 # Special File - socket
NF4FIFO = 7 # Special File - fifo
NF4ATTRDIR = 8 # Attribute Directory
NF4NAMEDATTR = 9 # Named Attribute
class nfsstat4(xdr_enum):
NFS4_OK = 0 # everything is okay
NFS4ERR_PERM = 1 # caller not privileged
NFS4ERR_NOENT = 2 # no such file/directory
NFS4ERR_IO = 5 # hard I/O error
NFS4ERR_NXIO = 6 # no such device
NFS4ERR_ACCESS = 13 # access denied
NFS4ERR_EXIST = 17 # file already exists
NFS4ERR_XDEV = 18 # different filesystems
# Unused/reserved 19
NFS4ERR_NOTDIR = 20 # should be a directory
NFS4ERR_ISDIR = 21 # should not be directory
NFS4ERR_INVAL = 22 # invalid argument
NFS4ERR_FBIG = 27 # file exceeds server max
NFS4ERR_NOSPC = 28 # no space on filesystem
NFS4ERR_ROFS = 30 # read-only filesystem
NFS4ERR_MLINK = 31 # too many hard links
NFS4ERR_NAMETOOLONG = 63 # name exceeds server max
NFS4ERR_NOTEMPTY = 66 # directory not empty
NFS4ERR_DQUOT = 69 # hard quota limit reached
NFS4ERR_STALE = 70 # file no longer exists
NFS4ERR_BADHANDLE = 10001 # Illegal filehandle
NFS4ERR_BAD_COOKIE = 10003 # READDIR cookie is stale
NFS4ERR_NOTSUPP = 10004 # operation not supported
NFS4ERR_TOOSMALL = 10005 # response limit exceeded
NFS4ERR_SERVERFAULT = 10006 # undefined server error
NFS4ERR_BADTYPE = 10007 # type invalid for CREATE
NFS4ERR_DELAY = 10008 # file "busy" - retry
NFS4ERR_SAME = 10009 # nverify says attrs same
NFS4ERR_DENIED = 10010 # lock unavailable
NFS4ERR_EXPIRED = 10011 # lock lease expired
NFS4ERR_LOCKED = 10012 # I/O failed due to lock
NFS4ERR_GRACE = 10013 # in grace period
NFS4ERR_FHEXPIRED = 10014 # filehandle expired
NFS4ERR_SHARE_DENIED = 10015 # share reserve denied
NFS4ERR_WRONGSEC = 10016 # wrong security flavor
NFS4ERR_CLID_INUSE = 10017 # clientid in use
NFS4ERR_RESOURCE = 10018 # resource exhaustion
NFS4ERR_MOVED = 10019 # filesystem relocated
NFS4ERR_NOFILEHANDLE = 10020 # current FH is not set
NFS4ERR_MINOR_VERS_MISMATCH = 10021 # minor vers not supp
NFS4ERR_STALE_CLIENTID = 10022 # server has rebooted
NFS4ERR_STALE_STATEID = 10023 # server has rebooted
NFS4ERR_OLD_STATEID = 10024 # state is out of sync
NFS4ERR_BAD_STATEID = 10025 # incorrect stateid
NFS4ERR_BAD_SEQID = 10026 # request is out of seq.
NFS4ERR_NOT_SAME = 10027 # verify - attrs not same
NFS4ERR_LOCK_RANGE = 10028 # lock range not supported
NFS4ERR_SYMLINK = 10029 # should be file/directory
NFS4ERR_RESTOREFH = 10030 # no saved filehandle
NFS4ERR_LEASE_MOVED = 10031 # some filesystem moved
NFS4ERR_ATTRNOTSUPP = 10032 # recommended attr not sup
NFS4ERR_NO_GRACE = 10033 # reclaim outside of grace
NFS4ERR_RECLAIM_BAD = 10034 # reclaim error at server
NFS4ERR_RECLAIM_CONFLICT = 10035 # conflict on reclaim
NFS4ERR_BADXDR = 10036 # XDR decode failed
NFS4ERR_LOCKS_HELD = 10037 # file locks held at CLOSE
NFS4ERR_OPENMODE = 10038 # conflict in OPEN and I/O
NFS4ERR_BADOWNER = 10039 # owner translation bad
NFS4ERR_BADCHAR = 10040 # utf-8 char not supported
NFS4ERR_BADNAME = 10041 # name not supported
NFS4ERR_BAD_RANGE = 10042 # lock range not supported
NFS4ERR_LOCK_NOTSUPP = 10043 # no atomic up/downgrade
NFS4ERR_OP_ILLEGAL = 10044 # undefined operation
NFS4ERR_DEADLOCK = 10045 # file locking deadlock
NFS4ERR_FILE_OPEN = 10046 # open file blocks op.
NFS4ERR_ADMIN_REVOKED = 10047 # lockowner state revoked
NFS4ERR_CB_PATH_DOWN = 10048 # callback path down
offset4 = uint64_t
pathname4 = xdr_array(component4)
qop4 = uint32_t
sec_oid4 = xdr_opaque()
seqid4 = uint32_t
utf8string = xdr_opaque()
utf8str_cis = xdr_opaque()
utf8str_mixed = xdr_opaque()
verifier4 = xdr_opaque(size=NFS4_VERIFIER_SIZE)
class nfstime4(xdr_struct):
seconds = int64_t
nseconds = uint32_t
class time_how4(xdr_enum):
SET_TO_SERVER_TIME4 = 0
SET_TO_CLIENT_TIME4 = 1
class settime4(xdr_union(set_it=time_how4)):
SET_TO_CLIENT_TIME4.time = nfstime4
# File access handle
nfs_fh4 = xdr_opaque(max=NFS4_FHSIZE)
# File attribute definitions
# FSID structure for major/minor
class fsid4(xdr_struct):
major = uint64_t
minor = uint64_t
# Filesystem locations attribute for relocation/migration
class fs_location4(xdr_struct):
server = xdr_array(utf8str_cis)
rootpath = pathname4
class fs_locations4(xdr_struct):
fs_root = pathname4
locations = xdr_array(fs_location4)
# Various Access Control Entry definitions
# Mask that indicates which Access Control Entries are supported.
# Values for the fattr4_aclsupport attribute.
ACL4_SUPPORT_ALLOW_ACL = 1
ACL4_SUPPORT_DENY_ACL = 2
ACL4_SUPPORT_AUDIT_ACL = 4
ACL4_SUPPORT_ALARM_ACL = 8
acetype4 = uint32_t
# acetype4 values, others can be added as needed.
ACE4_ACCESS_ALLOWED_ACE_TYPE = 0
ACE4_ACCESS_DENIED_ACE_TYPE = 1
ACE4_SYSTEM_AUDIT_ACE_TYPE = 2
ACE4_SYSTEM_ALARM_ACE_TYPE = 3
# ACE flag
aceflag4 = uint32_t
# ACE flag values
ACE4_FILE_INHERIT_ACE = 0x00000001
ACE4_DIRECTORY_INHERIT_ACE = 0x00000002
ACE4_NO_PROPAGATE_INHERIT_ACE = 0x00000004
ACE4_INHERIT_ONLY_ACE = 0x00000008
ACE4_SUCCESSFUL_ACCESS_ACE_FLAG = 0x00000010
ACE4_FAILED_ACCESS_ACE_FLAG = 0x00000020
ACE4_IDENTIFIER_GROUP = 0x00000040
# ACE mask
acemask4 = uint32_t
# ACE mask values
ACE4_READ_DATA = 0x00000001
ACE4_LIST_DIRECTORY = 0x00000001
ACE4_WRITE_DATA = 0x00000002
ACE4_ADD_FILE = 0x00000002
ACE4_APPEND_DATA = 0x00000004
ACE4_ADD_SUBDIRECTORY = 0x00000004
ACE4_READ_NAMED_ATTRS = 0x00000008
ACE4_WRITE_NAMED_ATTRS = 0x00000010
ACE4_EXECUTE = 0x00000020
ACE4_DELETE_CHILD = 0x00000040
ACE4_READ_ATTRIBUTES = 0x00000080
ACE4_WRITE_ATTRIBUTES = 0x00000100
ACE4_DELETE = 0x00010000
ACE4_READ_ACL = 0x00020000
ACE4_WRITE_ACL = 0x00040000
ACE4_WRITE_OWNER = 0x00080000
ACE4_SYNCHRONIZE = 0x00100000
# ACE4_GENERIC_READ -- defined as combination of
# ACE4_READ_ACL |
# ACE4_READ_DATA |
# ACE4_READ_ATTRIBUTES |
# ACE4_SYNCHRONIZE
ACE4_GENERIC_READ = 0x00120081
# ACE4_GENERIC_WRITE -- defined as combination of
# ACE4_READ_ACL |
# ACE4_WRITE_DATA |
# ACE4_WRITE_ATTRIBUTES |
# ACE4_WRITE_ACL |
# ACE4_APPEND_DATA |
# ACE4_SYNCHRONIZE
ACE4_GENERIC_WRITE = 0x00160106
# ACE4_GENERIC_EXECUTE -- defined as combination of
# ACE4_READ_ACL
# ACE4_READ_ATTRIBUTES
# ACE4_EXECUTE
# ACE4_SYNCHRONIZE
ACE4_GENERIC_EXECUTE = 0x001200A0
# Access Control Entry definition
class nfsace4(xdr_struct):
type = acetype4
flag = aceflag4
access_mask = acemask4
who = utf8str_mixed
# Field definitions for the fattr4_mode attribute
MODE4_SUID = 0x800 # set user id on execution
MODE4_SGID = 0x400 # set group id on execution
MODE4_SVTX = 0x200 # save text even after use
MODE4_RUSR = 0x100 # read permission: owner
MODE4_WUSR = 0x080 # write permission: owner
MODE4_XUSR = 0x040 # execute permission: owner
MODE4_RGRP = 0x020 # read permission: group
MODE4_WGRP = 0x010 # write permission: group
MODE4_XGRP = 0x008 # execute permission: group
MODE4_ROTH = 0x004 # read permission: other
MODE4_WOTH = 0x002 # write permission: other
MODE4_XOTH = 0x001 # execute permission: other
class specdata4(xdr_struct):
specdata1 = uint32_t
specdata2 = uint32_t
FH4_PERSISTENT = 0
FH4_NOEXPIRE_WITH_OPEN = 1
FH4_VOLATILE_ANY = 2
FH4_VOL_MIGRATION = 4
FH4_VOL_RENAME = 8
fattr4_supported_attrs = bitmap4
fattr4_type = nfs_ftype4
fattr4_fh_expire_type = uint32_t
fattr4_change = changeid4
fattr4_size = uint64_t
fattr4_link_support = xdr_bool
fattr4_symlink_support = xdr_bool
fattr4_named_attr = xdr_bool
fattr4_fsid = fsid4
fattr4_unique_handles = xdr_bool
fattr4_lease_time = uint32_t
fattr4_rdattr_error = nfsstat4
fattr4_acl = xdr_array(nfsace4)
fattr4_aclsupport = uint32_t
fattr4_archive = xdr_bool
fattr4_cansettime = xdr_bool
fattr4_case_insensitive = xdr_bool
fattr4_case_preserving = xdr_bool
fattr4_chown_restricted = xdr_bool
fattr4_fileid = uint64_t
fattr4_files_avail = uint64_t
fattr4_filehandle = nfs_fh4
fattr4_files_free = uint64_t
fattr4_files_total = uint64_t
fattr4_fs_locations = fs_locations4
fattr4_hidden = xdr_bool
fattr4_homogeneous = xdr_bool
fattr4_maxfilesize = uint64_t
fattr4_maxlink = uint32_t
fattr4_maxname = uint32_t
fattr4_maxread = uint64_t
fattr4_maxwrite = uint64_t
fattr4_mimetype = utf8str_cs
fattr4_mode = mode4
fattr4_mounted_on_fileid = uint64_t
fattr4_no_trunc = xdr_bool
fattr4_numlinks = uint32_t
fattr4_owner = utf8str_mixed
fattr4_owner_group = utf8str_mixed
fattr4_quota_avail_hard = uint64_t
fattr4_quota_avail_soft = uint64_t
fattr4_quota_used = uint64_t
fattr4_rawdev = specdata4
fattr4_space_avail = uint64_t
fattr4_space_free = uint64_t
fattr4_space_total = uint64_t
fattr4_space_used = uint64_t
fattr4_system = xdr_bool
fattr4_time_access = nfstime4
fattr4_time_access_set = settime4
fattr4_time_backup = nfstime4
fattr4_time_create = nfstime4
fattr4_time_delta = nfstime4
fattr4_time_metadata = nfstime4
fattr4_time_modify = nfstime4
fattr4_time_modify_set = settime4
# Mandatory Attributes
FATTR4_SUPPORTED_ATTRS = 0
FATTR4_TYPE = 1
FATTR4_FH_EXPIRE_TYPE = 2
FATTR4_CHANGE = 3
FATTR4_SIZE = 4
FATTR4_LINK_SUPPORT = 5
FATTR4_SYMLINK_SUPPORT = 6
FATTR4_NAMED_ATTR = 7
FATTR4_FSID = 8
FATTR4_UNIQUE_HANDLES = 9
FATTR4_LEASE_TIME = 10
FATTR4_RDATTR_ERROR = 11
FATTR4_FILEHANDLE = 19
# Recommended Attributes
FATTR4_ACL = 12
FATTR4_ACLSUPPORT = 13
FATTR4_ARCHIVE = 14
FATTR4_CANSETTIME = 15
FATTR4_CASE_INSENSITIVE = 16
FATTR4_CASE_PRESERVING = 17
FATTR4_CHOWN_RESTRICTED = 18
FATTR4_FILEID = 20
FATTR4_FILES_AVAIL = 21
FATTR4_FILES_FREE = 22
FATTR4_FILES_TOTAL = 23
FATTR4_FS_LOCATIONS = 24
FATTR4_HIDDEN = 25
FATTR4_HOMOGENEOUS = 26
FATTR4_MAXFILESIZE = 27
FATTR4_MAXLINK = 28
FATTR4_MAXNAME = 29
FATTR4_MAXREAD = 30
FATTR4_MAXWRITE = 31
FATTR4_MIMETYPE = 32
FATTR4_MODE = 33
FATTR4_NO_TRUNC = 34
FATTR4_NUMLINKS = 35
FATTR4_OWNER = 36
FATTR4_OWNER_GROUP = 37
FATTR4_QUOTA_AVAIL_HARD = 38
FATTR4_QUOTA_AVAIL_SOFT = 39
FATTR4_QUOTA_USED = 40
FATTR4_RAWDEV = 41
FATTR4_SPACE_AVAIL = 42
FATTR4_SPACE_FREE = 43
FATTR4_SPACE_TOTAL = 44
FATTR4_SPACE_USED = 45
FATTR4_SYSTEM = 46
FATTR4_TIME_ACCESS = 47
FATTR4_TIME_ACCESS_SET = 48
FATTR4_TIME_BACKUP = 49
FATTR4_TIME_CREATE = 50
FATTR4_TIME_DELTA = 51
FATTR4_TIME_METADATA = 52
FATTR4_TIME_MODIFY = 53
FATTR4_TIME_MODIFY_SET = 54
FATTR4_MOUNTED_ON_FILEID = 55
class fattr4(xdr_struct):
attrmask = bitmap4
attr_vals = attrlist4
class change_info4(xdr_struct):
atomic = xdr_bool
before = changeid4
after = changeid4
class clientaddr4(xdr_struct):
r_netid = xdr_string()
r_addr = xdr_string()
class cb_client4(xdr_struct):
cb_program = xdr_uint
cb_location = clientaddr4
class nfs_client_id4(xdr_struct):
verifier = verifier4
id = xdr_opaque(max=NFS4_OPAQUE_LIMIT)
class open_owner4(xdr_struct):
clientid = clientid4
owner = xdr_opaque(max=NFS4_OPAQUE_LIMIT)
class lock_owner4(xdr_struct):
clientid = clientid4
owner = xdr_opaque(max=NFS4_OPAQUE_LIMIT)
class stateid4(xdr_struct):
seqid = uint32_t
other = xdr_opaque(size=12)
class open_to_lock_owner4(xdr_struct):
open_seqid = seqid4
open_stateid = stateid4
lock_seqid = seqid4
lock_owner = lock_owner4
class SECINFO4args(xdr_struct):
# CURRENT_FH: directory
name = component4
# From RFC 2203
class rpc_gss_svc_t(xdr_enum):
RPC_GSS_SVC_NONE = 1
RPC_GSS_SVC_INTEGRITY = 2
RPC_GSS_SVC_PRIVACY = 3
class rpcsec_gss_info(xdr_struct):
oid = sec_oid4
qop = qop4
service = rpc_gss_svc_t
class nfs_lock_type4(xdr_enum):
READ_LT = 1
WRITE_LT = 2
READW_LT = 3 # blocking read
WRITEW_LT = 4 # blocking write
# ACCESS: Check access permission
ACCESS4_READ = 1
ACCESS4_LOOKUP = 2
ACCESS4_MODIFY = 4
ACCESS4_EXTEND = 8
ACCESS4_DELETE = 16
ACCESS4_EXECUTE = 32
class ACCESS4args(xdr_struct):
# CURRENT_FH: object
access = uint32_t
class ACCESS4resok(xdr_struct):
supported = uint32_t
access = uint32_t
class ACCESS4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = ACCESS4resok
# CLOSE: Close a file and release share reservations
class CLOSE4args(xdr_struct):
# CURRENT_FH: object
seqid = seqid4
open_stateid = stateid4
class CLOSE4res(xdr_union(status=nfsstat4)):
NFS4_OK.open_stateid = stateid4
# COMMIT: Commit cached data on server to stable storage
class COMMIT4args(xdr_struct):
# CURRENT_FH: file
offset = offset4
count = count4
class COMMIT4resok(xdr_struct):
writeverf = verifier4
class COMMIT4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = COMMIT4resok
# CREATE: Create a non-regular file
class createtype4(xdr_union(type=nfs_ftype4)):
NF4LNK.linkdata = linktext4
NF4BLK.devdata = specdata4
NF4CHR.devdata = specdata4
class CREATE4args(xdr_struct):
# CURRENT_FH: directory for creation
objtype = createtype4
objname = component4
createattrs = fattr4
class CREATE4resok(xdr_struct):
cinfo = change_info4
attrset = bitmap4 # attributes set
class CREATE4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = CREATE4resok
# DELEGPURGE: Purge Delegations Awaiting Recovery
class DELEGPURGE4args(xdr_struct):
clientid = clientid4
class DELEGPURGE4res(xdr_struct):
status = nfsstat4
# DELEGRETURN: Return a delegation
class DELEGRETURN4args(xdr_struct):
# CURRENT_FH: delegated file
deleg_stateid = stateid4
class DELEGRETURN4res(xdr_struct):
status = nfsstat4
# GETATTR: Get file attributes
class GETATTR4args(xdr_struct):
# CURRENT_FH: directory or file
attr_request = bitmap4
class GETATTR4resok(xdr_struct):
obj_attributes = fattr4
class GETATTR4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = GETATTR4resok
# GETFH: Get current filehandle
class GETFH4resok(xdr_struct):
object = nfs_fh4
class GETFH4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = GETFH4resok
# LINK: Create link to an object
class LINK4args(xdr_struct):
# SAVED_FH: source object
# CURRENT_FH: target directory
newname = component4
class LINK4resok(xdr_struct):
cinfo = change_info4
class LINK4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = LINK4resok
# For LOCK, transition from open_owner to new lock_owner
class open_to_lock_owner4(xdr_struct):
open_seqid = seqid4
open_stateid = stateid4
lock_seqid = seqid4
lock_owner = lock_owner4
# For LOCK, existing lock_owner continues to request file locks
class exist_lock_owner4(xdr_struct):
lock_stateid = stateid4
lock_seqid = seqid4
class locker4(xdr_union(new_lock_owner=xdr_bool)):
TRUE.open_owner = open_to_lock_owner4
FALSE.lock_owner = exist_lock_owner4
# LOCK/LOCKT/LOCKU: Record lock management
class LOCK4args(xdr_struct):
# CURRENT_FH: file
locktype = nfs_lock_type4
reclaim = xdr_bool
offset = offset4
length = length4
locker = locker4
class LOCK4denied(xdr_struct):
offset = offset4
length = length4
locktype = nfs_lock_type4
owner = lock_owner4
class LOCK4resok(xdr_struct):
lock_stateid = stateid4
class LOCK4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = LOCK4resok
NFS4ERR_DENIED.denied = LOCK4denied
class LOCKT4args(xdr_struct):
# CURRENT_FH: file
locktype = nfs_lock_type4
offset = offset4
length = length4
owner = lock_owner4
class LOCKT4res(xdr_union(status=nfsstat4)):
NFS4ERR_DENIED.denied = LOCK4denied
class LOCKU4args(xdr_struct):
# CURRENT_FH: file
locktype = nfs_lock_type4
seqid = seqid4
lock_stateid = stateid4
offset = offset4
length = length4
class LOCKU4res(xdr_union(status=nfsstat4)):
NFS4_OK.lock_stateid = stateid4
# LOOKUP: Lookup filename
class LOOKUP4args(xdr_struct):
# CURRENT_FH: directory
objname = component4
class LOOKUP4res(xdr_struct):
# CURRENT_FH: object
status = nfsstat4
# LOOKUPP: Lookup parent directory
class LOOKUPP4res(xdr_struct):
# CURRENT_FH: directory
status = nfsstat4
# NVERIFY: Verify attributes different
class NVERIFY4args(xdr_struct):
# CURRENT_FH: object
obj_attributes = fattr4
class NVERIFY4res(xdr_struct):
status = nfsstat4
# Various definitions for OPEN
class createmode4(xdr_enum):
UNCHECKED4 = 0
GUARDED4 = 1
EXCLUSIVE4 = 2
class createhow4(xdr_union(mode=createmode4)):
UNCHECKED4.createattrs = fattr4
GUARDED4.createattrs = fattr4
EXCLUSIVE4.createverf = verifier4
class opentype4(xdr_enum):
OPEN4_NOCREATE = 0
OPEN4_CREATE = 1
class openflag4(xdr_union(opentype=opentype4)):
OPEN4_CREATE.how = createhow4
# Next definitions used for OPEN delegation
class limit_by4(xdr_enum):
NFS_LIMIT_SIZE = 1
NFS_LIMIT_BLOCKS = 2
# others as needed
class nfs_modified_limit4(xdr_struct):
num_blocks = uint32_t
bytes_per_block = uint32_t
class nfs_space_limit4(xdr_union(limitby=limit_by4)):
# limit specified as file size
NFS_LIMIT_SIZE.filesize = uint64_t
# limit specified by number of blocks
NFS_LIMIT_BLOCKS.mod_blocks = nfs_modified_limit4
# Share Access and Deny constants for open argument
OPEN4_SHARE_ACCESS_READ = 1
OPEN4_SHARE_ACCESS_WRITE = 2
OPEN4_SHARE_ACCESS_BOTH = 3
OPEN4_SHARE_DENY_NONE = 0
OPEN4_SHARE_DENY_READ = 1
OPEN4_SHARE_DENY_WRITE = 2
OPEN4_SHARE_DENY_BOTH = 3
class open_delegation_type4(xdr_enum):
OPEN_DELEGATE_NONE = 0
OPEN_DELEGATE_READ = 1
OPEN_DELEGATE_WRITE = 2
class open_claim_type4(xdr_enum):
CLAIM_NULL = 0
CLAIM_PREVIOUS = 1
CLAIM_DELEGATE_CUR = 2
CLAIM_DELEGATE_PREV = 3
class open_claim_delegate_cur4(xdr_struct):
delegate_stateid = stateid4
file = component4
class open_claim4(xdr_union(claim=open_claim_type4)):
# No special rights to file. Ordinary OPEN of the specified file.
CLAIM_NULL.file = component4
# CURRENT_FH: directory
# Right to the file established by an open previous to server
# reboot. File identified by filehandle obtained at that time
# rather than by name.
CLAIM_PREVIOUS.delegate_type = open_delegation_type4
# CURRENT_FH: file being reclaimed
# Right to file based on a delegation granted by the server.
# File is specified by name.
CLAIM_DELEGATE_CUR.delegate_cur_info = open_claim_delegate_cur4
# CURRENT_FH: directory
# Right to file based on a delegation granted to a previous boot
# instance of the client. File is specified by name.
CLAIM_DELEGATE_PREV.file_delegate_prev = component4
# CURRENT_FH: directory
# OPEN: Open a file, potentially receiving an open delegation
class OPEN4args(xdr_struct):
seqid = seqid4
share_access = uint32_t
share_deny = uint32_t
owner = open_owner4
openhow = openflag4
claim = open_claim4
class open_read_delegation4(xdr_struct):
# Stateid for delegation
stateid = stateid4
# Pre-recalled flag for delegations obtained by reclaim (CLAIM_PREVIOUS)
recall = xdr_bool
# Defines users who don't need an ACCESS call to open for read
permissions = nfsace4
class open_write_delegation4(xdr_struct):
# Stateid for delegation
stateid = stateid4
# Pre-recalled flag for delegations obtained by reclaim (CLAIM_PREVIOUS)
recall = xdr_bool
# Defines condition that the client must check to determine whether the
# file needs to be flushed to the server on close.
space_limit = nfs_space_limit4
# Defines users who don't need an ACCESS call as part of a delegated open.
permissions = nfsace4
class open_delegation4(xdr_union(delegation_type=open_delegation_type4)):
OPEN_DELEGATE_READ.read = open_read_delegation4
OPEN_DELEGATE_WRITE.write = open_write_delegation4
# Result flags
# Client must confirm open
OPEN4_RESULT_CONFIRM = 2
# Type of file locking behavior at the server
OPEN4_RESULT_LOCKTYPE_POSIX = 4
class OPEN4resok(xdr_struct):
stateid = stateid4 # Stateid for open
cinfo = change_info4 # Directory Change Info
rflags = uint32_t # Result flags
attrset = bitmap4 # attribute set for create
delegation = open_delegation4 # Info on any open delegation
class OPEN4res(xdr_union(status=nfsstat4)):
# CURRENT_FH: opened file
NFS4_OK.resok4 = OPEN4resok
# OPENATTR: open named attributes directory
class OPENATTR4args(xdr_struct):
# CURRENT_FH: object
createdir = xdr_bool
class OPENATTR4res(xdr_struct):
# CURRENT_FH: named attr directory
status = nfsstat4
# OPEN_CONFIRM: confirm the open
class OPEN_CONFIRM4args(xdr_struct):
# CURRENT_FH: opened file
open_stateid = stateid4
seqid = seqid4
class OPEN_CONFIRM4resok(xdr_struct):
open_stateid = stateid4
class OPEN_CONFIRM4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = OPEN_CONFIRM4resok
# OPEN_DOWNGRADE: downgrade the access/deny for a file
class OPEN_DOWNGRADE4args(xdr_struct):
# CURRENT_FH: opened file
open_stateid = stateid4
seqid = seqid4
share_access = uint32_t
share_deny = uint32_t
class OPEN_DOWNGRADE4resok(xdr_struct):
open_stateid = stateid4
class OPEN_DOWNGRADE4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = OPEN_DOWNGRADE4resok
# PUTFH: Set current filehandle
class PUTFH4args(xdr_struct):
object = nfs_fh4
class PUTFH4res(xdr_struct):
# CURRENT_FH:
status = nfsstat4
# PUTPUBFH: Set public filehandle
class PUTPUBFH4res(xdr_struct):
# CURRENT_FH: public fh
status = nfsstat4
# PUTROOTFH: Set root filehandle
class PUTROOTFH4res(xdr_struct):
# CURRENT_FH: root fh
status = nfsstat4
# READ: Read from file
class READ4args(xdr_struct):
# CURRENT_FH: file
stateid = stateid4
offset = offset4
count = count4
class READ4resok(xdr_struct):
eof = xdr_bool
data = xdr_opaque()
class READ4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = READ4resok
# READDIR: Read directory
class READDIR4args(xdr_struct):
# CURRENT_FH: directory
cookie = nfs_cookie4
cookieverf = verifier4
dircount = count4
maxcount = count4
attr_request = bitmap4
class entry4(xdr_struct):
cookie = nfs_cookie4
name = component4
attrs = fattr4
entry4.nextentry = xdr_optional(entry4)
class dirlist4(xdr_struct):
entries = xdr_optional(entry4)
eof = xdr_bool
class READDIR4resok(xdr_struct):
cookieverf = verifier4
reply = dirlist4
class READDIR4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = READDIR4resok
# READLINK: Read symbolic link
class READLINK4resok(xdr_struct):
link = linktext4
class READLINK4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = READLINK4resok
# REMOVE: Remove filesystem object
class REMOVE4args(xdr_struct):
# CURRENT_FH: directory
target = component4
class REMOVE4resok(xdr_struct):
cinfo = change_info4
class REMOVE4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = REMOVE4resok
# RENAME: Rename directory entry
class RENAME4args(xdr_struct):
# SAVED_FH: source directory
oldname = component4
# CURRENT_FH: target directory
newname = component4
class RENAME4resok(xdr_struct):
source_cinfo = change_info4
target_cinfo = change_info4
class RENAME4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = RENAME4resok
# RENEW: Renew a Lease
class RENEW4args(xdr_struct):
clientid = clientid4
class RENEW4res(xdr_struct):
status = nfsstat4
# RESTOREFH: Restore saved filehandle
class RESTOREFH4res(xdr_struct):
# CURRENT_FH: value of saved fh
status = nfsstat4
# SAVEFH: Save current filehandle
class SAVEFH4res(xdr_struct):
# SAVED_FH: value of current fh
status = nfsstat4
# RPCSEC_GSS has a value of '6' - See RFC 2203
class secinfo4(xdr_union(flavor=rpc_auth_flavor)):
RPCSEC_GSS.flavor_info = rpcsec_gss_info
SECINFO4resok = xdr_array(secinfo4)
class SECINFO4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = SECINFO4resok
class SETATTR4args(xdr_struct):
# CURRENT_FH: target object
stateid = stateid4
obj_attributes = fattr4
class SETATTR4res(xdr_struct):
status = nfsstat4
attrsset = bitmap4
class SETCLIENTID4args(xdr_struct):
client = nfs_client_id4
callback = cb_client4
callback_ident = uint32_t
class SETCLIENTID4resok(xdr_struct):
clientid = clientid4
setclientid_confirm = verifier4
class SETCLIENTID4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = SETCLIENTID4resok
NFS4ERR_CLID_INUSE.client_using = clientaddr4
class SETCLIENTID_CONFIRM4args(xdr_struct):
clientid = clientid4
setclientid_confirm = verifier4
class SETCLIENTID_CONFIRM4res(xdr_struct):
status = nfsstat4
class VERIFY4args(xdr_struct):
# CURRENT_FH: object
obj_attributes = fattr4
class VERIFY4res(xdr_struct):
status = nfsstat4
class stable_how4(xdr_enum):
UNSTABLE4 = 0
DATA_SYNC4 = 1
FILE_SYNC4 = 2
class WRITE4args(xdr_struct):
# CURRENT_FH: file
stateid = stateid4
offset = offset4
stable = stable_how4
data = xdr_opaque()
class WRITE4resok(xdr_struct):
count = count4
committed = stable_how4
writeverf = verifier4
class WRITE4res(xdr_union(status=nfsstat4)):
NFS4_OK.resok4 = WRITE4resok
class RELEASE_LOCKOWNER4args(xdr_struct):
lock_owner = lock_owner4
class RELEASE_LOCKOWNER4res(xdr_struct):
status = nfsstat4
class ILLEGAL4res(xdr_struct):
status = nfsstat4
class nfs_opnum4(xdr_enum):
OP_ACCESS = 3
OP_CLOSE = 4
OP_COMMIT = 5
OP_CREATE = 6
OP_DELEGPURGE = 7
OP_DELEGRETURN = 8
OP_GETATTR = 9
OP_GETFH = 10
OP_LINK = 11
OP_LOCK = 12
OP_LOCKT = 13
OP_LOCKU = 14
OP_LOOKUP = 15
OP_LOOKUPP = 16
OP_NVERIFY = 17
OP_OPEN = 18
OP_OPENATTR = 19
OP_OPEN_CONFIRM = 20
OP_OPEN_DOWNGRADE = 21
OP_PUTFH = 22
OP_PUTPUBFH = 23
OP_PUTROOTFH = 24
OP_READ = 25
OP_READDIR = 26
OP_READLINK = 27
OP_REMOVE = 28
OP_RENAME = 29
OP_RENEW = 30
OP_RESTOREFH = 31
OP_SAVEFH = 32
OP_SECINFO = 33
OP_SETATTR = 34
OP_SETCLIENTID = 35
OP_SETCLIENTID_CONFIRM = 36
OP_VERIFY = 37
OP_WRITE = 38