Module ExtUnixAll


module ExtUnixAll: sig .. end
ExtUnix

exception Not_available of string
Not_available "func" may be raised by ExtUnix.All.func if the wrapped C function is not available on this platform
val fsync : Unix.file_descr -> unit
val fdatasync : Unix.file_descr -> unit
val eventfd : int -> Unix.file_descr
val eventfd_read : Unix.file_descr -> int64
val eventfd_write : Unix.file_descr -> int64 -> unit
val dirfd : Unix.dir_handle -> Unix.file_descr

type statvfs = {
   f_bsize : int; (*file system block size*)
   f_blocks : int64; (*size of file system in blocks*)
   f_bfree : int64; (*free blocks*)
   f_bavail : int64; (*free blocks for unprivileged users*)
   f_files : int64; (*inodes*)
   f_ffree : int64; (*free inodes*)
   f_favail : int64; (*free inodes for unprivileged users*)
   f_fsid : int64; (*file system ID*)
   f_flag : int; (*mount flags*)
   f_namemax : int;
}
val statvfs : string -> statvfs
maximum filename length
val fstatvfs : Unix.file_descr -> statvfs

type at_flag =
| AT_EACCESS
| AT_SYMLINK_NOFOLLOW
| AT_REMOVEDIR
| AT_SYMLINK_FOLLOW
val openat : Unix.file_descr ->
string -> Unix.open_flag list -> Unix.file_perm -> Unix.file_descr
val fstatat : Unix.file_descr -> string -> Unix.stats
val unlinkat : Unix.file_descr -> string -> at_flag list -> unit
Supported flags : AT_REMOVEDIR
val renameat : Unix.file_descr -> string -> Unix.file_descr -> string -> unit
val mkdirat : Unix.file_descr -> string -> int -> unit
val linkat : Unix.file_descr ->
string -> Unix.file_descr -> string -> at_flag list -> unit
Supported flags : AT_SYMLINK_FOLLOW
val symlinkat : string -> Unix.file_descr -> string -> unit
module Uname: sig .. end
uname Author: Sylvain Le Gall sylvain@le-gall.net
val uname : unit -> Uname.t

type advice =
| POSIX_FADV_NORMAL (*Indicates that the application has no advice to give about its access pattern for the specified data.*)
| POSIX_FADV_SEQUENTIAL (*The application expects to access the specified data sequentially.*)
| POSIX_FADV_RANDOM (*The specified data will be accessed in random order.*)
| POSIX_FADV_NOREUSE (*The specified data will be accessed only once.*)
| POSIX_FADV_WILLNEED (*The specified data will be accessed in the near future.*)
| POSIX_FADV_DONTNEED

posix_fadvise

Author: Sylvain Le Gall


The specified data will not be accessed in the near future.
val fadvise : Unix.file_descr -> int -> int -> advice -> unit

posix_fallocate



Allocate disk space for file

Author: Sylvain Le Gall

val fallocate : Unix.file_descr -> int -> int -> unit
fallocate fd off len allocates disk space to ensure that subsequent writes between off and off + len in fd will not fail because of lack of disk space. The file size is modified if off + len is bigger than the current size.
module LargeFile: sig .. end
File operations on large files

ioctl


module Ioctl: sig .. end
Control the underlying device parameters of special files
val ttyname : Unix.file_descr -> string

Miscellaneous


val ctermid : unit -> string
Get controlling terminal name
val setpgid : int -> int -> unit
setpgid pid pgid sets the process group of the process specified by pid to pgid. If pid is zero, then the process ID of the calling process is used. If pgid is zero, then the PGID of the process specified by pid is made the same as its process ID.
val getpgid : int -> int
getpgid pid returns the PGID of the process specified by pid. If pid is zero, the process ID of the calling process is used.
val getsid : int -> int
getsid pid returns the session ID of the process specified by pid. If pid is zero, the process ID of the calling process is used.
val setreuid : int -> int -> unit
setreuid ruid euid sets real and effective user IDs of the calling process. Supplying a value of -1 for either the real or effective user ID forces the system to leave that ID unchanged.
See also setreuid(2) manual
val setregid : int -> int -> unit
setregid rgid egid sets real and effective group IDs of the calling process. Supplying a value of -1 for either the real or effective group ID forces the system to leave that ID unchanged.
See also setregid(2) manual
val realpath : string -> string
realpath path
Returns the canonicalized absolute pathname of path
See also realpath(2) manual
val is_open_descr : Unix.file_descr -> bool
Returns whether file desctiptor is open
val tcgetpgrp : Unix.file_descr -> int
val tcsetpgrp : Unix.file_descr -> int -> unit
val int_of_file_descr : Unix.file_descr -> int
Raises Not_available if OS does not represent file descriptors as numbers
val file_descr_of_int : int -> Unix.file_descr
Raises Not_available if OS does not represent file descriptors as numbers

signalfd



OCaml bindings for signalfd(2) and related functions

Author: Kaustuv Chaudhuri <kaustuv.chaudhuri@inria.fr>

