@@ -37,7 +37,9 @@ module Op = struct
37
37
| Isintroduced
38
38
| Resume
39
39
| Set_target
40
- | Restrict
40
+ | Invalid
41
+ | Reset_watches
42
+ | Directory_part
41
43
42
44
(* The index of the value in the array is the integer representation used
43
45
by the wire protocol. Every element of t exists exactly once in the array. *)
@@ -63,7 +65,9 @@ module Op = struct
63
65
; Isintroduced
64
66
; Resume
65
67
; Set_target
66
- ; Restrict
68
+ ; Invalid
69
+ ; Reset_watches
70
+ ; Directory_part
67
71
|]
68
72
69
73
let of_int32 i =
@@ -104,7 +108,9 @@ module Op = struct
104
108
| Isintroduced -> " isintroduced"
105
109
| Resume -> " resume"
106
110
| Set_target -> " set_target"
107
- | Restrict -> " restrict"
111
+ | Invalid -> " invalid"
112
+ | Reset_watches -> " reset_watches"
113
+ | Directory_part -> " directory_part"
108
114
end
109
115
110
116
let split_string ~limit c s =
@@ -212,6 +218,7 @@ let get_data pkt =
212
218
Buffer. sub pkt.data 0 (pkt.len - 1 )
213
219
else Buffer. contents pkt.data
214
220
221
+ let get_raw_data pkt = Buffer. contents pkt.data
215
222
let get_rid pkt = pkt.rid
216
223
217
224
module Parser = struct
@@ -372,10 +379,12 @@ module Response = struct
372
379
| Resume
373
380
| Release
374
381
| Set_target
375
- | Restrict
376
382
| Isintroduced of bool
377
383
| Error of string
378
384
| Watchevent of string * string
385
+ | Directory_part of int64 * string
386
+ (* Not a string list like Directory because we need to add another null
387
+ character at the end of the last packet *)
379
388
380
389
let prettyprint_payload =
381
390
let open Printf in
@@ -397,10 +406,10 @@ module Response = struct
397
406
| Resume -> " Resume"
398
407
| Release -> " Release"
399
408
| Set_target -> " Set_target"
400
- | Restrict -> " Restrict"
401
409
| Isintroduced x -> sprintf " Isintroduced %b" x
402
410
| Error x -> sprintf " Error %s" x
403
411
| Watchevent (x , y ) -> sprintf " Watchevent %s %s" x y
412
+ | Directory_part (gen , ls ) -> sprintf " Directory_part %Ld %s" gen ls
404
413
405
414
let ty_of_payload = function
406
415
| Read _ -> Op. Read
@@ -423,7 +432,7 @@ module Response = struct
423
432
| Resume -> Op. Resume
424
433
| Release -> Op. Release
425
434
| Set_target -> Op. Set_target
426
- | Restrict -> Op. Restrict
435
+ | Directory_part _ -> Op. Directory_part
427
436
428
437
let ok = " OK\000 "
429
438
@@ -437,6 +446,9 @@ module Response = struct
437
446
| Isintroduced b -> data_concat [ (if b then " T" else " F" ) ]
438
447
| Watchevent (path , token ) -> data_concat [ path; token ]
439
448
| Error x -> data_concat [ x ]
449
+ | Directory_part (gen , ls ) ->
450
+ let gen = Int64. to_string gen in
451
+ gen ^ " \000 " ^ ls
440
452
| _ -> ok
441
453
442
454
let print x tid rid = create tid rid (ty_of_payload x) (data_of_payload x)
@@ -446,6 +458,7 @@ module Request = struct
446
458
type path_op =
447
459
| Read
448
460
| Directory
461
+ | Directory_part of int (* offset *)
449
462
| Getperms
450
463
| Write of string
451
464
| Mkdir
@@ -464,7 +477,6 @@ module Request = struct
464
477
| Resume of int
465
478
| Release of int
466
479
| Set_target of int * int
467
- | Restrict of int
468
480
| Isintroduced of int
469
481
| Error of string
470
482
| Watchevent of string
@@ -474,6 +486,8 @@ module Request = struct
474
486
let prettyprint_pathop x = function
475
487
| Read -> sprintf " Read %s" x
476
488
| Directory -> sprintf " Directory %s" x
489
+ | Directory_part offset ->
490
+ sprintf " Directory_part %s %s" x (string_of_int offset)
477
491
| Getperms -> sprintf " Getperms %s" x
478
492
| Write v -> sprintf " Write %s %s" x v
479
493
| Mkdir -> sprintf " Mkdir %s" x
@@ -492,12 +506,13 @@ module Request = struct
492
506
| Resume x -> sprintf " Resume %d" x
493
507
| Release x -> sprintf " Release %d" x
494
508
| Set_target (x , y ) -> sprintf " Set_target %d %d" x y
495
- | Restrict x -> sprintf " Restrict %d" x
496
509
| Isintroduced x -> sprintf " Isintroduced %d" x
497
510
| Error x -> sprintf " Error %s" x
498
511
| Watchevent x -> sprintf " Watchevent %s" x
499
512
500
513
exception Parse_failure
514
+ exception Deprecated
515
+ exception Unimplemented
501
516
502
517
let strings data = String. split_on_char '\000' data
503
518
@@ -515,9 +530,10 @@ module Request = struct
515
530
let acl x =
516
531
match ACL. of_string x with Some x -> x | None -> raise Parse_failure
517
532
533
+ let is_digit c = c > = '0' && c < = '9'
534
+
518
535
let domid s =
519
536
let v = ref 0 in
520
- let is_digit c = c > = '0' && c < = '9' in
521
537
let len = String. length s in
522
538
let i = ref 0 in
523
539
while ! i < len && not (is_digit s.[! i]) do
@@ -537,6 +553,11 @@ module Request = struct
537
553
match get_ty request with
538
554
| Op. Read -> PathOp (data |> one_string, Read )
539
555
| Op. Directory -> PathOp (data |> one_string, Directory )
556
+ | Op. Directory_part ->
557
+ let path, off = two_strings data in
558
+ let off = int_of_string off in
559
+ PathOp (path, Directory_part off)
560
+ | Op. Reset_watches -> raise Unimplemented
540
561
| Op. Getperms -> PathOp (data |> one_string, Getperms )
541
562
| Op. Getdomainpath -> Getdomainpath (data |> one_string |> domid)
542
563
| Op. Transaction_start -> Transaction_start
@@ -571,10 +592,10 @@ module Request = struct
571
592
let mine, yours = two_strings data in
572
593
let mine = domid mine and yours = domid yours in
573
594
Set_target (mine, yours)
574
- | Op. Restrict -> Restrict (data |> one_string |> domid)
575
595
| Op. Isintroduced -> Isintroduced (data |> one_string |> domid)
576
596
| Op. Error -> Error (data |> one_string)
577
597
| Op. Watchevent -> Watchevent (data |> one_string)
598
+ | Op. Invalid -> raise Deprecated
578
599
579
600
let parse request = try Some (parse_exn request) with _ -> None
580
601
@@ -587,6 +608,7 @@ module Request = struct
587
608
588
609
let ty_of_payload = function
589
610
| PathOp (_ , Directory) -> Op. Directory
611
+ | PathOp (_ , Directory_part _ ) -> Op. Directory_part
590
612
| PathOp (_ , Read) -> Op. Read
591
613
| PathOp (_ , Getperms) -> Op. Getperms
592
614
| Debug _ -> Op. Debug
@@ -603,7 +625,6 @@ module Request = struct
603
625
| PathOp (_ , Rm) -> Op. Rm
604
626
| PathOp (_ , Setperms _ ) -> Op. Setperms
605
627
| Set_target (_ , _ ) -> Op. Set_target
606
- | Restrict _ -> Op. Restrict
607
628
| Isintroduced _ -> Op. Isintroduced
608
629
| Error _ -> Op. Error
609
630
| Watchevent _ -> Op. Watchevent
@@ -616,6 +637,8 @@ module Request = struct
616
637
| PathOp (path , Write value ) ->
617
638
path ^ " \000 " ^ value (* no NUL at the end *)
618
639
| PathOp (path , Setperms perms ) -> data_concat [ path; ACL. to_string perms ]
640
+ | PathOp (path , Directory_part value ) ->
641
+ data_concat [ path; string_of_int value ]
619
642
| PathOp (path , _ ) -> data_concat [ path ]
620
643
| Debug commands -> data_concat commands
621
644
| Watch (path , token ) | Unwatch (path , token ) -> data_concat [ path; token ]
@@ -628,11 +651,7 @@ module Request = struct
628
651
; Printf. sprintf " %nu" mfn
629
652
; string_of_int port
630
653
]
631
- | Release domid
632
- | Resume domid
633
- | Getdomainpath domid
634
- | Restrict domid
635
- | Isintroduced domid ->
654
+ | Release domid | Resume domid | Getdomainpath domid | Isintroduced domid ->
636
655
data_concat [ Printf. sprintf " %u" domid ]
637
656
| Set_target (mine , yours ) ->
638
657
data_concat [ Printf. sprintf " %u" mine; Printf. sprintf " %u" yours ]
@@ -658,6 +677,7 @@ module Unmarshal = struct
658
677
let int32 = int32_of_string_opt ++ get_data
659
678
let unit = unit_of_string_opt ++ get_data
660
679
let ok = ok ++ get_data
680
+ let raw = some ++ get_raw_data (* with trailing NUL *)
661
681
end
662
682
663
683
exception Enoent of string
0 commit comments