std/os
What a program asks about the machine it runs on (docs/design/OS.md): the environment it was started with, which
system and version it is, and where the user's files belong. The three target constants of std/core are
re-exported, so that a file that branches on the system writes one import.
EnvironmentandEnvironmentVariables- read one variable, list them all, split the search path.SystemandSystemVersion- the version, the host name, the uptime, the page size, the machine's architecture.MemoryandSwap- how much memory the machine has, how much of it is available, and its swap.Processor,ProcessorTimesandProcessorUsage- how many processors the machine has, the time they have spent in each state, and how busy they were over an interval;ProcessorDescriptionis what a processor says about itself,Frequencya processor clock,ProcessorCacheone of its caches andProcessorFeaturean instruction-set extension it offers.CurrentProcessandProcessResources- this process's identifier and its parent's, its executable, working directory and uptime, the processor time and memory it uses, its processors and its memory limit.Volume,VolumeKindandVolumeSpace- the mounted file systems, what kind of storage each is, and how full.Directories- home, configuration, data, state, cache and temporary files, by the convention of the system.User- the account this process runs as: its name, full name, identifier, home directory and whether it is elevated.Entropy- bytes of the system's source of randomness, for keys, nonces and the seed of a generator.NetworkInterface,InterfaceAddress,InterfaceStatusandInterfaceKind- the machine's network interfaces, their addresses with the length of their prefix, whether the link is up and what kind of interface each is.MacAddress- the hardware address of a network interface, read from and shown as text; it reads nothing from the machine.OsError- what every question that can fail fails with.
A branch on the system is a match OperatingSystem.current: every arm is type checked on every machine, and only the
arm of the build's target is compiled. Each module above is such a branch, and each arm hands its question to a
directory of its own - windows/, linux/, macos/, freebsd/, browser/ for one system, posix/, bsd/,
xdg/ for a standard several share. Those directories hold the raw natives (browser/ has none: a page asks the
machine nothing); torb check --every-target reports one that is reached on a system it does not exist on.
Modules
std/os/directories[Directories]: where a user's files belong by the convention of the system - the home directory, and the bases for configuration, data, state, cache and temporary files.std/os/entropy[Entropy]: bytes of the operating system's source of randomness, which is fit for cryptography - what a key, a nonce, a token and the seed of a generator are made from (docs/design/RANDOM.md).std/os/environmentThe environment this process was started with: [Environment] reads one variable, lists every one as a value, and splits the search path; [EnvironmentVariables] is that list as a value a program can change and hand on.std/os/error[OsError], what asking the operating system can go wrong with, and [outcome], the one function that turns the answer of a native ofruntime/os/into aResult.std/os/macaddress[MacAddress]: the hardware address of a network interface, as a value like any other (docs/design/OS.md section 5.5).std/os/memory[Memory] - how much memory the machine has and how much of it a new allocation could still get - and [Swap], the space on disk the system pages memory out to.std/os/network[NetworkInterface] - a network interface of the machine with its addresses - and the values it is made of: [InterfaceAddress], [InterfaceStatus] and [InterfaceKind].std/os/process[CurrentProcess] - what the operating system knows about this process: its identifier and its parent's, the executable it runs, its working directory, how long it has been running, and the resources it uses and may use ([ProcessResources], its processors, its memory limit).std/os/processor[Processor] - how many processors the machine has, what they are and how busy they are - with [ProcessorTimes], the cumulative time each state has taken, [ProcessorUsage], the fractions of an interval, [ProcessorDescription], what a processor says about itself, and [Frequency], a processor clock.std/os/system[System] - which operating system this is and which version, the host name, how long it has been running, the size of a memory page and the architecture of the machine - and [SystemVersion], the name and version it answers.std/os/user[User] - the account this process runs as.std/os/volumes[Volume] - a mounted file system - with its [VolumeKind] and, in step with [Volume.space], its [VolumeSpace].
Everything
- type
CurrentProcessWhat the operating system knows about this process. - type
DirectoriesWhere a user's files belong, by the convention of the system. - type
EntropyThe operating system's source of randomness:BCryptGenRandomon Windows,getrandomon Linux and FreeBSD,getentropyon macOS, andcrypto.getRandomValuesin the browser. - type
EnvironmentThe environment this process was started with: read, listed, and handed on as a value. - type
EnvironmentVariablesA set of environment variables as a value. - type
FrequencyA processor clock: a count of hertz. - type
InterfaceAddressOne address of an interface, with the length of its network prefix:192.168.1.23/24,fe80::1/64. - type
InterfaceKindWhat kind of interface a [NetworkInterface] is. - type
InterfaceStatusWhether the link of an interface is up. - type
MacAddressA MAC address: six octets, held as one number of 48 bits. - type
MemoryHow much memory the machine has, and how much of it a new allocation could still get without swapping. - type
NetworkInterfaceA network interface and its addresses. - type
OsErrorWhat asking the operating system went wrong with. - type
ProcessorThe processors of this machine. - type
ProcessorCacheOne cache of a processor, as the processor describes it: the level, what it holds, how large it is and how long its lines are. - type
ProcessorDescriptionWhat a processor says about itself, as [Processor.describe] reads it. - type
ProcessorFeatureAn instruction-set extension a program may dispatch on, named after the extension as its vendor spells it. - type
ProcessorTimesCumulative time in each state. - type
ProcessorUsageFractions of an interval, each between 0 and 1. - type
ProcessResourcesWhat the current process has used, from [CurrentProcess.resources]:getrusageon Linux and macOS with the resident size each reads its own way,GetProcessTimesandGetProcessMemoryInfoon Windows. - type
SwapThe swap of the machine: the page files on Windows, the swap partitions and files on Linux, the swap files macOS makes as it needs them. - type
SystemWhich system this is, which version, and how long it has been running. - type
SystemVersionThe name and version of the running system. - type
UserThe account this process runs as: who it is for the system, what people call it, and where its files are. - type
VolumeA mounted file system: where it is mounted, what is mounted there, and what kind of storage it is. - type
VolumeKindWhat a [Volume] is stored on. - type
VolumeSpaceHow big a [Volume] is and how much of it is free.