Eio_fs_unix.BatchSourceConfined directory operations, many to one system-thread hop.
Eio.Path makes one system-thread hop per operation, which dominates the cost of writing a large tree of small files. A batch runs a list of operations beneath one directory in a single hop and answers each one separately.
Every path is relative to the batch's directory. Native directories resolve one component at a time with openat(O_DIRECTORY | O_NOFOLLOW), as eio_posix resolves a path where the kernel has no RESOLVE_BENEATH. The confinement is stricter than Eio.Path's: an absolute path, an empty, . or .. component, a NUL byte, or a symbolic link before the last component is refused, never followed, so no operation reaches outside the directory. Descriptorless backends hold each Eio parent capability and verify its identity before descending. The last component is never followed either. The directories a run opens are held for the run only.
The type for a directory that batches run beneath.
v ~sw dir opens dir, resolved by Eio.Path's own confinement, and holds it until sw finishes. A wrapper of Eio_fs_chaos observes the open and the batch then runs beneath the directory it wraps. An already-open directory is held through its dot entry, without an empty open pathname. Descriptorless backends use Eio operations through held parent capabilities.
type op = | Mkdir of {}mkdirat(2) with perm, subject to the umask.
| Create of {}openat(2) with O_CREAT | O_EXCL | O_NOFOLLOW, every byte of contents written, then fchmod(2) to perm, so the umask does not apply. A failed write leaves the file holding what was written.
| Symlink of {}symlinkat(2); target is stored as given and never resolved.
| Unlink of {}unlinkat(2), with AT_REMOVEDIR iff dir.
| Rename of {}renameat(2); both paths are confined.
| Link of {}linkat(2) making dst a second name for src; both paths are confined, and a symbolic link at src is linked itself, never followed. Descriptorless backends refuse hard links.
| Lstat of stringfstatat(2) with AT_SYMLINK_NOFOLLOW.
The type for batch operations, each named after the system call that performs it beneath a native directory.
The type for the results of operations that succeeded.
type error = [ | `Refused of stringThe path names nothing beneath the directory; the string says why.
*)| `Unix of Unix.error * string * stringThe system call failed: its error, its name and its argument.
*) ]The type for the errors of operations that failed.