···109109 | _ -> assert false
110110 )
111111 in
112112- let at_flags, mask_flags =
112112+ let at_flags, mask_flags, attr_flags =
113113+ let new_flags =
114114+ C.C_define.Type.[
115115+ (* Masks *)
116116+ "STATX_MNT_ID", Int;
117117+ "STATX_DIOALIGN", Int;
118118+ (* File Attributes *)
119119+ "STATX_ATTR_VERITY", Int;
120120+ "STATX_ATTR_DAX", Int;
121121+ ]
122122+ in
123123+ let new_flag_prelude =
124124+ let def_flag = function
125125+ | name, C.C_define.Type.Int ->
126126+ Printf.sprintf "#ifndef %s\n#define %s 0\n#endif\n" name name;
127127+ | _ -> assert false
128128+ in
129129+ String.concat "" (List.map def_flag new_flags)
130130+ in
113131 C.C_define.import c ~c_flags:["-D_GNU_SOURCE"; "-I"; Filename.concat (Sys.getcwd ()) "include"]
114114- ~prelude:{|#include <sys/stat.h>
132132+ ~prelude:({|#include <sys/stat.h>
115133#ifndef STATX_TYPE
116134#include <linux/stat.h>
117117-#endif|}
135135+#endif
136136+|} ^ new_flag_prelude)
118137 ~includes:["fcntl.h" ]
119119- C.C_define.Type.[
138138+ (C.C_define.Type.[
120139 "AT_EMPTY_PATH", Int;
121140 "AT_NO_AUTOMOUNT", Int;
122141 "AT_SYMLINK_NOFOLLOW", Int;
···137156 "STATX_BLOCKS", Int;
138157 "STATX_BASIC_STATS", Int;
139158 "STATX_BTIME", Int;
140140- ]
141141- |> List.fold_left (fun (ats, stats) (v, k) -> match String.split_on_char '_' v, k with
159159+160160+ "STATX_ATTR_COMPRESSED", Int;
161161+ "STATX_ATTR_IMMUTABLE", Int;
162162+ "STATX_ATTR_APPEND", Int;
163163+ "STATX_ATTR_NODUMP", Int ;
164164+ "STATX_ATTR_ENCRYPTED", Int;
165165+ ] @ new_flags)
166166+ |> List.fold_left (fun (ats, stats, attrs) (v, k) -> match String.split_on_char '_' v, k with
142167 | "AT" :: name, C.C_define.Value.Int v ->
143168 let ocaml_name = String.lowercase_ascii (String.concat "_" name) in
144144- ((ocaml_name, v) :: ats, stats)
169169+ ((ocaml_name, v) :: ats, stats, attrs)
170170+ | "STATX" :: "ATTR" :: name, C.C_define.Value.Int v ->
171171+ let name = String.concat "_" name |> String.lowercase_ascii in
172172+ let ocaml_name = match name with
173173+ | "type" -> "type'"
174174+ | v -> v
175175+ in
176176+ (ats, stats, (ocaml_name, v) :: attrs)
145177 | "STATX" :: name, C.C_define.Value.Int v ->
146178 let name = String.concat "_" name |> String.lowercase_ascii in
147179 let ocaml_name = match name with
148180 | "type" -> "type'"
149181 | v -> v
150182 in
151151- (ats, (ocaml_name, v) :: stats)
183183+ (ats, (ocaml_name, v) :: stats, attrs)
152184 | _ -> assert false
153153- ) ([], [])
185185+ ) ([], [], [])
154186 in
155187 let op_sig = List.map (fun (name, _) -> Printf.sprintf " val %s : t" name) ops in
156188 let op_struct = List.map (fun (name, v) -> Printf.sprintf " let %s = 0x%x" name v) ops in
157189 let at_struct = List.map (fun (name, v) -> Printf.sprintf " let %s = 0x%x" name v) at_flags in
158190 let mask_struct = List.map (fun (name, v) -> Printf.sprintf " let %s = 0x%x" name v) mask_flags in
191191+ let attr_struct = List.map (fun (name, v) -> Printf.sprintf " let %s = 0x%x" name v) attr_flags in
159192 C.Flags.write_lines "config.ml"
160193 (defs @
161194 ["module Op : sig";
···172205 " end";
173206 " module Mask = struct";
174207 ] @ mask_struct @ [
208208+ " end";
209209+ " module Attr = struct";
210210+ ] @ attr_struct @ [
175211 " end";
176212 "end"
177213 ])
+55-25
vendor/opam/uring/lib/uring/uring.ml
···8787end
88888989module Statx = struct
9090- type internal
9090+ type t
91919292 type kind = [
9393 | `Unknown
···100100 | `Socket
101101 ]
102102103103- 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- }
103103+ let pp_kind f k =
104104+ Fmt.pf f "%s"
105105+ (match k with
106106+ |`Unknown -> "unknown"
107107+ |`Fifo -> "fifo"
108108+ |`Character_special -> "character special file"
109109+ |`Directory -> "directory"
110110+ |`Block_device -> "block device"
111111+ |`Regular_file -> "regular file"
112112+ |`Symbolic_link -> "symbolic link"
113113+ |`Socket -> "socket")
124114125125- external create : unit -> internal = "ocaml_uring_make_statx"
126126- external internal_to_t : internal -> t = "ocaml_uring_statx_internal_to_t"
115115+ external create : unit -> t = "ocaml_uring_make_statx"
127116128117 module Flags = struct
129118 include Flags
130119 include Config.Statx.Flags
131120 end
132121122122+ module Attr = struct
123123+ include Flags
124124+ include Config.Statx.Attr
125125+126126+ let check ?mask attr t =
127127+ let i = Int64.of_int t in
128128+ (match mask with Some m -> if Int64.equal (Int64.logand m i) i then invalid_arg "Attribute not supported" | _ -> ());
129129+ Int64.equal (Int64.logand attr i) i
130130+ end
131131+133132 module Mask = struct
134133 include Flags
135134 include Config.Statx.Mask
···138137 let i = Int64.of_int t in
139138 Int64.equal (Int64.logand mask i) i
140139 end
140140+141141+ external blksize : t -> (int64 [@unboxed]) = "ocaml_uring_statx_blksize_bytes" "ocaml_uring_statx_blksize_native" [@@noalloc]
142142+ external attributes : t -> (int64 [@unboxed]) = "ocaml_uring_statx_attributes_bytes" "ocaml_uring_statx_attributes_native" [@@noalloc]
143143+ external nlink : t -> (int64 [@unboxed]) = "ocaml_uring_statx_nlink_bytes" "ocaml_uring_statx_nlink_native" [@@noalloc]
144144+ external uid : t -> (int64 [@unboxed]) = "ocaml_uring_statx_uid_bytes" "ocaml_uring_statx_uid_native" [@@noalloc]
145145+ external gid : t -> (int64 [@unboxed]) = "ocaml_uring_statx_gid_bytes" "ocaml_uring_statx_gid_native" [@@noalloc]
146146+ external ino : t -> (int64 [@unboxed]) = "ocaml_uring_statx_ino_bytes" "ocaml_uring_statx_ino_native" [@@noalloc]
147147+ external size : t -> (int64 [@unboxed]) = "ocaml_uring_statx_size_bytes" "ocaml_uring_statx_size_native" [@@noalloc]
148148+ external blocks : t -> (int64 [@unboxed]) = "ocaml_uring_statx_blocks_bytes" "ocaml_uring_statx_blocks_native" [@@noalloc]
149149+ external attributes_mask : t -> (int64 [@unboxed]) = "ocaml_uring_statx_attributes_mask_bytes" "ocaml_uring_statx_attributes_mask_native" [@@noalloc]
150150+ external rdev : t -> (int64 [@unboxed]) = "ocaml_uring_statx_rdev_bytes" "ocaml_uring_statx_rdev_native" [@@noalloc]
151151+ external dev : t -> (int64 [@unboxed]) = "ocaml_uring_statx_dev_bytes" "ocaml_uring_statx_dev_native" [@@noalloc]
152152+ external mask : t -> (int64 [@unboxed]) = "ocaml_uring_statx_mask_bytes" "ocaml_uring_statx_mask_native" [@@noalloc]
153153+ external mnt_id : t -> (int64 [@unboxed]) = "ocaml_uring_statx_mnt_id_bytes" "ocaml_uring_statx_mnt_id_native" [@@noalloc]
154154+ external dio_mem_align : t -> (int64 [@unboxed]) = "ocaml_uring_statx_dio_mem_align_bytes" "ocaml_uring_statx_dio_mem_align_native" [@@noalloc]
155155+ external dio_offset_align : t -> (int64 [@unboxed]) = "ocaml_uring_statx_dio_offset_align_bytes" "ocaml_uring_statx_dio_offset_align_native" [@@noalloc]
156156+157157+ external atime_sec : t -> (int64 [@unboxed]) = "ocaml_uring_statx_atime_sec_bytes" "ocaml_uring_statx_atime_sec_native" [@@noalloc]
158158+ external btime_sec : t -> (int64 [@unboxed]) = "ocaml_uring_statx_btime_sec_bytes" "ocaml_uring_statx_btime_sec_native" [@@noalloc]
159159+ external ctime_sec : t -> (int64 [@unboxed]) = "ocaml_uring_statx_ctime_sec_bytes" "ocaml_uring_statx_ctime_sec_native" [@@noalloc]
160160+ external mtime_sec : t -> (int64 [@unboxed]) = "ocaml_uring_statx_mtime_sec_bytes" "ocaml_uring_statx_mtime_sec_native" [@@noalloc]
161161+162162+ external atime_nsec : t -> int = "ocaml_uring_statx_atime_nsec" [@@noalloc]
163163+ external btime_nsec : t -> int = "ocaml_uring_statx_btime_nsec" [@@noalloc]
164164+ external ctime_nsec : t -> int = "ocaml_uring_statx_ctime_nsec" [@@noalloc]
165165+ external mtime_nsec : t -> int = "ocaml_uring_statx_mtime_nsec" [@@noalloc]
166166+167167+ external mode : t -> (int [@untagged]) = "ocaml_uring_statx_mode_bytes" "ocaml_uring_statx_mode_native" [@@noalloc]
168168+ external perm : t -> (int [@untagged]) = "ocaml_uring_statx_perm_bytes" "ocaml_uring_statx_perm_native" [@@noalloc]
169169+170170+ external kind : t -> kind = "ocaml_uring_statx_kind"
141171end
142172143173module Sockaddr = struct
···293323 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]
294324 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]
295325 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]
326326+ external submit_statx : t -> id -> Unix.file_descr -> Statx.t -> Sketch.ptr -> int -> int -> bool = "ocaml_uring_submit_statx_byte" "ocaml_uring_submit_statx_native" [@@noalloc]
297327 external submit_splice : t -> id -> Unix.file_descr -> Unix.file_descr -> int -> bool = "ocaml_uring_submit_splice" [@@noalloc]
298328 external submit_connect : t -> id -> Unix.file_descr -> Sockaddr.t -> bool = "ocaml_uring_submit_connect" [@@noalloc]
299329 external submit_accept : t -> id -> Unix.file_descr -> Sockaddr.t -> bool = "ocaml_uring_submit_accept" [@@noalloc]
+73-34
vendor/opam/uring/lib/uring/uring.mli
···226226 The result is [EINVAL] if the file descriptors don't support splicing. *)
227227228228module Statx : sig
229229- type internal
230230- (** An internal type used to pass into {! statx}. *)
229229+ type t
230230+ (** A statx struct. *)
231231232232 type kind = [
233233 | `Unknown
···240240 | `Socket
241241 ]
242242243243- 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}. *)
243243+ val pp_kind : kind Fmt.t
267244268268- 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. *)
245245+ val create : unit -> t
246246+ (** Use [create] to make a statx result buffer to pass to {! statx}. *)
271247272248 module Flags : sig
273249 include FLAGS
···279255 val statx_sync_as_stat : t
280256 val statx_force_sync : t
281257 val statx_dont_sync : t
258258+ end
259259+260260+ module Attr : sig
261261+ include FLAGS
262262+263263+ val compressed : t
264264+ val immutable : t
265265+ val append : t
266266+ val nodump : t
267267+ val encrypted : t
268268+ val verity : t
269269+270270+ val dax : t
271271+ (** Since Linux 5.8 *)
272272+273273+ val check : ?mask:Int64.t -> Int64.t -> t -> bool
274274+ (** [check ?mask attr t] will check if [t] is set in [attr].
275275+276276+ If [mask] is not [None] then it will first check the mask to see
277277+ if the file attribute is supported and if not raise [Invalid_argument]. *)
282278 end
283279284280 module Mask : sig
···299295300296 val btime : t
301297298298+ val mnt_id : t
299299+ (** As of Linux 5.8 *)
300300+301301+ val dioalign : t
302302+ (** As of Linux 6.1 *)
303303+302304 val check : Int64.t -> t -> bool
303305 (** [check mask t] checks if [t] is set in [mask]. *)
304306 end
307307+308308+ (** You may wish to use {! Mask.check} to verify the field has actually
309309+ been returned with a sensible value first. *)
310310+311311+ val blksize : t -> Int64.t
312312+ val attributes : t -> Int64.t
313313+ val nlink : t -> Int64.t
314314+ val uid : t -> Int64.t
315315+ val gid : t -> Int64.t
316316+ val ino : t -> Int64.t
317317+ val size : t -> Int64.t
318318+ val blocks : t -> Int64.t
319319+ val attributes_mask : t -> Int64.t
320320+ val rdev : t -> Int64.t
321321+ val dev : t -> Int64.t
322322+ val mask : t -> Int64.t
323323+324324+ val mnt_id : t -> Int64.t
325325+ (** See {! Mask.mnt_id}. *)
326326+327327+ val dio_mem_align : t -> Int64.t
328328+ (** See {! Mask.dioalign}. *)
329329+330330+ val dio_offset_align : t -> Int64.t
331331+ (** See {! Mask.dioalign}. *)
332332+333333+ val atime_sec : t -> int64
334334+ val btime_sec : t -> int64
335335+ val ctime_sec : t -> int64
336336+ val mtime_sec : t -> int64
337337+338338+ val atime_nsec : t -> int
339339+ val btime_nsec : t -> int
340340+ val ctime_nsec : t -> int
341341+ val mtime_nsec : t -> int
342342+343343+ val mode : t -> int
344344+ val perm : t -> int
345345+346346+ val kind : t -> kind
305347end
306348307307-val statx : 'a t -> ?fd:Unix.file_descr -> mask:Statx.Mask.t -> string -> Statx.internal -> Statx.Flags.t -> 'a -> 'a job option
349349+val statx : 'a t -> ?fd:Unix.file_descr -> mask:Statx.Mask.t -> string -> Statx.t -> Statx.Flags.t -> 'a -> 'a job option
308350(** [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}. *)
351351+ (or the current directory if [fd] is not given). *)
313352314353val connect : 'a t -> Unix.file_descr -> Unix.sockaddr -> 'a -> 'a job option
315354(** [connect t fd addr d] will submit a request to connect [fd] to [addr]. *)