Schemes

Within Redox, a scheme may be thought of in a few ways. It is all of these things.

  • It is the type of a resource, such as "file", "M.2 drive", "tcp connection", etc. (Note that these are not valid scheme names, they are just given by way of example.)
  • It is the starting point for locating the resource, i.e. it is the root of the path to the resource, which the system can then use in establishing a connection to the resource.
  • It is a uniquely named service that is provided by some driver or daemon program, with the full URL identifying a specific resource accessed via that service.

Kernel vs. Userspace Schemes

Schemes are implemented by scheme providers. A userspace scheme is implemented by a program running in user space, currently requiring root permission. A kernel scheme is implemented by the kernel directly. When possible, schemes should be implemented in userspace. Only critical schemes are implemented in kernel space.

Accessing Resources

In order to provide "virtual file" behavior, schemes generally implement file-like operations. However, it is up to the scheme provider to determine what each file-like operation means. For example, seek to an SSD driver scheme might simply add to a file offset, but to a floppy disk controller scheme, it might cause the physical movement of disk read-write heads.

Typical scheme operations include:

  • open - Create a handle (file descriptor) to a resource provided by the scheme. e.g. File::create("tcp:127.0.0.1:3000") in a regular program would be converted by the kernel into open("127.0.0.1:3000") and sent to the "tcp:" scheme provider. The "tcp:" scheme provider would parse the name, establish a connection to Internet address "127.0.0.1", port "3000", and return a handle that represents that connection.
  • read - get some data from the thing represented by the handle, normally consuming that data so the next read will return new data.
  • write - send some data to the thing represented by the handle to be saved, sent or written.
  • seek - change the logical location that the next read or write will occur. This may or may not cause some action by the scheme provider.

Schemes may choose to provide other standard operations, such as mkdir, but the meaning of the operation is up to the scheme. mkdir might create a directory entry, or it might create some type of substructure or container relevant to that particular scheme.

Some schemes implement fmap, which creates a memory-mapped area that is shared between the scheme resource and the scheme user. It allows direct memory operations on the resource, rather than reading and writing to a file descriptor. The most common use case for fmap is for a device driver to access the physical addresses of a memory-mapped device, using the memory: kernel scheme. It is also used for frame buffers in the graphics subsystem.

TODO add F-operations.

TODO Explain file-like vs. socket-like schemes.

Userspace Schemes

Redox creates user-space schemes during initialization, starting various daemon-style programs, each of which can provide one or more schemes.

NameDaemonDescription
disk.*:ided, ahcid, nvmedStorage drivers
disk.live:livedRAM-disk driver that loads the bootable USB data into RAM
disk.usb-{id}+{port}-scsi:usbscsidUSB SCSI driver
logging:ramfsError logging scheme, using an in-memory temporary filesystem
initfs:bootstrapStartup filesystem
file:redoxfsMain filesystem
network:e1000d, rtl8168dLink-level network send/receive
ip:smolnetdRaw IP packet send/receive
tcp:smolnetdTCP sockets
udp:smolnetdUDP sockets
icmp:smolnetdICMP protocol
netcfg:smolnetdNetwork configuration
dns:dnsdDNS protocol
display.vesa:vesadVESA driver
display.virtio-gpu:virtio-gpudVirtIO GPU driver
orbital:orbitalWindowing system (window manager and virtual driver)
pty:ptydPseudoterminals, used by terminal emulators
audiorw:sb16d, ac97d, ihdadSound drivers
audio:audiodAudio manager and virtual device
usb.*:usb*dUSB interfaces
pcspkr:pcspkrdPC speaker driver
acpi:acpidACPI driver
input:inputdVirtual device
escalate:escalatedPrivilege manager
chan:ipcdInter-process communication
shm:ipcdShared memory manager
log:logdLogging
rand:randdPseudo-random number generator
zero:zerodDiscard all writes, and always fill read buffers with zeroes
null:nulldDiscard all writes, and read no bytes

Kernel Schemes

The kernel provides a small number of schemes in order to support userspace.

NameDocumentationDescription
:root.rsNamespace manager
user:user.rsDispatch for user-space schemes
debug:debug.rsDebug messages that can't use the log: scheme
event:event.rsepoll-like file descriptor read/write "ready" events
irq:irq.rsInterrupt manager (converts interrupts to messages)
pipe:pipe.rsKernel manager for pipes
proc:proc.rsProcess context manager
thisproc:proc.rsProcess context manager
sys:mod.rsSystem hardware resources information
kernel.acpi:acpi.rsRead the CPU configuration (number of cores, etc)
memory:memory.rsPhysical memory mapping manager
time:time.rsReal-time clock timer
itimer:time.rsInterval timer
serio:serio.rsSerial I/O (PS/2) driver (must stay in the kernel due to PS/2 protocol issues)