Implements
  • Kernel
Index
auth: Auth

Authentication and authorization service

Broadcast channel for inter-kernel communication

components: Components

Web Components manager

devices: Map<string, { device: KernelDevice; drivers?: KernelCharDevice[] }> = ...

Map of registered devices and their drivers

dom: Dom

DOM manipulation service

events: Events

Event management system

filesystem: Filesystem

Virtual filesystem

framebuffers: Framebuffers

The framebuffers (/dev/fb<N>), each drawing in a window

fstypes: FsTypes

The filesystem types mount -t knows: the built-in ones and those modules add

host: Host

The environment this kernel runs in (browser or Node)

i18n: I18n

Internationalization service

id: string = ...

Unique identifier for this kernel instance

init: Init = ...

pid 1: /sbin/init, which runs /etc/inittab, supervises its daemons and reaps orphans.

intervals: Intervals

Interval management service

keyboard: Keyboard

Keyboard interface

kmodules: ModuleManager

Loads and unloads modules (insmod, rmmod) and keeps their symbols

log: Log

Logging system

machine: string | undefined

The machine this kernel runs (?machine=NAME); undefined is the default one. See lib/machine.ts.

memory: Memory

Memory management service

modcatalog?: ModuleCatalog

The in-tree modules that are fetched when first asked for; undefined when options.modules is false

modprobe: ModProbe
moduleBinfmts: Set<BinFmt> = ...

The program formats modules added, which the shell asks about a file it does not know

modules: KernelModules = loadedModules

The loaded modules, @zenfs/linux's list that /proc/modules shows

name: string = ...

Name of the kernel

options: KernelOptions

Configuration options passed to the kernel

packages: Map<string, Module> = ...

Map of loaded packages

protocol: Protocol

Protocol handler service

screensavers: Map<
    string,
    {
        default: (options: { terminal: Terminal }) => Promise<void>;
        exit: () => Promise<void>;
    },
>

Map of available screensavers

service: Service

Service management system

shell: Shell

Shell for command interpretation and execution

sockets: Sockets

Socket connection management service

storage: Storage

Storage provider interface

system: Shell

The kernel's own shell, root's whoever is logged in: what runs init scripts, fstab mounts and cron jobs. No user's session is ever lent to the kernel for these. It shows on the console (TTY 0) but is not its shell.

telemetry: Telemetry

Telemetry service for OpenTelemetry tracing

terminal: Terminal

Terminal interface for user interaction

users: Users

User management service

version: string = ...

Version string of the kernel

wasm: Wasm

WebAssembly service

windows: Windows

Window management service

workers: Workers

