@@ -77,10 +77,11 @@ let chdir path =
7777 traceln "chdir %S" path;
7878 Unix.chdir path
7979
80- let try_stat path =
80+ let try_stat ?(info_type=`Kind) path =
8181 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
8485 | exception Eio.Io (e, _) -> Fmt.str "@[<h>%a@]" Eio.Exn.pp_err e
8586 in
8687 let a = stat ~follow:false in
@@ -94,6 +95,11 @@ let try_symlink ~link_to path =
9495 match Path.symlink ~link_to path with
9596 | s -> traceln "symlink %a -> %S" Path.pp path link_to
9697 | 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
97103```
98104
99105# Basic test cases
@@ -865,6 +871,27 @@ Unconfined:
865871- : unit = ()
866872```
867873
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+
868895# pread/pwrite
869896
870897Check reading and writing vectors at arbitrary offsets:
0 commit comments