@@ -77,10 +77,11 @@ let chdir path =
77
77
traceln "chdir %S" path;
78
78
Unix.chdir path
79
79
80
- let try_stat path =
80
+ let try_stat ?(info_type=`Kind) path =
81
81
let stat ~follow =
82
- match Eio.Path.stat ~follow path with
83
- | info -> Fmt.str "@[<h>%a@]" Eio.File.Stat.pp_kind info.kind
82
+ match Eio.Path.stat ~follow path, info_type with
83
+ | info, `Perm -> Fmt.str "@[<h>%o@]" info.perm
84
+ | info, `Kind -> Fmt.str "@[<h>%a@]" Eio.File.Stat.pp_kind info.kind
84
85
| exception Eio.Io (e, _) -> Fmt.str "@[<h>%a@]" Eio.Exn.pp_err e
85
86
in
86
87
let a = stat ~follow:false in
@@ -94,6 +95,11 @@ let try_symlink ~link_to path =
94
95
match Path.symlink ~link_to path with
95
96
| s -> traceln "symlink %a -> %S" Path.pp path link_to
96
97
| exception ex -> traceln "@[<h>%a@]" Eio.Exn.pp ex
98
+
99
+ let try_chmod path ~follow ~perm =
100
+ match Eio.Path.chmod ~follow path ~perm with
101
+ | () -> traceln "chmod %a to %o -> ok" Path.pp path perm
102
+ | exception ex -> traceln "@[<h>%a@]" Eio.Exn.pp ex
97
103
```
98
104
99
105
# Basic test cases
@@ -865,6 +871,27 @@ Unconfined:
865
871
- : unit = ()
866
872
```
867
873
874
+ # chmod
875
+
876
+ Chmod works.
877
+
878
+ ``` ocaml
879
+ # run ~clear:["test-file"] @@ fun env ->
880
+ let cwd = Eio.Stdenv.cwd env in
881
+ let file_path = cwd / "test-file" in
882
+ Path.save ~create:(`Exclusive 0o644) file_path "test data";
883
+ try_chmod ~follow:false ~perm:0o400 file_path;
884
+ try_stat ~info_type:`Perm file_path;
885
+ try_chmod ~follow:false ~perm:0o600 file_path;
886
+ try_stat ~info_type:`Perm file_path
887
+ +chmod <cwd:test-file> to 400 -> ok
888
+ +<cwd:test-file> -> 400
889
+ +chmod <cwd:test-file> to 600 -> ok
890
+ +<cwd:test-file> -> 600
891
+ - : unit = ()
892
+ ```
893
+
894
+
868
895
# pread/pwrite
869
896
870
897
Check reading and writing vectors at arbitrary offsets:
0 commit comments