Web Worker management service

  • get addEventListener(): <T>(event: string, callback: EventCallback<T>) => void

    Add an event listener; alias for events.on

    Returns <T>(event: string, callback: EventCallback<T>) => void

      • <T>(event: string, callback: EventCallback<T>): void
      • Add an event listener

        Type Parameters

        • T

        Parameters

        • event: string

          Event name

        • callback: EventCallback<T>

          Event handler

        Returns void

  • get context(): KernelContext

    The cross-cutting primitives a subsystem or driver may depend on, with no back-reference to the Kernel itself

    Returns KernelContext

  • get hotplug(): {}

    Nodes made and removed at runtime, for a package whose devices come and go. add gives driver its node (the major is registered if no driver of the package's had it at boot), and the function it returns takes the node away: a file still open on it gets ENODEV, as on Linux, until a device takes the minor again.

    Returns {}

  • get pipeProcess(): Process

    The kernel's own process, whose table holds the pipe ends no program does: bridges, and sockets' connections

    Returns Process

  • get programsRunAsUser(): boolean

    Whether a user's programs run with that user's credentials, rather than all as root (see canRunProgramsAsUser)

    Returns boolean

  • get removeEventListener(): <T>(
        event: string,
        callback: EventCallback<T>,
    ) => void

    Remove an event listener; alias for events.off

    Returns <T>(event: string, callback: EventCallback<T>) => void

      • <T>(event: string, callback: EventCallback<T>): void
      • Remove an event listener

        Type Parameters

        • T

        Parameters

        • event: string

          Event name

        • callback: EventCallback<T>

          Event handler

        Returns void

  • Makes name (an IANA zone, or undefined for the browser's) the system's zone: the TZ the kernel's shells give what they start from now on. A program already running, and a shell that set its own TZ, keep theirs.

    Parameters

    • name: string | undefined

    Returns Promise<void>

  • First half of a login on ttyNumber for /sbin/getty: tries a passkey. True when username is already authenticated and no password is needed.

    Parameters

    • ttyNumber: number
    • username: string

    Returns Promise<boolean>

  • Boots the kernel and initializes all core services.

    Parameters

    • options: BootOptions = DefaultBootOptions

      Boot configuration options

    Returns Promise<void>

    If boot process fails

  • Configures kernel subsystems with the provided options

    Parameters

    • options: KernelOptions

      Configuration options for kernel subsystems

    Returns Promise<void>

  • A login on ttyNumber has ended: the session record goes, and the shell holds no user until the next login.

    Parameters

    • ttyNumber: number

    Returns Promise<void>

  • Runs a plain JS/ESM file as an isolated process through @zenfs/linux's execve, with /bin/node as interpreter. Redirected stdio is wired through bridgeStdio. A program cannot import modules itself.

    Parameters

    • options: KernelExecuteOptions

      the file path and shell

    Returns Promise<number>

    the process's exit code

  • Second half: authenticates (the passkey from beginLogin, or password) and starts the session on the tty's shell. Resolves to what getty needs to run the user's shell; rejects with the message to show.

    Parameters

    • ttyNumber: number
    • username: string
    • password: string

    Returns Promise<
        {
            env: Record<string, string>;
            gid: number;
            groups: number[];
            home: string;
            shell: string;
            uid: number;
            username: string;
        },
    >

  • Gets the main entry file path from a package.json

    Parameters

    • pkgData: JSONSchemaForNPMPackageJsonFiles

      The parsed package.json data

    Returns string | null

    The main entry file path or null if not found

  • Gets a shell by TTY number

    Parameters

    • ttyNumber: number

      TTY number (0-7)

    Returns Shell | undefined

    Shell instance or undefined if not found

  • A directed create_pipe between two processes with no pump. A loopback socket connection is two of these, one per direction. Both ends are created on pipeProcess and each Handle moves to its process's table at the lowest free fd.

    Parameters

    • fromProc: Process
    • toProc: Process

    Returns { readerFd: number; writerFd: number }

  • Removes an event listener from the kernel.

    Parameters

    • event: KernelEvents

      The event to remove the listener from.

    • listener: EventCallback

      The listener to remove.

    Returns void

  • Adds an event listener to the kernel.

    Parameters

    • event: KernelEvents

      The event to listen for.

    • listener: EventCallback

      The listener to add.

    Returns void

  • Opens a login on a terminal with no page, for a user already authenticated (by key, over a peer link). Takes the lowest free TTY of 1 to 7, starts the session and runs the built-in shell until exit. Output goes to options.write; the caller feeds input to session.terminal.

    Parameters

    • options: {
          cols?: number;
          onEnd?: () => void;
          rows?: number;
          username: string;
          write: (data: string | Uint8Array<ArrayBufferLike>) => void;
      }

    Returns Promise<KernelSession>

    if every TTY is taken or the user may not log in

  • Has a browser call done by the display the user is at on tty; undefined when none is attached (see lib/remote-display.ts)

    Parameters

    • tty: number
    • kind: string
    • params: Record<string, unknown>

    Returns RemoteCall | undefined

  • The context a program started from shell runs in: the shell's own user, or undefined (root) for a root shell or when the installed @zenfs/core cannot run programs as another user (see canRunProgramsAsUser).

    Parameters

    • shell: Shell
    • cwd: string
    • Optionalprogram: string

    Returns BoundContext | undefined

  • A login on a pty, for /bin/login -p: authenticates and resolves to what the login needs to start the user's shell on the terminal it already has. There is no Shell behind a pty, so no session record and no startup files here; the login shell reads its own.

    Parameters

    • username: string
    • password: string

    Returns Promise<
        {
            env: Record<string, string>;
            gid: number;
            groups: number[];
            home: string;
            shell: string;
            uid: number;
            username: string;
        },
    >

  • Reads and parses a file header to determine its type

    Parameters

    • filePath: string

      Path to the file

    • Optionalshell: Shell

      Optional shell instance to use for filesystem operations

    Returns Promise<FileHeader | null>

    Parsed header information or null if invalid

  • Discovers the built-in screensavers. An import.meta.glob resolved at build time relative to this file, so it cannot move out of Kernel the way startScreensaverDaemon did.

    Returns void

  • Replaces imports in a script with SWAPI URLs (import maps cannot be dynamic).

    Parameters

    • contents: string

      the script contents

    • packagePath: string

    Returns Promise<string>

  • request_module: the kernel asks for a module by alias (fs-zip when mount -t zip meets a type nobody has) and modprobe loads it, as root, whoever asked. True if the alias named a module and it loaded.

    Parameters

    • alias: string

    Returns Promise<boolean>

  • Asks init to reboot, the way the reboot command does, so everything is stopped in order first. Straight to reboot when init is not running, or when it has not taken the system down within 15 seconds, so a wedged init cannot make the keyboard shortcut useless.

    Returns void

  • Runs a program as a user on a pty nothing watches; see runDetached.

    Parameters

    • options: DetachedOptions

    Returns Promise<number>

  • A shell that acts as the user of proc, for a DOM app that process started from a shell of its own (su, a login's child): the app runs its commands through this, so they run as that user and not as the kernel's root shell. It has no terminal of its own; what it runs writes where the app tells it to.

    Parameters

    • proc: {
          context: { credentials: Credentials; pwd: string };
          env: Record<string, string | undefined>;
      }

    Returns Shell

  • Parameters

    • options: {
          args?: string[];
          command: string;
          cwd?: string;
          env?: Record<string, string>;
          pty: KernelPty;
          username: string;
      }

    Returns Promise<Process>

  • Starts the idle screensaver daemon: shows localStorage['screensaver'] (default matrix) after localStorage['screensaver-timeout'] ms (default 60000) of inactivity. Started by /boot/init through screensaver-daemon.

    Returns (() => void) | undefined

    a function that stops the daemon, or undefined if the screensaver is not registered

  • Makes user the login on shell: credentials, bound context, identity variables, the session record, the home directory, then the startup files in order. The one place a login takes effect, shared by the built-in login prompt, auto-login, and /sbin/getty through login_session.

    Parameters

    • shell: Shell
    • user: User
    • cred: Credentials
    • Optionaloptions: { startupFiles?: boolean }

    Returns Promise<void>

  • What init does last: reboot shuts down and reloads the page, halt only shuts down, poweroff shuts down and then tries to close the page (best effort; browsers only close windows a script opened).

    Parameters

    • mode: "reboot" | "halt" | "poweroff"

    Returns Promise<void>

  • The passkey half of a login: when username has passkeys and the browser supports them, asks for one and returns the session it yields. Null means "ask for a password" (no such user, no passkey, or the attempt was cancelled or failed, which is said on terminal).

    Parameters

    • terminal: { writeln(text: string): void }
    • username: string

    Returns Promise<{ cred: Credentials; user: User } | null>

  • Resolves when the catalog's programs are installed (or have failed), which boot does not wait for. Until then a program not installed before is a placeholder that waits for it.

    Returns Promise<void>