platform/posix
Target scope is enforced by the module assertion below.
POSIX's facilities in Landin types, on Linux, Darwin and FreeBSD alike.
A descriptor is a handle type, not a number to count with, so descriptors compare with == and nothing else; standard_input, standard_output and standard_error are 0, 1 and 2, and working_directory is the directory an *_at call's relative path starts from. A failure is the errno as an atom of errno, one atom for each errno the three systems define, named after its C macro in lower case, enoent and eintr among them; number gives the number this system uses for an atom and errno_of the atom for a number, and unlisted is a failure with no errno this module names. A path or an argument is a host string, which the module copies into a buffer of the system's PATH_MAX with the NUL a C call needs, refusing one that holds a NUL with einval and one too long with enametoolong. The calls are POSIX's own, not policy: open_at with open_options (reading and writing are the two the hosted provider uses), read, write, close, status_at for a structured status of device, inode, kind and size, open_directory, read_directory and close_directory over a caller's buffer, listing . and .. as POSIX does, make_directory_at, unlink_at and remove_directory_at, map and unmap for anonymous memory and page_size, exit, and poll over entries made by watch and read by happened, whose poll_events is a distinct flag set: poll_input, poll_output and poll_urgent are asked about, poll_error, poll_hung_up and poll_invalid only reported, combined with | and tested with & against poll_no_events. An interrupted call fails with eintr and is not retried here, and a short transfer is returned as it came. The process's arguments are its root, established by _landin_host_initialize_arguments and read through arguments and argument. It is written twice beneath its interface, over platform/linux's system calls and over platform/libc, and a system that is not POSIX, as Windows is not, has none.
compiler.assert(compiler.os == linux or compiler.os == darwin
or compiler.os == freebsd)Items
- access type
- argument_table type
- descriptor type
- directory_entry type
- directory_stream type
- errno type
- file_kind type
- open_options type
- poll_entry type
- poll_events type
- status type
- block_device atom
- character_device atom
- directory atom
- e2big atom
- eacces atom
- eaddrinuse atom
- eaddrnotavail atom
- eadv atom
- eafnosupport atom
- eagain atom
- ealready atom
- eauth atom
- ebadarch atom
- ebade atom
- ebadexec atom
- ebadf atom
- ebadfd atom
- ebadmacho atom
- ebadmsg atom
- ebadr atom
- ebadrpc atom
- ebadrqc atom
- ebadslt atom
- ebfont atom
- ebusy atom
- ecanceled atom
- ecapmode atom
- echild atom
- echrng atom
- ecomm atom
- econnaborted atom
- econnrefused atom
- econnreset atom
- edeadlk atom
- edestaddrreq atom
- edeverr atom
- edom atom
- edoofus atom
- edotdot atom
- edquot atom
- eexist atom
- efault atom
- efbig atom
- eftype atom
- ehostdown atom
- ehostunreach atom
- ehwpoison atom
- eidrm atom
- eilseq atom
- einprogress atom
- eintegrity atom
- eintr atom
- einval atom
- eio atom
- eisconn atom
- eisdir atom
- eisnam atom
- ekeyexpired atom
- ekeyrejected atom
- ekeyrevoked atom
- el2hlt atom
- el2nsync atom
- el3hlt atom
- el3rst atom
- elibacc atom
- elibbad atom
- elibexec atom
- elibmax atom
- elibscn atom
- elnrng atom
- eloop atom
- emediumtype atom
- emfile atom
- emlink atom
- emsgsize atom
- emultihop atom
- enametoolong atom
- enavail atom
- eneedauth atom
- enetdown atom
- enetreset atom
- enetunreach atom
- enfile atom
- enoano atom
- enoattr atom
- enobufs atom
- enocsi atom
- enodata atom
- enodev atom
- enoent atom
- enoexec atom
- enokey atom
- enolck atom
- enolink atom
- enomedium atom
- enomem atom
- enomsg atom
- enonet atom
- enopkg atom
- enopolicy atom
- enoprotoopt atom
- enospc atom
- enosr atom
- enostr atom
- enosys atom
- enotblk atom
- enotcapable atom
- enotconn atom
- enotdir atom
- enotempty atom
- enotnam atom
- enotrecoverable atom
- enotsock atom
- enotsup atom
- enotty atom
- enotuniq atom
- enxio atom
- eopnotsupp atom
- eoverflow atom
- eownerdead atom
- eperm atom
- epfnosupport atom
- epipe atom
- eproclim atom
- eprocunavail atom
- eprogmismatch atom
- eprogunavail atom
- eproto atom
- eprotonosupport atom
- eprototype atom
- epwroff atom
- eqfull atom
- erange atom
- eremchg atom
- eremote atom
- eremoteio atom
- erestart atom
- erfkill atom
- erofs atom
- erpcmismatch atom
- eshlibvers atom
- eshutdown atom
- esocktnosupport atom
- espipe atom
- esrch atom
- esrmnt atom
- estale atom
- estrpipe atom
- etime atom
- etimedout atom
- etoomanyrefs atom
- etxtbsy atom
- euclean atom
- eunatch atom
- eusers atom
- exdev atom
- exfull atom
- fifo atom
- read_only atom
- read_write atom
- regular atom
- socket_file atom
- symbolic_link atom
- unknown_kind atom
- unlisted atom
- write_only atom
- directory_buffer value
- poll_error value
- poll_hung_up value
- poll_input value
- poll_invalid value
- poll_no_events value
- poll_output value
- poll_urgent value
- reading value
- standard_error value
- standard_input value
- standard_output value
- working_directory value
- writing value
- _landin_host_initialize_arguments function
- argument function
- arguments function
- close function
- close_directory function
- errno_of function
- exit function
- happened function
- make_directory_at function
- map function
- number function
- open_at function
- open_directory function
- page_size function
- poll function
- read function
- read_directory function
- remove_directory_at function
- status_at function
- unlink_at function
- unmap function
- watch function
- write function
Executable example
This complete program is maintained in the repository runtime tests. View source.
-- platform/posix's files: a descriptor is a handle, a failure is the -- errno as an atom, and a path is a host string, terminated beneath the -- caller. The program makes a scratch directory, opens a file in it -- relative to the directory's own descriptor, writes and reads it back, -- asks its status, and removes both. Each failure is the errno POSIX -- names for it, the same atom on Linux, Darwin and FreeBSD: a missing -- name, an exclusive create of a taken one, a file used as a directory, a -- directory opened for writing, a closed descriptor, a path holding a NUL -- and one longer than PATH_MAX. The program writes each atom's number -- on this system, so a failing lane shows what it met. import core/text import platform/posix top: []u8 = "posix-files-scratch" inner: []u8 = "posix-files-scratch/data" -- Write LINE to standard output. say: (line: []u8) -> none = _ = posix.write(posix.standard_output, line) else 0 end say -- Write NAME, `=` and the number PROBLEM has on this system. said: (name: []u8, problem: posix.errno) -> none = mut line: [32]u8 = zeroed mut used: usize = 0 for byte in name do line[used] = byte inc used end for line[used] = 61 inc used used = text.write_u32(line[0..<32], used, u32(posix.number(problem))) else used line[used] = 10 say(line[0..<used + 1]) end said -- Remove what an earlier run may have left. clear: () -> none = posix.unlink_at(posix.working_directory, text.host_over(inner)) else (p) _ = p end posix.remove_directory_at(posix.working_directory, text.host_over(top)) else (p) _ = p end end clear -- Whether opening PATH with OPTIONS, relative to AT, fails with WANTED. refused: (at: posix.descriptor, path: text.host_string, options: posix.open_options, wanted: posix.errno, name: []u8) -> (yes: bool) = yes = false opened: posix.descriptor = posix.open_at(at, path, options, 0o644) else (problem) said(name, problem) yes = problem == wanted return end posix.close(opened) else (p) _ = p end end refused public main: () -> (code: i32) = clear() code = 1 posix.make_directory_at(posix.working_directory, text.host_over(top), 0o755) else (problem) said("mkdir", problem) return end code = 2 folder: posix.descriptor = posix.open_at(posix.working_directory, text.host_over(top), (access: posix.read_only, create: false, exclusive: false, truncate: false, append: false, directory: true), 0) else (problem) said("folder", problem) return end -- A file made relative to the directory's descriptor, written and -- read back through a second descriptor. code = 3 written: posix.descriptor = posix.open_at(folder, text.host_over("data"), posix.writing, 0o644) else (problem) said("create", problem) return end count: usize = posix.write(written, "posix\n") else (problem) said("write", problem) return end return when count <> 6 posix.close(written) else (problem) said("close", problem) return end code = 4 reading: posix.descriptor = posix.open_at(posix.working_directory, text.host_over(inner), posix.reading, 0) else (problem) said("open", problem) return end mut buffer: [16]u8 = zeroed got: usize = posix.read(reading, buffer[0..<16]) else (problem) said("read", problem) return end return when got <> 6 or buffer[0] <> 112 or buffer[5] <> 10 ended: usize = posix.read(reading, buffer[0..<16]) else (problem) said("eof", problem) return end return when ended <> 0 posix.close(reading) else (problem) said("close", problem) return end -- Its status: a regular file of six bytes, the same file by either -- path, inside a directory. code = 5 file: posix.status = posix.status_at(folder, text.host_over("data"), false) else (problem) said("stat", problem) return end again: posix.status = posix.status_at(posix.working_directory, text.host_over(inner), true) else (problem) said("stat", problem) return end holder: posix.status = posix.status_at(posix.working_directory, text.host_over(top), true) else (problem) said("stat", problem) return end return when file.kind <> posix.regular or file.size <> 6 or file.device <> again.device or file.inode <> again.inode or holder.kind <> posix.directory or holder.inode == file.inode -- The failure oracles. code = 6 return when not refused(folder, text.host_over("absent"), posix.reading, posix.enoent, "absent") code = 7 return when not refused(folder, text.host_over("data"), (access: posix.write_only, create: true, exclusive: true, truncate: false, append: false, directory: false), posix.eexist, "exclusive") code = 8 return when not refused(folder, text.host_over("data/below"), posix.reading, posix.enotdir, "through") code = 9 return when not refused(posix.working_directory, text.host_over(top), posix.writing, posix.eisdir, "directory") code = 10 return when not refused(posix.working_directory, text.host_over("posix\x00files"), posix.reading, posix.einval, "nul") code = 11 long: [5000]u8 = [5000 of 97] return when not refused(posix.working_directory, text.host_over(long[0..<5000]), posix.reading, posix.enametoolong, "long") code = 12 _ = posix.read(reading, buffer[0..<16]) else (problem) said("closed", problem) return when problem <> posix.ebadf 0 end code = 13 posix.close(folder) else (problem) said("close", problem) return end posix.unlink_at(posix.working_directory, text.host_over(inner)) else (problem) said("unlink", problem) return end posix.remove_directory_at(posix.working_directory, text.host_over(top)) else (problem) said("rmdir", problem) return end code = 42 end main
access type
public access: type = read_only | write_only | read_writeHow an open file may be used: read_only, write_only or read_write.
argument_table type
public argument_table: type = struct
values: ptr ptr u8
count: usize
end argument_tableThe process's arguments as its entry gave them: argv after argv[0] and their count. arguments gives the table, which lends what it points to from storage the process keeps, and argument reads it.
descriptor type
public descriptor: type = descriptor_valueAn open file's descriptor: a handle the system gives, which names one open file until it is closed. It is a handle and not a number to count with; descriptor(n) and i32(d) convert at a C boundary.
directory_entry type
public directory_entry: type = struct
name: text.host_string
kind: file_kind
end directory_entryAn entry of a directory: its name, lent from the buffer it was read into until the next read, and its kind, unknown_kind where the file system records none.
directory_stream type
public directory_stream: type = struct
descriptor: descriptor
stream: usize
filled: usize
cursor: usize
finished: bool
end directory_streamAn open directory stream, POSIX's DIR: a value its caller keeps and passes inout to read_directory, with the same buffer each time. Its fields belong to this module: the directory's descriptor, the C library's stream where there is one, and how much of the buffer the system has filled and the caller has read.
errno type
public errno: type = eperm | enoent | esrch | eintr | eio | enxio | e2bigEvery failure a POSIX call here reports: the errno it failed with, as an atom, or unlisted. number gives the errno's number on this system and errno_of the atom for a number.
file_kind type
public file_kind: type = regular | directory | symbolic_link | fifoWhat a file is.
open_options type
public open_options: type = struct
access: access
create: bool
exclusive: bool
truncate: bool
append: bool
directory: bool
end open_optionsHow open_at opens a file: its access, and whether to create it when it is missing, refuse it when it exists (exclusive, with create), truncate it, append every write to its end, or refuse anything that is not a directory with enotdir.
poll_entry type
public poll_entry: type = poll_recordOne descriptor for poll to watch and the events asked about, made by watch, and after the call what happened, which happened reads.
poll_events type
public poll_events: type = events_valuePoll events, POSIX's poll bits as a set: a value combines with |, & and ~ and compares with == and <>. poll_input, poll_output and poll_urgent are what an entry can ask about; poll_error, poll_hung_up and poll_invalid are only ever reported. The bits are the same on Linux, Darwin and FreeBSD.
status type
public status: type = struct
device: u64
inode: u64
kind: file_kind
size: u64
end statusA file's status, POSIX's stat: the device and inode that identify it, what it is and its size in bytes. On Linux the device is the kernel's major number in the upper 32 bits and its minor in the lower, as statx reports them; elsewhere it is the system's st_dev. Two paths name the same file when both identify it alike.
block_device atom
public block_device: atomA block device.
character_device atom
public character_device: atomA character device.
directory atom
public directory: atomA directory.
e2big atom
public e2big: atomerrno E2BIG: Argument list too long.
eacces atom
public eacces: atomerrno EACCES: Permission denied.
eaddrinuse atom
public eaddrinuse: atomerrno EADDRINUSE: Address already in use.
eaddrnotavail atom
public eaddrnotavail: atomerrno EADDRNOTAVAIL: Cannot assign requested address.
eadv atom
public eadv: atomerrno EADV: Advertise error.
eafnosupport atom
public eafnosupport: atomerrno EAFNOSUPPORT: Address family not supported by protocol.
eagain atom
public eagain: atomerrno EAGAIN: Try again.
ealready atom
public ealready: atomerrno EALREADY: Operation already in progress.
eauth atom
public eauth: atomerrno EAUTH: Authentication error.
ebadarch atom
public ebadarch: atomerrno EBADARCH: Bad CPU type in executable.
ebade atom
public ebade: atomerrno EBADE: Invalid exchange.
ebadexec atom
public ebadexec: atomerrno EBADEXEC: Bad executable (or shared library).
ebadf atom
public ebadf: atomerrno EBADF: Bad file number.
ebadfd atom
public ebadfd: atomerrno EBADFD: File descriptor in bad state.
ebadmacho atom
public ebadmacho: atomerrno EBADMACHO: Malformed Mach-o file.
ebadmsg atom
public ebadmsg: atomerrno EBADMSG: Not a data message.
ebadr atom
public ebadr: atomerrno EBADR: Invalid request descriptor.
ebadrpc atom
public ebadrpc: atomerrno EBADRPC: RPC struct is bad.
ebadrqc atom
public ebadrqc: atomerrno EBADRQC: Invalid request code.
ebadslt atom
public ebadslt: atomerrno EBADSLT: Invalid slot.
ebfont atom
public ebfont: atomerrno EBFONT: Bad font file format.
ebusy atom
public ebusy: atomerrno EBUSY: Device or resource busy.
ecanceled atom
public ecanceled: atomerrno ECANCELED: Operation Canceled.
ecapmode atom
public ecapmode: atomerrno ECAPMODE: Not permitted in capability mode.
echild atom
public echild: atomerrno ECHILD: No child processes.
echrng atom
public echrng: atomerrno ECHRNG: Channel number out of range.
ecomm atom
public ecomm: atomerrno ECOMM: Communication error on send.
econnaborted atom
public econnaborted: atomerrno ECONNABORTED: Software caused connection abort.
econnrefused atom
public econnrefused: atomerrno ECONNREFUSED: Connection refused.
econnreset atom
public econnreset: atomerrno ECONNRESET: Connection reset by peer.
edeadlk atom
public edeadlk: atomerrno EDEADLK: Resource deadlock would occur.
edestaddrreq atom
public edestaddrreq: atomerrno EDESTADDRREQ: Destination address required.
edeverr atom
public edeverr: atomerrno EDEVERR: Device error.
edom atom
public edom: atomerrno EDOM: Math argument out of domain of func.
edoofus atom
public edoofus: atomerrno EDOOFUS: Programming error.
edotdot atom
public edotdot: atomerrno EDOTDOT: RFS specific error.
edquot atom
public edquot: atomerrno EDQUOT: Quota exceeded.
eexist atom
public eexist: atomerrno EEXIST: File exists.
efault atom
public efault: atomerrno EFAULT: Bad address.
efbig atom
public efbig: atomerrno EFBIG: File too large.
eftype atom
public eftype: atomerrno EFTYPE: Inappropriate file type or format.
ehostdown atom
public ehostdown: atomerrno EHOSTDOWN: Host is down.
ehostunreach atom
public ehostunreach: atomerrno EHOSTUNREACH: No route to host.
ehwpoison atom
public ehwpoison: atomerrno EHWPOISON: Memory page has hardware error.
eidrm atom
public eidrm: atomerrno EIDRM: Identifier removed.
eilseq atom
public eilseq: atomerrno EILSEQ: Illegal byte sequence.
einprogress atom
public einprogress: atomerrno EINPROGRESS: Operation now in progress.
eintegrity atom
public eintegrity: atomerrno EINTEGRITY: Integrity check failed.
eintr atom
public eintr: atomerrno EINTR: Interrupted system call.
einval atom
public einval: atomerrno EINVAL: Invalid argument.
eio atom
public eio: atomerrno EIO: I/O error.
eisconn atom
public eisconn: atomerrno EISCONN: Transport endpoint is already connected.
eisdir atom
public eisdir: atomerrno EISDIR: Is a directory.
eisnam atom
public eisnam: atomerrno EISNAM: Is a named type file.
ekeyexpired atom
public ekeyexpired: atomerrno EKEYEXPIRED: Key has expired.
ekeyrejected atom
public ekeyrejected: atomerrno EKEYREJECTED: Key was rejected by service.
ekeyrevoked atom
public ekeyrevoked: atomerrno EKEYREVOKED: Key has been revoked.
el2hlt atom
public el2hlt: atomerrno EL2HLT: Level 2 halted.
el2nsync atom
public el2nsync: atomerrno EL2NSYNC: Level 2 not synchronized.
el3hlt atom
public el3hlt: atomerrno EL3HLT: Level 3 halted.
el3rst atom
public el3rst: atomerrno EL3RST: Level 3 reset.
elibacc atom
public elibacc: atomerrno ELIBACC: Can not access a needed shared library.
elibbad atom
public elibbad: atomerrno ELIBBAD: Accessing a corrupted shared library.
elibexec atom
public elibexec: atomerrno ELIBEXEC: Cannot exec a shared library directly.
elibmax atom
public elibmax: atomerrno ELIBMAX: Attempting to link in too many shared libraries.
elibscn atom
public elibscn: atomerrno ELIBSCN: .lib section in a.out corrupted.
elnrng atom
public elnrng: atomerrno ELNRNG: Link number out of range.
eloop atom
public eloop: atomerrno ELOOP: Too many symbolic links encountered.
emediumtype atom
public emediumtype: atomerrno EMEDIUMTYPE: Wrong medium type.
emfile atom
public emfile: atomerrno EMFILE: Too many open files.
emlink atom
public emlink: atomerrno EMLINK: Too many links.
emsgsize atom
public emsgsize: atomerrno EMSGSIZE: Message too long.
emultihop atom
public emultihop: atomerrno EMULTIHOP: Multihop attempted.
enametoolong atom
public enametoolong: atomerrno ENAMETOOLONG: File name too long.
eneedauth atom
public eneedauth: atomerrno ENEEDAUTH: Need authenticator.
enetdown atom
public enetdown: atomerrno ENETDOWN: Network is down.
enetreset atom
public enetreset: atomerrno ENETRESET: Network dropped connection because of reset.
enetunreach atom
public enetunreach: atomerrno ENETUNREACH: Network is unreachable.
enfile atom
public enfile: atomerrno ENFILE: File table overflow.
enoano atom
public enoano: atomerrno ENOANO: No anode.
enoattr atom
public enoattr: atomerrno ENOATTR: Attribute not found.
enobufs atom
public enobufs: atomerrno ENOBUFS: No buffer space available.
enocsi atom
public enocsi: atomerrno ENOCSI: No CSI structure available.
enodata atom
public enodata: atomerrno ENODATA: No data available.
enodev atom
public enodev: atomerrno ENODEV: No such device.
enoent atom
public enoent: atomerrno ENOENT: No such file or directory.
enoexec atom
public enoexec: atomerrno ENOEXEC: Exec format error.
enokey atom
public enokey: atomerrno ENOKEY: Required key not available.
enolck atom
public enolck: atomerrno ENOLCK: No record locks available.
enolink atom
public enolink: atomerrno ENOLINK: Link has been severed.
enomedium atom
public enomedium: atomerrno ENOMEDIUM: No medium found.
enomem atom
public enomem: atomerrno ENOMEM: Out of memory.
enomsg atom
public enomsg: atomerrno ENOMSG: No message of desired type.
enonet atom
public enonet: atomerrno ENONET: Machine is not on the network.
enopkg atom
public enopkg: atomerrno ENOPKG: Package not installed.
enopolicy atom
public enopolicy: atomerrno ENOPOLICY: Policy not found.
enoprotoopt atom
public enoprotoopt: atomerrno ENOPROTOOPT: Protocol not available.
enospc atom
public enospc: atomerrno ENOSPC: No space left on device.
enosr atom
public enosr: atomerrno ENOSR: Out of streams resources.
enostr atom
public enostr: atomerrno ENOSTR: Device not a stream.
enosys atom
public enosys: atomerrno ENOSYS: Invalid system call number.
enotblk atom
public enotblk: atomerrno ENOTBLK: Block device required.
enotcapable atom
public enotcapable: atomerrno ENOTCAPABLE: Capabilities insufficient.
enotconn atom
public enotconn: atomerrno ENOTCONN: Transport endpoint is not connected.
enotdir atom
public enotdir: atomerrno ENOTDIR: Not a directory.
enotempty atom
public enotempty: atomerrno ENOTEMPTY: Directory not empty.
enotnam atom
public enotnam: atomerrno ENOTNAM: Not a XENIX named type file.
enotrecoverable atom
public enotrecoverable: atomerrno ENOTRECOVERABLE: State not recoverable.
enotsock atom
public enotsock: atomerrno ENOTSOCK: Socket operation on non-socket.
enotsup atom
public enotsup: atomerrno ENOTSUP: Operation not supported.
enotty atom
public enotty: atomerrno ENOTTY: Not a typewriter.
enotuniq atom
public enotuniq: atomerrno ENOTUNIQ: Name not unique on network.
enxio atom
public enxio: atomerrno ENXIO: No such device or address.
eopnotsupp atom
public eopnotsupp: atomerrno EOPNOTSUPP: Operation not supported on transport endpoint.
eoverflow atom
public eoverflow: atomerrno EOVERFLOW: Value too large for defined data type.
eownerdead atom
public eownerdead: atomerrno EOWNERDEAD: Owner died.
eperm atom
public eperm: atomerrno EPERM: Operation not permitted.
epfnosupport atom
public epfnosupport: atomerrno EPFNOSUPPORT: Protocol family not supported.
epipe atom
public epipe: atomerrno EPIPE: Broken pipe.
eproclim atom
public eproclim: atomerrno EPROCLIM: Too many processes.
eprogmismatch atom
public eprogmismatch: atomerrno EPROGMISMATCH: Program version wrong.
eproto atom
public eproto: atomerrno EPROTO: Protocol error.
eprotonosupport atom
public eprotonosupport: atomerrno EPROTONOSUPPORT: Protocol not supported.
eprototype atom
public eprototype: atomerrno EPROTOTYPE: Protocol wrong type for socket.
epwroff atom
public epwroff: atomerrno EPWROFF: Device power is off.
eqfull atom
public eqfull: atomerrno EQFULL: Interface output queue is full.
erange atom
public erange: atomerrno ERANGE: Math result not representable.
eremchg atom
public eremchg: atomerrno EREMCHG: Remote address changed.
eremote atom
public eremote: atomerrno EREMOTE: Object is remote.
eremoteio atom
public eremoteio: atomerrno EREMOTEIO: Remote I/O error.
erestart atom
public erestart: atomerrno ERESTART: Interrupted system call should be restarted.
erfkill atom
public erfkill: atomerrno ERFKILL: Operation not possible due to RF-kill.
erofs atom
public erofs: atomerrno EROFS: Read-only file system.
erpcmismatch atom
public erpcmismatch: atomerrno ERPCMISMATCH: RPC version wrong.
eshlibvers atom
public eshlibvers: atomerrno ESHLIBVERS: Shared library version mismatch.
eshutdown atom
public eshutdown: atomerrno ESHUTDOWN: Cannot send after transport endpoint shutdown.
esocktnosupport atom
public esocktnosupport: atomerrno ESOCKTNOSUPPORT: Socket type not supported.
espipe atom
public espipe: atomerrno ESPIPE: Illegal seek.
esrch atom
public esrch: atomerrno ESRCH: No such process.
esrmnt atom
public esrmnt: atomerrno ESRMNT: Srmount error.
estale atom
public estale: atomerrno ESTALE: Stale file handle.
estrpipe atom
public estrpipe: atomerrno ESTRPIPE: Streams pipe error.
etime atom
public etime: atomerrno ETIME: Timer expired.
etimedout atom
public etimedout: atomerrno ETIMEDOUT: Connection timed out.
etoomanyrefs atom
public etoomanyrefs: atomerrno ETOOMANYREFS: Too many references: cannot splice.
etxtbsy atom
public etxtbsy: atomerrno ETXTBSY: Text file busy.
euclean atom
public euclean: atomerrno EUCLEAN: Structure needs cleaning.
eunatch atom
public eunatch: atomerrno EUNATCH: Protocol driver not attached.
eusers atom
public eusers: atomerrno EUSERS: Too many users.
exdev atom
public exdev: atomerrno EXDEV: Cross-device link.
exfull atom
public exfull: atomerrno EXFULL: Exchange full.
fifo atom
public fifo: atomA FIFO, a named pipe.
read_only atom
public read_only: atomOpen for reading only.
read_write atom
public read_write: atomOpen for reading and writing.
regular atom
public regular: atomA regular file.
socket_file atom
public socket_file: atomA socket: socket_file, since socket is the name of a call.
symbolic_link atom
public symbolic_link: atomA symbolic link, reported as itself when it is not followed.
unknown_kind atom
public unknown_kind: atomA kind the system did not say: a directory entry whose file system records none, which status_at then tells.
unlisted atom
public unlisted: atomA failure no errno this module names describes: a number newer than its tables, or a record the system filled that could not be read. Its number is zero.
write_only atom
public write_only: atomOpen for writing only.
directory_buffer value
public directory_buffer: usize = 1024The least a buffer read_directory reads into holds: room for any entry any of the three systems gives, its record and its NUL included.
poll_error value
public poll_error: poll_events = events_value(8)An error on the file.
poll_hung_up value
public poll_hung_up: poll_events = events_value(16)The peer has gone.
poll_input value
public poll_input: poll_events = events_value(1)Data to read, or the end of a file.
poll_invalid value
public poll_invalid: poll_events = events_value(32)A descriptor that is not open.
poll_no_events value
public poll_no_events: poll_events = events_value(0)No event.
poll_output value
public poll_output: poll_events = events_value(4)Room to write.
poll_urgent value
public poll_urgent: poll_events = events_value(2)Out-of-band data to read.
reading value
public reading: open_options = (access: read_only, create: false,The options for reading an existing file.
standard_error value
public standard_error: descriptor = descriptor_value(2)Standard error, descriptor 2.
standard_input value
public standard_input: descriptor = descriptor_value(0)Standard input, descriptor 0.
standard_output value
public standard_output: descriptor = descriptor_value(1)Standard output, descriptor 1.
working_directory value
When compiler.os == darwin
public working_directory: descriptor = descriptor_value(-2)The working directory as the directory an *_at call's relative path is relative to: C's AT_FDCWD, which is no open file.
When not (compiler.os == darwin) and (compiler.os == freebsd)
public working_directory: descriptor = descriptor_value(-100)The working directory as the directory an *_at call's relative path is relative to: C's AT_FDCWD, which is no open file.
When not (compiler.os == darwin or compiler.os == freebsd)
public working_directory: descriptor = descriptor_value(-100)The working directory as the directory an *_at call's relative path is relative to: C's AT_FDCWD, which is no open file.
writing value
public writing: open_options = (access: write_only, create: true,The options for writing a file from its start, creating it when it is missing and truncating it when it is not.
_landin_host_initialize_arguments function
public extern(c) _landin_host_initialize_arguments:
(count: i32, escaping values: ptr ptr u8) -> noneEstablish the process's argument root from C's main carriers. The hosted entry calls this with its own argc and argv before its body runs; a C main that drives Landin exports calls it itself, before it reads an argument and before starting a thread that may.
The first call needs a nonnegative count and a non-null table, and keeps that exact pair without copying: the caller keeps the table and its strings readable while any argument lent from them is in use. Repeating the identical pair changes nothing; a negative count, a null table or a different pair traps. The published arguments omit argv[0], so their count is max(argc - 1, 0).
argument function
public link(symbol: "_landin_posix_argument") argument:
(table: argument_table, index: usize)
-> (value: text.host_string from table)The argument index, from zero, as a host string lending the process's own storage, which nothing copies. An index at or past the table's count traps, as does a null entry, which C promises none below argc is.
arguments function
public link(symbol: "_landin_posix_arguments") arguments:
() -> (table: argument_table)The process's arguments, argv[0] not among them. It traps when no argument root has been established: the hosted entry establishes one before main runs, and a C main calls _landin_host_initialize_arguments itself.
close function
public link(symbol: "_landin_posix_close") close:
(closing: descriptor) -> none ! errnoClose closing. The descriptor is released even when this fails, so a failed close is never retried: the number may already name another file.
close_directory function
public link(symbol: "_landin_posix_close_directory") close_directory:
(opened: directory_stream) -> none ! errnoClose the directory stream and its descriptor, which are released even when this fails.
errno_of function
public link(symbol: "_landin_posix_errno_of") errno_of:
(value: i32) -> (problem: errno)The errno atom for the number value on this system: unlisted for a number it does not define.
exit function
public link(symbol: "_landin_posix_exit") exit:
(status: i32) -> noreturnEnd the process with status at once, POSIX's _exit: nothing more of the program runs, and no C stream is flushed.
happened function
public link(symbol: "_landin_posix_happened") happened:
(entry: poll_entry) -> (events: poll_events)What happened to an entry's descriptor in the last poll; nothing, before one.
make_directory_at function
public link(symbol: "_landin_posix_make_directory_at") make_directory_at:
(at: descriptor, path: text.host_string,
permissions: u32) -> none ! errnoMake the directory path names, relative to at, with the permission bits permissions, which the process umask filters: eexist when the name is taken, enoent when its parent is missing.
map function
public link(symbol: "_landin_posix_map") map:
(length: usize) -> (base: ptr mut u8) ! errnoMap length bytes of fresh, zeroed memory that this process alone may read and write, POSIX's anonymous private mmap: its first byte, which is aligned to a page, or the errno, enomem when the system has no room.
number function
public link(symbol: "_landin_posix_number") number:
(problem: errno) -> (value: i32)The number problem has on this system, as C's errno holds it: zero for unlisted and for an errno this system does not define. ENOTSUP is EOPNOTSUPP's number on Linux and FreeBSD.
open_at function
public link(symbol: "_landin_posix_open_at") open_at:
(at: descriptor, path: text.host_string,
options: open_options, permissions: u32)
-> (opened: descriptor) ! errnoOpen the file path names, relative to the directory open as at (or working_directory), with options; a file it creates gets the permission bits permissions, which the process umask filters. The new descriptor, or the errno: enoent for a missing name, enotdir when a component is not a directory, eacces when refused, eexist for an exclusive name that is taken, eintr when a signal came first.
open_directory function
public link(symbol: "_landin_posix_open_directory") open_directory:
(at: descriptor, path: text.host_string)
-> (opened: directory_stream) ! errnoOpen the directory path names, relative to at, for reading: enotdir when it is not a directory, enoent when it is missing. Close it with close_directory, which also closes its descriptor.
page_size function
public link(symbol: "_landin_posix_page_size") page_size:
() -> (bytes: usize)The size of the system's pages in bytes, which map aligns to: 16 KiB on Darwin arm64 and 4 KiB on the others. On Linux it is what the kernel told a static executable's entry, and 4096 when the C runtime started the program instead.
poll function
public link(symbol: "_landin_posix_poll") poll:
(entries: []mut poll_entry, milliseconds: i32)
-> (ready: usize) ! errnoWait until an event happens to one of entries' descriptors, or milliseconds pass, waiting indefinitely when it is negative and not at all when it is zero, POSIX's poll: how many entries had an event, each of which happened reads, zero when the time passed first, or the errno, eintr when a signal came first.
read function
public link(symbol: "_landin_posix_read") read:
(source: descriptor, into: []mut u8) -> (count: usize) ! errnoRead at most lenof into bytes from source into into: the count read, zero at the end of a file, or the errno; eintr means nothing was read.
read_directory function
public link(symbol: "_landin_posix_read_directory") read_directory:
(inout opened: directory_stream, buffer: []mut u8)
-> (item: directory_entry from buffer) ! errnoThe directory's next entry, read into buffer, which must be the buffer every earlier read of this stream was given and hold at least directory_buffer bytes, or einval. The entry lends its name from buffer until the next read. An entry with an empty name is the end of the directory. Entries come in the system's order, . and .. among them, as POSIX's readdir gives them.
remove_directory_at function
public link(symbol: "_landin_posix_remove_directory_at") remove_directory_at:
(at: descriptor, path: text.host_string)
-> none ! errnoRemove the empty directory path names, relative to at, POSIX's unlinkat with AT_REMOVEDIR: enotempty when it holds anything.
status_at function
public link(symbol: "_landin_posix_status_at") status_at:
(at: descriptor, path: text.host_string, follow: bool)
-> (result: status) ! errnoThe status of the file path names, relative to the directory open as at (or working_directory), following a final symbolic link when follow is true and reporting the link itself when it is not.
unlink_at function
public link(symbol: "_landin_posix_unlink_at") unlink_at:
(at: descriptor, path: text.host_string) -> none ! errnoRemove the name path, relative to at, of a file that is not a directory, POSIX's unlinkat.
unmap function
public link(symbol: "_landin_posix_unmap") unmap:
(base: ptr mut u8, length: usize) -> none ! errnoGive back the length bytes mapped at base, POSIX's munmap.
watch function
public link(symbol: "_landin_posix_watch") watch:
(watched: descriptor, wanted: poll_events)
-> (entry: poll_entry)An entry watching watched for the events wanted asks about; its poll_error, poll_hung_up and poll_invalid are reported whether asked or not.
write function
public link(symbol: "_landin_posix_write") write:
(to: descriptor, bytes: []u8) -> (count: usize) ! errnoWrite at most lenof bytes bytes of bytes to to: the count accepted, which may be short, or the errno; eintr means nothing was written.