.TH SYSCALLS 2 .SH NAME syscalls - overview of MontaukOS system calls .SH DESCRIPTION MontaukOS provides 178 system calls (numbers 0-186, with numbers 140-148 reserved) for userspace programs. Syscalls use the x86-64 SYSCALL instruction with the following register convention: RAX Syscall number (in) / return value (out) RDI Argument 1 RSI Argument 2 RDX Argument 3 R10 Argument 4 R8 Argument 5 R9 Argument 6 Include for the numeric SYS_* constants and ABI structs, and for typed wrappers in the montauk:: namespace. This page groups syscalls the same way the kernel source does (one subsystem header per group). .SH CAPABILITY SECURITY Privileged authority is stored in kernel-owned process credentials, not inferred from a process name, PID, executable path, or merely from the owner name returned by SYS_GETUSER. The owner identity may namespace per-user resources such as the clipboard, but no owner name implies administrative authority. The kernel-created init process is the root of the delegation tree. Login authenticates a user and delegates the appropriate session capabilities; there is no special "system" user shortcut in the kernel. Each process has three uint64_t masks, exposed in ProcInfo: permitted capabilities owned by the process effective permitted capabilities accepted by syscall checks delegable permitted capabilities that may be given to children Effective and delegable must be subsets of permitted. SYS_SPAWN and the other ordinary spawn variants give the child no capabilities. A parent uses SYS_SPAWN_CAPS to make an explicit delegation. Every requested permitted or delegable bit must be present in the parent's delegable mask, so a non-delegable grant cannot be propagated through another generation. Invalid or unauthorized requests return SYS_ERR_PERMISSION (-13). Capability bits and protected operations are: CAP_PROCESS_ADMIN kill unrelated processes or whole sessions CAP_POWER_REQUEST post a graceful shutdown/reboot request CAP_POWER_CONTROL consume power requests; reset or power off CAP_SUSPEND enter ACPI sleep CAP_STORAGE_ADMIN change partitions, mounts, or filesystems CAP_RAW_STORAGE raw disk reads and writes CAP_NETWORK_ADMIN change network/Wi-Fi configuration CAP_SET_TIME set wall-clock time or timezone CAP_USER_ADMIN manage users/trusted config; override owner at spawn CAP_DISPLAY_ADMIN set display mode or brightness CAP_DEVICE_ADMIN claim USB interfaces or change Bluetooth state CAP_LOG_READ read the kernel log CAP_SYSTEM_IMAGE write the program images in 0:/os and 0:/apps CAP_STANDARD_SESSION contains CAP_POWER_REQUEST and CAP_SUSPEND. CAP_ADMIN_SESSION adds the administrative capabilities above except CAP_POWER_CONTROL and CAP_SYSTEM_IMAGE. Final shutdown/reset authority is deliberately retained by login, the trusted session supervisor. SYS_POWERINFO remains readable without a capability, so the powermgr GUI and power command are monitors, not privileged power daemons. CAP_SYSTEM_IMAGE is likewise excluded from every session and from the "all" wildcard in 0:/config/capabilities.toml, and must be named explicitly to be granted. Capability grants are keyed on binary path, so write access to 0:/os or 0:/apps is equivalent to holding whatever those images are granted the next time a launcher runs them. Partitioning or formatting a volume is CAP_STORAGE_ADMIN and does not carry it. The authentication and trusted-service configuration files users.toml, setup.toml, init.toml, and ssh.toml are readable by ordinary processes but require CAP_USER_ADMIN to create, replace, delete, or write. The kernel also protects the 0:/config directory entry against replacement. This prevents changing a userspace role string from becoming a route to new kernel authority at the next login or boot. .SH PROCESS MANAGEMENT .B SYS_EXIT (0) Terminate the calling process. [[noreturn]] void montauk::exit(int code = 0); .B SYS_YIELD (1) Yield the remainder of the time slice. void montauk::yield(); .B SYS_SLEEP_MS (2) Sleep for at least the given number of milliseconds. void montauk::sleep_ms(uint64_t ms); .B SYS_GETPID (3) Return the PID of the calling process. int montauk::getpid(); .B SYS_SPAWN (20) Spawn a new process from an ELF binary on the VFS. The child inherits a snapshot of the caller's environment but no capabilities. int montauk::spawn(const char* path, const char* args = nullptr); .B SYS_SPAWN_CAPS (185) Spawn a child with explicit permitted, effective, and delegable masks. The child masks must satisfy the subset rules described under CAPABILITY SECURITY. Passing a non-null user override additionally requires the caller to have effective CAP_USER_ADMIN; null inherits the parent owner. int montauk::spawn_with_caps( const char* path, const char* args, const char* user, const montauk::abi::SpawnCapabilities& capabilities); .B SYS_WAITPID (23) Block until the given process has exited. Returns 0-255 for a normal exit, 256 plus the signal number if it was killed or crashed, or 0 if the PID is unknown or its exit record is no longer available. int montauk::waitpid(int pid); .B SYS_GETARGS (25) Get the argument string passed to this process at spawn time. int montauk::getargs(char* buf, uint64_t maxLen); .B SYS_GETEXECPATH (151) Copy the absolute path from which this process was spawned into buf. Returns the copied path length, or -1 on invalid arguments. int mtk_getexecpath(char* buf, unsigned long maxLen); .B SYS_GETENVIRON (171), SYS_SETENVIRON (172), SYS_SPAWN_ENV (173) Libc process-environment transport. Environment data is encoded as consecutive NAME=VALUE strings with a final empty string. Applications normally use getenv(3), setenv(3), environ, and posix_spawn(3). .B SYS_PROCLIST (61) List running processes (pid, parent, state, name, heap usage, accumulated CPU time, and permitted/effective/delegable capability masks). int montauk::proclist(montauk::abi::ProcInfo* buf, int max); .B SYS_KILL (62) Terminate a process by PID. Any process may terminate one of its own descendants. Terminating an unrelated process requires CAP_PROCESS_ADMIN. int montauk::kill(int pid); .B SYS_SETSESSION (174) Make the calling process the leader of a new process session. Processes spawned afterward inherit the session identifier. int montauk::setsession(); .B SYS_KILLSESSION (175) Terminate all live processes in a process session. Returns the number of members signalled; repeat until zero to wait for complete teardown. Requires CAP_PROCESS_ADMIN. int montauk::killsession(int sessionId); .B SYS_CHDIR (96) Change the calling process's current working directory. int montauk::chdir(const char* path); .B SYS_GETCWD (95) Get the calling process's current working directory. Returns the path length on success, -2 if maxLen cannot hold the path and terminating NUL, or -1 for another failure. The buffer is not modified when it is too small. int montauk::getcwd(char* buf, uint64_t maxLen); .B SYS_SETUSER (92) Associate a process with a logged-in user name (used by login/session management and per-user resource isolation). Requires CAP_USER_ADMIN. The name never grants capabilities or implies administrator status. int montauk::setuser(int pid, const char* name); .B SYS_GETUSER (93) Get the user name associated with the calling process. int montauk::getuser(char* buf, uint64_t maxLen); .SH THREADING Threads share the calling process's address space and heap (see montauk/heap.h for the heap lock). Declared in montauk/thread.h. .B SYS_THREAD_SPAWN (130) Spawn a new thread in the calling process. Returns a positive TID on success, -1 on failure. int montauk::thread_spawn(ThreadEntry entry, void* arg, uint64_t stack_bytes = 0); .B SYS_THREAD_EXIT (131) Terminate only the calling thread. If it is the main thread, the whole process exits. [[noreturn]] void montauk::thread_exit(int code = 0); .B SYS_THREAD_JOIN (132) Block until the given TID exits, then reclaim its kernel state. int montauk::thread_join(int tid, int* out_code = nullptr); .B SYS_THREAD_SELF (133) Return the calling thread's TID (equals getpid() for the main thread). int montauk::thread_self(); .SH CONSOLE I/O .B SYS_PRINT (4) Write a null-terminated string to the terminal. void montauk::print(const char* text); .B SYS_PUTCHAR (5) Write a single character to the terminal. void montauk::putchar(char c); .SH FILE I/O .B SYS_OPEN (6) Open a file. Returns a handle or negative on error. int montauk::open(const char* path); .B SYS_READ (7) Read bytes from a file at a given offset. int montauk::read(int h, uint8_t* buf, uint64_t off, uint64_t sz); .B SYS_GETSIZE (8) Get the size of an open file in bytes. uint64_t montauk::getsize(int handle); .B SYS_CLOSE (9) Close a file handle. void montauk::close(int handle); .B SYS_READDIR (10) List directory entries (max 256 per call for ramdisk directories, 128 for FAT32 and ext2 directories). For larger directories use SYS_READDIR_AT. int montauk::readdir(const char* path, const char** names, int max); .B SYS_READDIR_AT (136) Paginated directory read. Returns entries starting at startIndex; call repeatedly with startIndex advanced by the returned count until it returns 0 to enumerate directories of any size. int montauk::readdir_at(const char* path, const char** names, int max, int startIndex); .B SYS_FWRITE (41) Write bytes to a file at a given offset. int montauk::fwrite(int handle, const uint8_t* buf, uint64_t offset, uint64_t size); .B SYS_FCREATE (42) Create a new file on the target volume. Returns a handle or negative on error. int montauk::fcreate(const char* path); .B SYS_FDELETE (77) Delete a file. int montauk::fdelete(const char* path); .B SYS_FMKDIR (78) Create a directory. int montauk::fmkdir(const char* path); .B SYS_FRENAME (94) Rename or move a file/directory (used as the basis for file manager move operations). int montauk::frename(const char* oldPath, const char* newPath); .B SYS_STAT (152) Get a path's size, timestamps, mode, and directory status. int montauk::stat(const char* path, montauk::abi::FileStat* out); .B SYS_UTIME (167) Set a path's access and modification timestamps. This is the kernel transport used by the libc utime(3) interface. int utime(const char* path, const struct utimbuf* times); .B SYS_DRIVELIST (79) List mounted drive numbers. int montauk::drivelist(int* outDrives, int max); .B SYS_DRIVELABEL (124) Get the volume label of a drive. int montauk::drivelabel(int drive, char* outLabel, int maxLen); .B SYS_DRIVEKIND (127) Get the block device kind backing a drive: 0=unknown/ramdisk, 1=SATA, 2=SATAPI, 3=NVMe, 4=USB mass storage. int montauk::drivekind(int drive); .SH MEMORY .B SYS_ALLOC (11) Map zeroed pages into the process address space. void* montauk::alloc(uint64_t size); .B SYS_FREE (12) Release a complete mapping previously returned by SYS_ALLOC. void montauk::free(void* ptr); .B SYS_MMAP_ANON (168) Reserve a zero-filled anonymous mapping with read/write/execute protection flags. Pages are committed on first access. Writable executable mappings are rejected. void* mmap(void*, size_t, int, int, int, long); .B SYS_MUNMAP (169) Release a page-aligned range. Partial unmap splits the VM area and makes the virtual range reusable. int munmap(void* addr, size_t length); .B SYS_MPROTECT (170) Change read/write/execute permissions on an anonymous mapping. int mprotect(void* addr, size_t length, int prot); .B SYS_MEMSTATS (67) Get kernel-wide physical memory usage (total/free/used bytes, page size). void montauk::memstats(montauk::abi::MemStats* out); .SH TIMEKEEPING .B SYS_GETTICKS (13) Get APIC timer ticks since boot. uint64_t montauk::get_ticks(); .B SYS_GETMILLISECONDS (14) Get milliseconds elapsed since boot. uint64_t montauk::get_milliseconds(); .B SYS_GETTIME (28) Get the current wall-clock date and time in the configured timezone. Fills a montauk::abi::DateTime struct with Year, Month, Day, Hour, Minute, and Second fields. void montauk::gettime(montauk::abi::DateTime* out); .B SYS_SETUNIXTIME (153) Set the system wall clock from a UTC Unix timestamp. Returns 0 on success or -1 if the timestamp is outside the supported range. Requires CAP_SET_TIME. int montauk::set_unix_time(int64_t unixSeconds); .B SYS_SETTZ (90) Set the system-wide timezone offset, in minutes from UTC. Requires CAP_SET_TIME. int montauk::settz(int offset_minutes); .B SYS_GETTZ (91) Get the current timezone offset, in minutes from UTC. int montauk::gettz(); .SH SYSTEM .B SYS_GETINFO (15) Get OS name, version string, API version, max process count, and the monotonic kernel build number. void montauk::get_info(montauk::abi::SysInfo* info); .SH KEYBOARD .B SYS_ISKEYAVAILABLE (16) Check if a key event is pending (non-blocking). bool montauk::is_key_available(); .B SYS_GETKEY (17) Get the next key event (press or release). void montauk::getkey(montauk::abi::KeyEvent* out); .B SYS_GETCHAR (18) Block until a printable character is typed. char montauk::getchar(); .B SYS_GETCHAR_NB (166) Return the next printable character, or 0 when none is pending. Never blocks; key events carrying no ascii are drained rather than left to stall a following getchar. char montauk::getchar_nb(); .B SYS_INPUT_WAIT (123) Block until the input serial number differs from observedSerial or the timeout elapses; used to sleep efficiently between input-driven redraws. uint64_t montauk::input_wait(uint64_t observedSerial, uint64_t timeoutMs); .SH MOUSE .B SYS_MOUSESTATE (47) Get the current mouse position, scroll delta, and button mask. void montauk::mouse_state(montauk::abi::MouseState* out); .B SYS_SETMOUSEBOUNDS (48) Set the maximum X/Y the mouse cursor may reach (e.g. framebuffer dimensions). void montauk::set_mouse_bounds(int32_t maxX, int32_t maxY); .SH NETWORKING .B SYS_PING (19) Send an ICMP echo request and wait for reply. int32_t montauk::ping(uint32_t ip, uint32_t timeoutMs = 3000); .B SYS_RESOLVE (44) Resolve a hostname to an IPv4 address via DNS. Sends a UDP query to the configured DNS server and waits up to 5 seconds for a reply. Returns the IP in network byte order, or 0 on failure. IP address strings (e.g. "10.0.0.1") are detected and returned directly without a DNS query. uint32_t montauk::resolve(const char* hostname); .B SYS_GETNETCFG (37) Get the current network configuration (IP, mask, gateway, MAC, DNS server). void montauk::get_netcfg(montauk::abi::NetCfg* out); .B SYS_SETNETCFG (38) Set the network configuration (IP, mask, gateway, DNS server). Requires CAP_NETWORK_ADMIN. int montauk::set_netcfg(const montauk::abi::NetCfg* cfg); .B SYS_NETSTATUS (125) Get adapter status including driver name, link state, polling mode, and RX/TX packet counters. int montauk::net_status(montauk::abi::NetStatus* out); .B SYS_NETIFS (165) List registered link-layer network interfaces. The global IP configuration belongs to the entry whose active field is set. int montauk::net_interfaces(montauk::abi::NetIfInfo* buf, int maxCount); .SH WI-FI .B SYS_WIFI_SCAN (158) Perform a channel scan and block until it finishes or timeoutMs elapses. Returns the number of results, or -1 if no adapter is ready. Requires CAP_NETWORK_ADMIN because it changes radio state. int montauk::wifi_scan(montauk::abi::WifiNetwork* buf, int maxCount, uint32_t timeoutMs); .B SYS_WIFI_INFO (159) Get adapter, link, scan, join, and last-error status. int montauk::wifi_info(montauk::abi::WifiInfo* out); .B SYS_WIFI_CONNECT (160) Join a network and block until the link is up or the attempt fails. Requires CAP_NETWORK_ADMIN. int montauk::wifi_connect(const char* ssid, const char* password); .B SYS_WIFI_DISCONNECT (161) Disconnect from the current Wi-Fi network. Requires CAP_NETWORK_ADMIN. int montauk::wifi_disconnect(); .B SYS_WIFI_SCAN_START (162) Start a non-blocking channel scan. Returns 0 if started, 1 if a scan is already running, or -1 if no adapter is ready. Requires CAP_NETWORK_ADMIN. int montauk::wifi_scan_start(uint32_t timeoutMs); .B SYS_WIFI_RESULTS (163) Copy results from the most recent scan without accessing the radio. int montauk::wifi_results(montauk::abi::WifiNetwork* buf, int maxCount); .B SYS_WIFI_CONNECT_ASYNC (164) Start a non-blocking network join. Observe SYS_WIFI_INFO for progress and the final result. Requires CAP_NETWORK_ADMIN. int montauk::wifi_connect_async(const char* ssid, const char* password); .SH SOCKETS .B SYS_SOCKET (29) Create a socket. type=SOCK_TCP (1) or SOCK_UDP (2). Returns fd or -1. int montauk::socket(int type); .B SYS_CONNECT (30) Connect a TCP socket to a remote host. int montauk::connect(int fd, uint32_t ip, uint16_t port); .B SYS_BIND (31) Bind a socket to a local port for listening. int montauk::bind(int fd, uint16_t port); .B SYS_LISTEN (32) Start listening for incoming TCP connections. int montauk::listen(int fd); .B SYS_ACCEPT (33) Accept an incoming connection on a listening socket. Returns a new socket fd for the client connection. int montauk::accept(int fd); .B SYS_SEND (34) Send data on a connected socket. Returns bytes sent. int montauk::send(int fd, const void* data, uint32_t len); .B SYS_RECV (35) Receive data from a connected socket. Returns bytes received, 0 if no data available, or -1 on close/error. int montauk::recv(int fd, void* buf, uint32_t maxLen); .B SYS_CLOSESOCK (36) Close a socket and release its resources. int montauk::closesocket(int fd); .B SYS_SENDTO (39) Send a UDP datagram to a specific destination. int montauk::sendto(int fd, const void* data, uint32_t len, uint32_t destIp, uint16_t destPort); .B SYS_RECVFROM (40) Receive a UDP datagram. Returns the source address. int montauk::recvfrom(int fd, void* buf, uint32_t maxLen, uint32_t* srcIp, uint16_t* srcPort); .SH FRAMEBUFFER .B SYS_FBINFO (21) Get framebuffer dimensions and format. void montauk::fb_info(montauk::abi::FbInfo* info); .B SYS_FBMAP (22) Map the framebuffer into process memory. void* montauk::fb_map(); .B SYS_FBFLIP (150) Flip between double-buffered hardware scanout buffers. Index -1 queries support; index -2 acquires ownership and returns the current front-buffer index. Flag bit 0 waits for vertical blank. int64_t montauk::fb_flip(int64_t index, uint64_t flags); .SH DISPLAY CONTROL .B SYS_DISPLAYINFO (154) Get connector, mode, capability, and brightness information. int montauk::display_info(montauk::abi::DisplayInfo* out); .B SYS_DISPLAYMODES (155) Enumerate supported display modes. Returns the number written. int montauk::display_modes(montauk::abi::DisplayModeInfo* out, int maxCount); .B SYS_DISPLAYSETMODE (156) Switch to a mode returned by SYS_DISPLAYMODES. Requires CAP_DISPLAY_ADMIN. int montauk::display_set_mode(int modeIndex); .B SYS_DISPLAYBRIGHTNESS (157) Set brightness to 0-100 percent, or pass -1 to query it. Setting requires CAP_DISPLAY_ADMIN; querying does not. int montauk::display_brightness(int percent = -1); .SH TERMINAL .B SYS_TERMSIZE (24) Get terminal dimensions (columns and rows). void montauk::termsize(int* cols, int* rows); .B SYS_TERMSCALE (43) Get or set the terminal font scale factor. When scale_x is 0, returns the current scale as (scale_y << 32 | scale_x). When scale_x is non-zero, sets the font scale and returns the new terminal dimensions as (rows << 32 | cols). void montauk::termscale(int scale_x, int scale_y); void montauk::get_termscale(int* scale_x, int* scale_y); .SH RANDOM .B SYS_GETRANDOM (45) Fill a buffer with random bytes using RDTSC-seeded entropy. Returns the number of bytes written. int64_t montauk::getrandom(void* buf, uint32_t len); .SH POWER MANAGEMENT .B SYS_RESET (26) Reboot the system. Requires CAP_POWER_CONTROL. A successful call does not return; an unauthorized call returns SYS_ERR_PERMISSION. int montauk::reset(); .B SYS_SHUTDOWN (27) Shut down the system. Requires CAP_POWER_CONTROL. A successful call does not return; an unauthorized call returns SYS_ERR_PERMISSION. int montauk::shutdown(); .B SYS_SUSPEND (89) Enter ACPI S3 sleep. Returns after wake, 0 on success. Requires CAP_SUSPEND. int montauk::suspend(); .B SYS_POWER_REQUEST (135) Cross-process graceful power-off request channel. The desktop posts a pending action (POWER_REQ_SHUTDOWN / POWER_REQ_REBOOT) then exits; login.elf reads it with POWER_REQ_QUERY (read-and-clear), runs the shutdown stages, and finally calls shutdown()/reset(). Posting requires CAP_POWER_REQUEST; querying and consuming the request requires CAP_POWER_CONTROL. See montauk::abi::PowerRequestAction. A request may also come from inside a session -- the shell's shutdown builtin posts one. Since login only reads the request after the session leader exits, the leader polls POWER_REQ_PEEK, a non-destructive read requiring only CAP_POWER_REQUEST, and exits when one is pending. int montauk::power_request(int action); int montauk::power_request_pending(); .B SYS_POWERINFO (149) Get the CPU power/thermal snapshot (HWP state, throttling, package temperature, base/max/effective frequency). Returns 0 on success, -1 if unsupported by the running hardware. montauk::abi::PowerInfo out; int64_t rc = montauk::syscall1( montauk::abi::SYS_POWERINFO, (uint64_t)&out); .SH KERNEL LOG .B SYS_LOG (46) Read from the kernel ring log buffer. Requires CAP_LOG_READ. int64_t montauk::read_log(char* buf, uint64_t size); .B SYS_LOG_WRITE (176) Append a userspace message to the system log. int64_t montauk::write_log(const char* message); .SH I/O REDIRECTION Used by the terminal app and similar programs to run a child process with its console I/O captured instead of going directly to the framebuffer console. .B SYS_SPAWN_REDIR (49) Spawn a process with its console I/O redirected to the caller. The child receives no capabilities. int montauk::spawn_redir(const char* path, const char* args = nullptr); .B SYS_SPAWN_REDIR_CAPS (186) Spawn a redirected child with explicit capability masks. It applies the same subset and parent-delegable checks as SYS_SPAWN_CAPS. An administrative console explicitly lets its shell delegate selected capabilities; the shell's executable policy gives each trusted tool a delegable mask of zero, preventing further propagation. int montauk::spawn_redir_with_caps( const char* path, const char* args, const montauk::abi::SpawnCapabilities& capabilities); .B SYS_CHILDIO_READ (50) Read buffered output produced by a redirected child. int montauk::childio_read(int childPid, char* buf, int maxLen); .B SYS_CHILDIO_WRITE (51) Write text input to a redirected child's stdin. int montauk::childio_write(int childPid, const char* data, int len); .B SYS_CHILDIO_WRITEKEY (52) Forward a raw key event to a redirected child. int montauk::childio_writekey( int childPid, const montauk::abi::KeyEvent* key); .B SYS_CHILDIO_SETTERMSZ (53) Tell a redirected child its terminal dimensions changed. int montauk::childio_settermsz(int childPid, int cols, int rows); .B SYS_TERMINAL_ATTACHED (177) Return 1 when the calling process has a redirected userspace terminal output stream, otherwise return 0. bool montauk::terminal_attached(); .SH WINDOW SERVER Window server syscalls are used by GUI programs to create and drive an on-screen window (see montauk/Window.hpp for the higher-level win_create/win_poll/win_present wrappers built on top of these). .B SYS_WINCREATE (54) Create a window and get its pixel buffer. int montauk::win_create(const char* title, int w, int h, montauk::abi::WinCreateResult* result); .B SYS_WINDESTROY (55) Destroy a window. int montauk::win_destroy(int id); .B SYS_WINPRESENT (56) Flush the pixel buffer to the screen. uint64_t montauk::win_present(int id); .B SYS_WINPOLL (57) Poll the next event (key, mouse, resize, close, scale) for a window. int montauk::win_poll(int id, montauk::abi::WinEvent* event); .B SYS_WINENUM (58) Enumerate all windows currently managed by the window server. int montauk::win_enumerate(montauk::abi::WinInfo* info, int max); .B SYS_WINMAP (59) Map (or re-map) a window's pixel buffer into the caller's address space. uint64_t montauk::win_map(int id); .B SYS_WINUNMAP (97) Unmap a window's pixel buffer from the caller's address space. int montauk::win_unmap(int id); .B SYS_WINSENDEVENT (60) Inject an event into a window's event queue. int montauk::win_sendevent(int id, const montauk::abi::WinEvent* event); .B SYS_WINRESIZE (64) Resize a window and its pixel buffer. uint64_t montauk::win_resize(int id, int w, int h); .B SYS_WINSETSCALE (65) Set the desktop-wide UI scale factor. int montauk::win_setscale(int scale); .B SYS_WINGETSCALE (66) Get the desktop-wide UI scale factor. int montauk::win_getscale(); .B SYS_WINSETCURSOR (68) Set the mouse cursor shown while over a window (0=arrow, 1=resize_h, 2=resize_v). int montauk::win_setcursor(int id, int cursor); .B SYS_WINSETFLAGS (126) Set window flags (e.g. WIN_FLAG_FULLSCREEN). int montauk::win_setflags(int id, uint32_t flags); .SH DEVICES .B SYS_DEVLIST (63) Enumerate detected devices (CPU, interrupts, timers, input, USB, network, display, storage, PCI, audio, ACPI) for the device explorer app. int montauk::devlist(montauk::abi::DevInfo* buf, int max); .B SYS_DISKINFO (69) Get detailed info for one block device (model, serial, sector size, NCQ/TRIM/SMART support, etc.). int montauk::diskinfo(montauk::abi::DiskInfo* buf, int port); .SH STORAGE .B SYS_PARTLIST (70) Enumerate GPT partitions across all block devices. int montauk::partlist(montauk::abi::PartInfo* buf, int max); .B SYS_DISKREAD (71) Raw, driver-agnostic sector read from a block device. Requires CAP_RAW_STORAGE. int64_t montauk::disk_read(int blockDev, uint64_t lba, uint32_t sectorCount, void* buf); .B SYS_DISKWRITE (72) Raw, driver-agnostic sector write to a block device. Requires CAP_RAW_STORAGE. int64_t montauk::disk_write(int blockDev, uint64_t lba, uint32_t sectorCount, const void* buf); .B SYS_GPTINIT (73) Initialize a fresh GPT partition table on a block device. Requires CAP_STORAGE_ADMIN. int montauk::gpt_init(int blockDev); .B SYS_GPTADD (74) Add a partition to an existing GPT table. Requires CAP_STORAGE_ADMIN. int montauk::gpt_add(const montauk::abi::GptAddParams* params); .B SYS_FSMOUNT (75) Mount a partition's filesystem onto a drive number. Requires CAP_STORAGE_ADMIN. int montauk::fs_mount(int partIndex, int driveNum); .B SYS_FSFORMAT (76) Format a partition with a filesystem (FS_TYPE_FAT32 or FS_TYPE_EXT2). Requires CAP_STORAGE_ADMIN. int montauk::fs_format(const montauk::abi::FsFormatParams* params); .B SYS_FS_SYNC (134) Flush all block-device write caches and cleanly unmount disk-backed volumes ahead of power-off. Returns the number of volumes unmounted. Part of the graceful shutdown sequence (see SYS_POWER_REQUEST). Requires CAP_STORAGE_ADMIN. int montauk::fs_sync(); .SH AUDIO .B SYS_AUDIOOPEN (80) Open a mixer output stream at the given sample rate, channel count, and bit depth. Returns a stream handle. int montauk::audio_open(uint32_t sampleRate, uint8_t channels, uint8_t bitsPerSample); .B SYS_AUDIOCLOSE (81) Close an audio stream. void montauk::audio_close(int handle); .B SYS_AUDIOWRITE (82) Write PCM samples to an audio stream. int montauk::audio_write(int handle, const void* data, uint32_t size); .B SYS_AUDIOCTL (83) Control an audio stream or the global mixer. Commands 0-3 act on the stream named by the handle argument; commands 4-12 act on that stream's routing/mute state or the global master and ignore or reuse the handle as documented below. int montauk::audio_ctl(int handle, int cmd, int value); Convenience wrappers (all thin calls onto audio_ctl): audio_set_volume, audio_get_volume AUDIO_CTL_{SET,GET}_VOLUME (0/1) audio_get_pos AUDIO_CTL_GET_POS (2) audio_pause, audio_resume AUDIO_CTL_PAUSE (3) audio_get_output GET_OUTPUT (4): 0=HDA, 1=Bluetooth audio_set_output SET_OUTPUT (5): all streams audio_ctl(handle, 5, output) SET_OUTPUT (5): one stream audio_bt_status BT_STATUS (6): unavailable/setup/ready audio_set_master_volume SET_MASTER_VOLUME (7), 0-100 audio_get_master_volume GET_MASTER_VOLUME (8) audio_set_mute, audio_get_mute MUTE (9/10), per-stream audio_set_master_mute SET_MASTER_MUTE (11) audio_get_master_mute GET_MASTER_MUTE (12) .B SYS_AUDIOLIST (128) Enumerate active mixer streams (owner PID, name, format, volume, mute/pause state). int montauk::audio_list(montauk::abi::AudioStreamInfo* buf, int maxCount); .B SYS_AUDIOWAIT (129) Return the current mixer state serial. With timeoutMs > 0, blocks until the serial differs from prevSerial or the timeout elapses; with timeoutMs == 0 it returns immediately. uint64_t montauk::audio_wait(uint64_t prevSerial, uint64_t timeoutMs); .SH BLUETOOTH .B SYS_BTSCAN (84) Scan for discoverable Bluetooth devices for up to timeoutMs. Requires CAP_DEVICE_ADMIN because it changes radio state. int montauk::bt_scan(montauk::abi::BtScanResult* buf, int maxCount, uint32_t timeoutMs); .B SYS_BTCONNECT (85) Connect (and pair/bond if needed) to a device by BD_ADDR. Requires CAP_DEVICE_ADMIN. int montauk::bt_connect(const uint8_t* bdAddr); .B SYS_BTDISCONNECT (86) Disconnect from a device by BD_ADDR. Requires CAP_DEVICE_ADMIN. int montauk::bt_disconnect(const uint8_t* bdAddr); .B SYS_BTLIST (87) List currently connected devices. int montauk::bt_list(montauk::abi::BtDevInfo* buf, int maxCount); .B SYS_BTINFO (88) Get local adapter info (BD_ADDR, name, init/scanning state). int montauk::bt_info(montauk::abi::BtAdapterInfo* buf); .B SYS_BTSETADDR (137) Change the adapter's BD_ADDR (6-byte buffer, byte 0 is the least-significant octet). Volatile -- apply after the last controller reset and persist separately to bluetooth.toml. Requires CAP_DEVICE_ADMIN. int montauk::bt_set_addr(const uint8_t* bdAddr); .B SYS_BTBONDS (138) List bonded (paired) devices. int montauk::bt_bonds(montauk::abi::BtBondInfo* buf, int maxCount); .B SYS_BTFORGET (139) Forget a paired device; it must re-pair next time. Requires CAP_DEVICE_ADMIN. int montauk::bt_forget(const uint8_t* bdAddr); .SH GENERIC USB INTERFACES Process-owned access to USB interfaces that do not have a bound kernel class driver. Claims are exclusive and are released automatically at process exit. The current xHCI device model records one interface per device slot, so claiming that interface temporarily claims the whole slot. Kernel-owned HID, Bluetooth, mass-storage, and RTL-SDR interfaces are visible in SYS_USB_LIST but cannot be claimed. .B SYS_USB_LIST (178) List currently connected USB interfaces. Each UsbInterfaceInfo contains stable identifiers for the current connection, endpoint addresses, maximum packet sizes, and kernelDriverBound/claimed flags. int montauk::usb_list(montauk::abi::UsbInterfaceInfo* buf, int maxCount); .B SYS_USB_CLAIM (179) Exclusively claim an unbound interface. Returns a generation-checked handle owned by the calling process. Requires CAP_DEVICE_ADMIN; subsequent operations are authorized by ownership of that handle. int montauk::usb_claim(uint8_t slotId, uint8_t interfaceNumber); .B SYS_USB_CLOSE (180) Stop active transfers and release a USB claim. int montauk::usb_close(int handle); .B SYS_USB_CONTROL (181) Execute a USB control transfer on endpoint zero. The requestType direction bit determines whether data is read or written. request.length must equal dataLen; control payloads are currently limited to 4096 bytes. int montauk::usb_control( int handle, const montauk::abi::UsbControlRequest* request, void* data, uint32_t dataLen); .B SYS_USB_BULK_IN_START (182) Start a continuous bulk-IN transfer pool. transferBytes is 1..4096 and bufferCount is 1..16. Completed data is copied into a 256 KiB per-claim ring buffer. int montauk::usb_bulk_in_start(int handle, uint32_t transferBytes, uint32_t bufferCount); .B SYS_USB_BULK_IN_STOP (183) Stop continuous bulk-IN transfers without releasing the claim. int montauk::usb_bulk_in_stop(int handle); .B SYS_USB_BULK_IN_READ (184) Non-blocking read from the bulk-IN ring. Returns bytes copied, zero when no data is queued, or USB_ERR_DISCONNECTED after queued data has been drained. int montauk::usb_bulk_in_read(int handle, void* data, uint32_t dataLen); Errors are USB_ERR_INVALID (-1), USB_ERR_BUSY (-2), USB_ERR_DISCONNECTED (-3), USB_ERR_UNSUPPORTED (-4), USB_ERR_IO (-5), USB_ERR_NO_RESOURCES (-6), USB_ERR_NOT_FOUND (-7), and USB_ERR_KERNEL_BOUND (-8). .SH RESERVED SYSCALL NUMBERS Syscall numbers 140 through 148 are reserved. They were used by an experimental kernel SDR API and are intentionally not dispatched or exposed through userspace syscall wrappers. RTL-SDR support is provided by 0:/os/rtlsdr.lib over the generic userspace USB API. .SH CLIPBOARD .B SYS_CLIPBOARD_SET_TEXT (119) Set the system clipboard's text contents (max CLIPBOARD_MAX_TEXT_BYTES, 256 KiB). int montauk::clipboard_set_text(const char* data, uint32_t len); .B SYS_CLIPBOARD_GET_INFO (120) Get the clipboard's current size and serial number (for change detection). int montauk::clipboard_get_info(montauk::abi::ClipboardInfo* out); .B SYS_CLIPBOARD_GET_TEXT (121) Read the clipboard's text contents. int montauk::clipboard_get_text(char* buf, uint32_t bufLen, uint32_t* outLen, uint64_t* outSerial = nullptr); .B SYS_CLIPBOARD_CLEAR (122) Clear the clipboard. int montauk::clipboard_clear(); .SH GENERIC IPC Handle-based IPC primitives underlying streams, mailboxes, waitsets, and shared-memory surfaces (see kernel/src/Ipc/Ipc.hpp). All are accessed via numeric handles with rights-based security and can be waited on with SYS_WAIT_HANDLE or a waitset. .B SYS_DUPHANDLE (98) Duplicate a handle (e.g. to hand a copy to a child process). int montauk::dup_handle(int handle); .B SYS_WAIT_HANDLE (99) Block until a handle's signals intersect wantedSignals, or timeoutMs elapses. See IPC_SIGNAL_* (READABLE, WRITABLE, PEER_CLOSED, EXITED, READY). uint32_t montauk::wait_handle(int handle, uint32_t wantedSignals, uint64_t timeoutMs = ~0ULL); .B SYS_STREAM_CREATE (100) Create a byte-pipe stream, returning a read handle and a write handle. int montauk::stream_create(int* outReadHandle, int* outWriteHandle, uint32_t capacity = 0); .B SYS_STREAM_READ (101) Read bytes from a stream handle. int montauk::stream_read(int handle, void* buf, int maxLen); .B SYS_STREAM_WRITE (102) Write bytes to a stream handle. int montauk::stream_write(int handle, const void* data, int len); .B SYS_MAILBOX_CREATE (103) Create a message-queue mailbox, returning a send handle and a receive handle. int montauk::mailbox_create(int* outSendHandle, int* outRecvHandle); .B SYS_MAILBOX_SEND (104) Send a typed message, optionally attaching a handle to transfer to the receiver. int montauk::mailbox_send(int handle, uint32_t msgType, const void* data, uint16_t len, int attachHandle = -1); .B SYS_MAILBOX_RECV (105) Receive a message. int montauk::mailbox_recv(int handle, uint32_t* outMsgType, void* data, uint16_t* inOutLen, int* outAttachHandle = nullptr); .B SYS_WAITSET_CREATE (106) Create a waitset for multiplexing waits across many handles. int montauk::waitset_create(); .B SYS_WAITSET_ADD (107) Add a handle and its signal mask to a waitset. int montauk::waitset_add(int waitsetHandle, int targetHandle, uint32_t signals); .B SYS_WAITSET_REMOVE (108) Remove an entry from a waitset by index. int montauk::waitset_remove(int waitsetHandle, int index); .B SYS_WAITSET_WAIT (109) Block until any member handle's watched signals fire, or timeoutMs elapses. int montauk::waitset_wait( int waitsetHandle, montauk::abi::IpcWaitResult* outReady, uint64_t timeoutMs = ~0ULL); .B SYS_PROC_OPEN (110) Open a handle to another process by PID (for waiting on its exit via IPC_SIGNAL_EXITED, etc.). int montauk::proc_open(int pid); .B SYS_SURFACE_CREATE (111) Create a shared pixel-buffer surface of byteSize bytes. int montauk::surface_create(uint64_t byteSize); .B SYS_SURFACE_MAP (112) Map a surface into the caller's address space. void* montauk::surface_map(int handle); .B SYS_SURFACE_RESIZE (113) Resize a surface. int montauk::surface_resize(int handle, uint64_t newSize); .SH SHARED LIBRARIES .B SYS_LOAD_LIB (114) Load a shared library ELF (.lib) into the caller's address space. int montauk::load_lib(const char* path); .B SYS_UNLOAD_LIB (115) Unload a previously loaded library. int montauk::unload_lib(int handle); .B SYS_DLSYM (116) Resolve a symbol offset within a loaded library to a callable address. void* montauk::dlsym(int handle, uint64_t symbolOffset); .B SYS_GETLIBBASE (117) Get the base virtual address a loaded library was mapped at. uint64_t montauk::get_libbase(int handle); .SH CRASH REPORTING .B SYS_CRASH_REPORT (118) Retrieve the kernel-filled crash report for the last faulting process (exception vector/name, faulting address, register state, page-fault error bits). Used by the crashpad app. int montauk::crash_report(montauk::abi::CrashReportInfo* out); .SH SEE ALSO spawn(2), file(2), framebuffer(2), malloc(3), intro(1)