val signalfd : ?fd:Unix.file_descr ->
sigs:int list -> flags:int list -> unit -> Unix.file_descr
signalfd ?fd sigs flags () If the first optional argument is omitted, then a new file descriptor is allocated. Otherwise, the given file descriptor is modified (in which case it must have been created with signalfd previously). When you are done with the fd, remember to Unix.close it. Do not forget to block sigs with Unix.sigprocmask to prevent signal handling according to default dispositions.
See also signalfd(2) manual
type ssi 
This type represents signal information that is read(2) from the signalfd.
val signalfd_read : Unix.file_descr -> ssi
Blocking read(2) on a signalfd. Has undefined behaviour on non-signalfds. Every successful read consumes a pending signal.

Functions to query the signal information structure.

val ssi_signo_sys : ssi -> int
Get the signal value. This form is compatible with the signal values defined in the standard Sys module.

See signalfd(2) for the details of the remaining functions. Most of these integers are actually unsigned.

val ssi_signo : ssi -> int32
val ssi_errno : ssi -> int32
val ssi_code : ssi -> int32
val ssi_pid : ssi -> int32
val ssi_uid : ssi -> int32
val ssi_fd : ssi -> Unix.file_descr
val ssi_tid : ssi -> int32
val ssi_band : ssi -> int32
val ssi_overrun : ssi -> int32
val ssi_trapno : ssi -> int32
val ssi_status : ssi -> int32
val ssi_int : ssi -> int32
val ssi_ptr : ssi -> int64
val ssi_utime : ssi -> int64
val ssi_stime : ssi -> int64
val ssi_addr : ssi -> int64
val ptrace_traceme : unit -> unit

ptrace


val ptrace_peekdata : int -> nativeint -> nativeint
val ptrace_peektext : int -> nativeint -> nativeint

type ptrace_request =
| PTRACE_ATTACH
| PTRACE_DETACH
val ptrace : int -> ptrace_request -> unit

type which_prio_t =
| PRIO_PROCESS of int (*Priority for a process id*)
| PRIO_PGRP of int (*Priority for a process group id*)
| PRIO_USER of int

POSIX resource operations

Author: Sylvain Le Gall <sylvain@le-gall.net>

type priority = int 
Priority for a user id

type resource =
| RLIMIT_CORE (*Limit on size of core dump file.*)
| RLIMIT_CPU (*Limit on CPU time per process.*)
| RLIMIT_DATA (*Limit on data segment size.*)
| RLIMIT_FSIZE (*Limit on file size.*)
| RLIMIT_NOFILE (*Limit on number of open files.*)
| RLIMIT_STACK (*Limit on stack size.*)
| RLIMIT_AS
val string_of_resource : resource -> string
Limit on address space size.
module Rlimit: sig .. end
Limits
val getpriority : which_prio_t -> priority
Get nice value
val setpriority : which_prio_t -> priority -> unit
Set nice value
val getrlimit : resource -> Rlimit.t * Rlimit.t
Get maximum resource consumption.
Returns (soft,hard) limits
val setrlimit : resource ->
soft:Rlimit.t -> hard:Rlimit.t -> unit
Set maximum resource consumption

getrusage is not implemented because the only meaningful information it provides are ru_utime and ru_stime which can be accessed through Unix.times.
val sys_exit : int -> 'a
Exit process without running any at_exit hooks (implemented in Pervasives)

type mlockall_flag =
| MCL_CURRENT
| MCL_FUTURE

Memory management


val mlockall : mlockall_flag list -> unit
Lock all pages mapped into the address space of the calling process.
val munlockall : unit -> unit
Unlock all pages mapped into the address space of the calling process.

Time conversion


val strptime : string -> string -> Unix.tm
This function is the converse of the ExtUnixAll.strftime function. strptime fmt data convert a string containing time information data into a tm struct according to the format specified by fmt.
val asctime : Unix.tm -> string
Return the ascii representation of a given tm argument. The ascii time is returned in the form of a string like 'Wed Jun 30, 21:21:21 2005\n'
val strftime : string -> Unix.tm -> string
This functions is the converse of the ExtUnixAll.strptime function. strftime fmt data convert a a tm structure data into a string according to the format specified by fmt.
val tzname : bool -> string
tzname isdst
Returns abbreviated name of the current timezone

Pseudo terminal management

Author: Niki Yoshiuchi <aplusbi@gmail.com>

val posix_openpt : Unix.open_flag list -> Unix.file_descr
This function opens a pseudo-terminal device.
val grantpt : Unix.file_descr -> unit
This function grants access to the slave pseudo-terminal.
val unlockpt : Unix.file_descr -> unit
This function unlock a pseudo-terminal master/slave pair.
val ptsname : Unix.file_descr -> string
This function get the name of the slave pseudo-terminal.

Application self-debugging


val backtrace : unit -> string array
Returns a backtrace for the calling program

Environment manipulation


val setenv : string -> string -> bool -> unit
setenv name value overwrite adds the variable name to the environment with the value value, if name does not already exist or overwrite is true
val unsetenv : string -> unit
unsetenv name removes variable name from the environment. If name does not exist in the environment, then the function succeeds, and the environment is unchanged.
val clearenv : unit -> unit
Clear the environment of all name-value pairs
val mkdtemp : string -> string
mkdtemp template creates a unique temporary directory (with permissions 0700). Last six characters of template must be "XXXXXX".

Meta


val have : string -> bool option
have name
Returns indication whether function name is available e.g. have "eventfd"