File tree Expand file tree Collapse file tree 2 files changed +31
-17
lines changed Expand file tree Collapse file tree 2 files changed +31
-17
lines changed Original file line number Diff line number Diff line change @@ -536,23 +536,34 @@ end = struct
536536 else Float. pred f
537537
538538 let stat t ~follow path =
539- let module X = Uring. Statx in
540- let x = X. create () in
541- Low_level. statx_confined ~follow ~mask: X.Mask. basic_stats t.fd path x;
542- { Eio.File.Stat.
543- dev = X. dev x;
544- ino = X. ino x;
545- kind = X. kind x;
546- perm = X. perm x;
547- nlink = X. nlink x;
548- uid = X. uid x;
549- gid = X. gid x;
550- rdev = X. rdev x;
551- size = X. size x |> Optint.Int63. of_int64;
552- atime = float_of_time (X. atime_sec x) (X. atime_nsec x);
553- mtime = float_of_time (X. mtime_sec x) (X. mtime_nsec x);
554- ctime = float_of_time (X. ctime_sec x) (X. ctime_nsec x);
555- }
539+ if ! Sched. statx_works then (
540+ let module X = Uring. Statx in
541+ let x = X. create () in
542+ Low_level. statx_confined ~follow ~mask: X.Mask. basic_stats t.fd path x;
543+ { Eio.File.Stat.
544+ dev = X. dev x;
545+ ino = X. ino x;
546+ kind = X. kind x;
547+ perm = X. perm x;
548+ nlink = X. nlink x;
549+ uid = X. uid x;
550+ gid = X. gid x;
551+ rdev = X. rdev x;
552+ size = X. size x |> Optint.Int63. of_int64;
553+ atime = float_of_time (X. atime_sec x) (X. atime_nsec x);
554+ mtime = float_of_time (X. mtime_sec x) (X. mtime_nsec x);
555+ ctime = float_of_time (X. ctime_sec x) (X. ctime_nsec x);
556+ }
557+ ) else (
558+ (* Linux < 5.18 *)
559+ Switch. run @@ fun sw ->
560+ let fd = Low_level. openat ~sw ~seekable: false t.fd (if path = " " then " ." else path)
561+ ~access: `R
562+ ~flags: Uring.Open_flags. (cloexec + path + (if follow then empty else nofollow))
563+ ~perm: 0
564+ in
565+ Flow. stat fd
566+ )
556567
557568 let rename t old_path t2 new_path =
558569 match get_dir_fd_opt t2 with
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ module Lf_queue = Eio_utils.Lf_queue
1111
1212let system_thread = Ctf. mint_id ()
1313
14+ let statx_works = ref false (* Before Linux 5.18, statx is unreliable *)
15+
1416type exit = [`Exit_scheduler ]
1517
1618type file_offset = [
@@ -526,6 +528,7 @@ let with_sched ?(fallback=no_fallback) config fn =
526528 Uring. exit uring;
527529 fallback (`Msg " Linux >= 5.11 is required for io_uring support" )
528530 ) else (
531+ statx_works := Uring. op_supported probe Uring.Op. msg_ring;
529532 match
530533 let mem =
531534 let fixed_buf_len = block_size * n_blocks in
You can’t perform that action at this time.
0 commit comments