Page
Library
Module
Module type
Parameter
Class
Class type
Source
Eio_linux.Low_levelSourceLow-level API for using uring directly.
type fd := Eio_unix.Fd.tnoop () performs a uring noop. This is only useful for benchmarking.
sleep_until time blocks until the current time is time.
The size of the fixed buffer is set when calling Eio_linux.run, which attempts to allocate a fixed buffer. However, that may fail due to resource limits.
val openat :
sw:Eio.Std.Switch.t ->
?seekable:bool ->
access:[ `R | `W | `RW ] ->
flags:Uring.Open_flags.t ->
perm:Unix.file_perm ->
dir_fd ->
string ->
fdopenat ~sw ~access ~flags ~perm dir path opens dir/path.
val openat2 :
sw:Eio.Std.Switch.t ->
?seekable:bool ->
access:[ `R | `W | `RW ] ->
flags:Uring.Open_flags.t ->
perm:Unix.file_perm ->
resolve:Uring.Resolve.t ->
?dir:fd ->
string ->
fdopenat2 ~sw ~access ~flags ~perm ~resolve ~dir path opens dir/path.
It provides full access to the resolve flags. See Uring.openat2 for details.
read_upto fd chunk len reads at most len bytes from fd, returning as soon as some data is available.
read_exactly fd chunk len reads exactly len bytes from fd, performing multiple read operations if necessary.
readv is like read_upto but can read into any cstruct(s), not just chunks of the pre-shared buffer.
If multiple buffers are given, they are filled in order.
write fd buf len writes exactly len bytes from buf to fd.
It blocks until the OS confirms the write is done, and resubmits automatically if the OS doesn't write all of it at once.
writev is like write but can write from any cstruct(s), not just chunks of the pre-shared buffer.
If multiple buffers are given, they are sent in order. It will make multiple OS calls if the OS doesn't write all of it at once.
writev_single is like writev but only performs a single write operation. It returns the number of bytes written, which may be smaller than the requested amount.
splice src ~dst ~len attempts to copy up to len bytes of data from src to dst.
connect fd addr attempts to connect socket fd to addr.
await_readable fd blocks until fd is readable (or has an error).
await_writable fd blocks until fd is writable (or has an error).
Like Unix.LargeFile.fstat.
eio_of_statx x converts a statx buffer to a more portable stat record. The buffer should have been filled using at least Uring.Statx.Mask.basic_stats.
val statx :
mask:Uring.Statx.Mask.t ->
follow:bool ->
dir_fd ->
string ->
Uring.Statx.t ->
unitstatx ~mask ~follow dir path buf stats dir / path.
The results are written to buf. If follow = true and the item is a symlink, information is reported about the target of the link. Otherwise, information about the symlink itself is returned.
mkdir ~perm dir path creates directory dir / path.
read_link dir path reads the target of symlink dir / path.
unlink ~rmdir dir path removes directory entry dir / path.
If rmdir = true then the target must be a directory. Otherwise, it must not be a directory.
rename old_dir old_path new_dir new_path renames old_dir / old_path as new_dir / new_path.
symlink ~link_to dir path creates a new symlink at dir / path pointing to link_to.
chmod ~follow ~mode dir path changes the file mode bits of dir / path.
chown ~follow ~uid ~gid dir path changes the ownership of dir / path to uid, gid.
If follow = true and dir / path is a symlink, then the ownership of the target is changed. If it is false then the ownership of the symlink itself is changed.
pipe ~sw returns a pair r, w with the readable and writeable ends of a new pipe.
read_dir dir reads all directory entries from dir. The entries are not returned in any particular order (not even necessarily the order in which Linux returns them).
read_some_dir dir reads some of the directory entries from dir, including their kind. The entries are not returned in any particular order (not even necessarily the order in which Linux returns them).
Set and/or get the current file position.
Like Unix.lseek.
Flush file data to disk.
Like fsync, but does not wait for metadata that is not needed to read the data back. The aim is to reduce disk activity for callers that do not require all metadata to be synchronized with the disk.
val fallocate :
?mode:Uring.Fallocate_flags.t ->
fd ->
off:Optint.Int63.t ->
len:Optint.Int63.t ->
unitfallocate fd ~off ~len manipulates the disk space allocated for the len bytes of fd starting at off (the fallocate(2) call).
With the default mode (the empty set of flags) this allocates the region as for posix_fallocate(3), extending the file's size if needed. See Uring.Fallocate_flags for other modes, such as punching holes.
socket ~sw domain ty protocol creates a new socket, like Unix.socket.
The new socket has the close-on-exec flag set and is attached to sw. On Linux >= 5.19 this uses io_uring and on older kernels it falls back to a socket(2) call.
bind fd addr binds socket fd to addr, like Unix.bind.
On Linux >= 6.11 this uses io_uring and on older kernels falls back to a bind(2) call.
listen fd backlog marks socket fd as accepting connections, like Unix.listen.
On Linux >= 6.11 this uses io_uring and on older kernels falls back to a listen(2) call.
accept ~sw t blocks until a new connection is received on listening socket t.
It returns the new connection and the address of the connecting peer. The new connection has the close-on-exec flag set automatically. The new connection is attached to sw and will be closed when that finishes, if not already closed manually by then.
send_msg socket bufs is like writev socket bufs, but also allows setting the destination address (for unconnected sockets) and attaching FDs (for Unix-domain sockets).
recv_msg socket bufs is like readv socket bufs but also returns the address of the sender.
val recv_msg_with_fds :
sw:Eio.Std.Switch.t ->
max_fds:int ->
fd ->
Cstruct.t list ->
Uring.Sockaddr.t * int * fd listrecv_msg_with_fds is like recv_msg but also allows receiving up to max_fds file descriptors (sent using SCM_RIGHTS over a Unix domain socket).
setsockopt fd opt v sets socket option opt to value v on file descriptor fd.
getsockopt fd opt gets the value of socket option opt on file descriptor fd.
getrandom buf fills buf with random bytes.
It uses Linux's getrandom call, which is like reading from /dev/urandom except that it will block (the whole domain) if used at early boot when the random system hasn't been initialised yet.
getaddrinfo host returns a list of IP addresses for host. host is either a domain name or an ipaddress.