···109109 | _ -> assert false
110110 )
111111 in
112112+ let at_flags, mask_flags =
113113+ C.C_define.import c ~c_flags:["-D_GNU_SOURCE"; "-I"; Filename.concat (Sys.getcwd ()) "include"]
114114+ ~prelude:{|#include <sys/stat.h>
115115+#ifndef STATX_TYPE
116116+#include <linux/stat.h>
117117+#endif|}
118118+ ~includes:["fcntl.h" ]
119119+ C.C_define.Type.[
120120+ "AT_EMPTY_PATH", Int;
121121+ "AT_NO_AUTOMOUNT", Int;
122122+ "AT_SYMLINK_NOFOLLOW", Int;
123123+ "AT_STATX_SYNC_AS_STAT", Int;
124124+ "AT_STATX_FORCE_SYNC", Int;
125125+ "AT_STATX_DONT_SYNC", Int;
126126+127127+ "STATX_TYPE", Int;
128128+ "STATX_MODE", Int;
129129+ "STATX_NLINK", Int;
130130+ "STATX_UID", Int;
131131+ "STATX_GID", Int;
132132+ "STATX_ATIME", Int;
133133+ "STATX_MTIME", Int;
134134+ "STATX_CTIME", Int;
135135+ "STATX_INO", Int;
136136+ "STATX_SIZE", Int;
137137+ "STATX_BLOCKS", Int;
138138+ "STATX_BASIC_STATS", Int;
139139+ "STATX_BTIME", Int;
140140+ ]
141141+ |> List.fold_left (fun (ats, stats) (v, k) -> match String.split_on_char '_' v, k with
142142+ | "AT" :: name, C.C_define.Value.Int v ->
143143+ let ocaml_name = String.lowercase_ascii (String.concat "_" name) in
144144+ ((ocaml_name, v) :: ats, stats)
145145+ | "STATX" :: name, C.C_define.Value.Int v ->
146146+ let name = String.concat "_" name |> String.lowercase_ascii in
147147+ let ocaml_name = match name with
148148+ | "type" -> "type'"
149149+ | v -> v
150150+ in
151151+ (ats, (ocaml_name, v) :: stats)
152152+ | _ -> assert false
153153+ ) ([], [])
154154+ in
112155 let op_sig = List.map (fun (name, _) -> Printf.sprintf " val %s : t" name) ops in
113156 let op_struct = List.map (fun (name, v) -> Printf.sprintf " let %s = 0x%x" name v) ops in
157157+ let at_struct = List.map (fun (name, v) -> Printf.sprintf " let %s = 0x%x" name v) at_flags in
158158+ let mask_struct = List.map (fun (name, v) -> Printf.sprintf " let %s = 0x%x" name v) mask_flags in
114159 C.Flags.write_lines "config.ml"
115160 (defs @
116161 ["module Op : sig";
···120165 " type t = int"
121166 ] @ op_struct @ [
122167 "end"
168168+ ] @ [
169169+ "module Statx = struct";
170170+ " module Flags = struct";
171171+ ] @ at_struct @ [
172172+ " end";
173173+ " module Mask = struct";
174174+ ] @ mask_struct @ [
175175+ " end";
176176+ "end"
123177 ])
124178 )
+59
vendor/opam/uring/lib/uring/uring.ml
···8686 let pollhup = Config.pollhup
8787end
88888989+module Statx = struct
9090+ type internal
9191+9292+ type kind = [
9393+ | `Unknown
9494+ | `Fifo
9595+ | `Character_special
9696+ | `Directory
9797+ | `Block_device
9898+ | `Regular_file
9999+ | `Symbolic_link
100100+ | `Socket
101101+ ]
102102+103103+ type t = {
104104+ blksize : Int64.t;
105105+ attributes : Int64.t;
106106+ nlink : Int64.t;
107107+ uid : Int64.t;
108108+ gid : Int64.t;
109109+ mode : int;
110110+ ino : Int64.t;
111111+ size : Optint.Int63.t;
112112+ blocks : Int64.t;
113113+ attributes_mask : Int64.t;
114114+ atime : float;
115115+ btime : float;
116116+ ctime : float;
117117+ mtime : float;
118118+ rdev : Int64.t;
119119+ dev : Int64.t;
120120+ perm : int;
121121+ kind : kind;
122122+ mask : Int64.t;
123123+ }
124124+125125+ external create : unit -> internal = "ocaml_uring_make_statx"
126126+ external internal_to_t : internal -> t = "ocaml_uring_statx_internal_to_t"
127127+128128+ module Flags = struct
129129+ include Flags
130130+ include Config.Statx.Flags
131131+ end
132132+133133+ module Mask = struct
134134+ include Flags
135135+ include Config.Statx.Mask
136136+137137+ let check mask t =
138138+ let i = Int64.of_int t in
139139+ Int64.equal (Int64.logand mask i) i
140140+ end
141141+end
142142+89143module Sockaddr = struct
90144 type t
91145···239293 external submit_readv_fixed : t -> Unix.file_descr -> id -> Cstruct.buffer -> int -> int -> offset -> bool = "ocaml_uring_submit_readv_fixed_byte" "ocaml_uring_submit_readv_fixed_native" [@@noalloc]
240294 external submit_writev_fixed : t -> Unix.file_descr -> id -> Cstruct.buffer -> int -> int -> offset -> bool = "ocaml_uring_submit_writev_fixed_byte" "ocaml_uring_submit_writev_fixed_native" [@@noalloc]
241295 external submit_close : t -> Unix.file_descr -> id -> bool = "ocaml_uring_submit_close" [@@noalloc]
296296+ external submit_statx : t -> id -> Unix.file_descr -> Statx.internal -> Sketch.ptr -> int -> int -> bool = "ocaml_uring_submit_statx_byte" "ocaml_uring_submit_statx_native" [@@noalloc]
242297 external submit_splice : t -> id -> Unix.file_descr -> Unix.file_descr -> int -> bool = "ocaml_uring_submit_splice" [@@noalloc]
243298 external submit_connect : t -> id -> Unix.file_descr -> Sockaddr.t -> bool = "ocaml_uring_submit_connect" [@@noalloc]
244299 external submit_accept : t -> id -> Unix.file_descr -> Sockaddr.t -> bool = "ocaml_uring_submit_accept" [@@noalloc]
···424479425480let close t fd user_data =
426481 with_id t (fun id -> Uring.submit_close t.uring fd id) user_data
482482+483483+let statx t ?(fd=at_fdcwd) ~mask path statx flags user_data =
484484+ let spath = Sketch.String.alloc t.sketch path in
485485+ with_id_full t (fun id -> Uring.submit_statx t.uring id fd statx spath flags mask) user_data ~extra_data:statx
427486428487let splice t ~src ~dst ~len user_data =
429488 with_id t (fun id -> Uring.submit_splice t.uring id src dst len) user_data
+86
vendor/opam/uring/lib/uring/uring.mli
···225225 The operation returns the number of bytes transferred, or 0 for end-of-input.
226226 The result is [EINVAL] if the file descriptors don't support splicing. *)
227227228228+module Statx : sig
229229+ type internal
230230+ (** An internal type used to pass into {! statx}. *)
231231+232232+ type kind = [
233233+ | `Unknown
234234+ | `Fifo
235235+ | `Character_special
236236+ | `Directory
237237+ | `Block_device
238238+ | `Regular_file
239239+ | `Symbolic_link
240240+ | `Socket
241241+ ]
242242+243243+ type t = {
244244+ blksize : Int64.t;
245245+ attributes : Int64.t;
246246+ nlink : Int64.t;
247247+ uid : Int64.t;
248248+ gid : Int64.t;
249249+ mode : int;
250250+ ino : Int64.t;
251251+ size : Optint.Int63.t;
252252+ blocks : Int64.t;
253253+ attributes_mask : Int64.t;
254254+ atime : float;
255255+ btime : float;
256256+ ctime : float;
257257+ mtime : float;
258258+ rdev : Int64.t;
259259+ dev : Int64.t;
260260+ perm : int;
261261+ kind : kind;
262262+ mask : Int64.t;
263263+ } (** See statx(2). *)
264264+265265+ val create : unit -> internal
266266+ (** Use [create] to make an {! internal} statx struct to pass to {! statx}. *)
267267+268268+ val internal_to_t : internal -> t
269269+ (** Convert an internal statx struct to an OCaml value. This should only be called
270270+ after a successful completition of a {! statx} call. *)
271271+272272+ module Flags : sig
273273+ include FLAGS
274274+275275+ val empty : t
276276+ val empty_path : t
277277+ val no_automount : t
278278+ val symlink_nofollow : t
279279+ val statx_sync_as_stat : t
280280+ val statx_force_sync : t
281281+ val statx_dont_sync : t
282282+ end
283283+284284+ module Mask : sig
285285+ include FLAGS
286286+287287+ val type' : t
288288+ val mode : t
289289+ val nlink : t
290290+ val uid : t
291291+ val gid : t
292292+ val atime : t
293293+ val mtime : t
294294+ val ctime : t
295295+ val ino : t
296296+ val size : t
297297+ val blocks : t
298298+ val basic_stats : t (** All of the above flags. *)
299299+300300+ val btime : t
301301+302302+ val check : Int64.t -> t -> bool
303303+ (** [check mask t] checks if [t] is set in [mask]. *)
304304+ end
305305+end
306306+307307+val statx : 'a t -> ?fd:Unix.file_descr -> mask:Statx.Mask.t -> string -> Statx.internal -> Statx.Flags.t -> 'a -> 'a job option
308308+(** [statx t ?fd ~mask path stat flags] stats [path], which is resolved relative to [fd]
309309+ (or the current directory if [fd] is not given).
310310+311311+ Create a {! Statx.internal} using {! Statx.create} and after successful completion
312312+ of the job, convert it to {! Statx.t} using {! Statx.internal_to_t}. *)
313313+228314val connect : 'a t -> Unix.file_descr -> Unix.sockaddr -> 'a -> 'a job option
229315(** [connect t fd addr d] will submit a request to connect [fd] to [addr]. *)
230316