working on api docs
This commit is contained in:
1 parent
56d8fb2016
commit
38d56ced19
43 files changed
+5669
-618
No files matched your search
@@ -0,0 +1,57 @@
|
||||
---@meta EFI
|
||||
|
||||
---@class HyperionOS.kernel.EFI Bootloader interface
|
||||
---@field yield fun() yeilds os to bootloader to prevent watchdog
|
||||
---@field getEpochMs fun(): number gets current epoch ms
|
||||
---@field getUptime fun(): number gets current uptime in ms
|
||||
---@field date fun(): string "!%Y-%m-%dT%H:%M:%SZ" of current ms utc
|
||||
---@field getMachineEvent fun(): ... returns queued machine events
|
||||
---@field getEEPROM fun(): string returns current EEPROM program
|
||||
---@field setEEPROM fun(self, code:string) sets the EEPROM code to code
|
||||
---@field initfs table initfs api
|
||||
---@field disks table disks api
|
||||
---@field screenctl HyperionOS.kernel.EFI.screen screen control handle
|
||||
---@field architecture string architecture signature
|
||||
---@field getNvram fun(): string reads non-volitile ram
|
||||
---@field setNvram fun(self, data:string) sets non-volitile ram
|
||||
---@field firmware table extra apis for drivers to use
|
||||
---@field status string run status
|
||||
---@field beep fun(self, freq:number, ms:number) beep tone
|
||||
|
||||
---@class HyperionOS.kernel.EFI.screen
|
||||
---@field print fun(self, text:string) prints with following \n
|
||||
---@field printInline fun(self, text:string) prints to screen
|
||||
---@field clear fun(self) clears screen
|
||||
---@field resetCursor fun(self) moves cursor to 1,1
|
||||
---@field setBackgroundColor fun(self, color24:number) sets background color
|
||||
---@field setTextColor fun(self, color24:number) sets text color
|
||||
---@field getBackgroundColor fun(self): number returns background color24
|
||||
---@field getTextColor fun(self): number returns text color24
|
||||
---@field enable fun(self) enables the screens
|
||||
---@field disable fun(self) disables the screen
|
||||
|
||||
---@class file
|
||||
---@field read fun(amount:number) reads x bytes from file (r)
|
||||
---@field write fun(data:string) writes data to a file (w, a)
|
||||
---@field flush fun() flushes appending writes (w, a)
|
||||
---@field seek fun(whence:"set"|"cur"|"end", offset:number): number moves the file pointer and returns the new position
|
||||
---@field close fun() closes the open file
|
||||
|
||||
---@class disk
|
||||
---@field address string ID of disk
|
||||
---@field isReadOnly fun(self): boolean Is disk read only?
|
||||
---@field spaceUsed fun(self): number Returns bytes used
|
||||
---@field spaceTotal fun(self): number Returns disk size in bytes
|
||||
---@field list fun(self, path:string) get contents of a directory
|
||||
---@field fileExists fun(self, path:string) does a file exist?
|
||||
---@field directoryExists fun(self, path:string) does a directory exist?
|
||||
---@field type fun(self, path:string): string returns type of a path
|
||||
---@field makeDirectory fun(self, path:string) makes a directory
|
||||
---@field remove fun(self, path:string) delete a file or directory
|
||||
---@field setLabel fun(self, label:string) sets disk label
|
||||
---@field getLabel fun(self): string returns disk label
|
||||
---@field attributes fun(self, path:string) returns path attributes (ex: size and date modified)
|
||||
---@field open fun(self, path:string, mode:string): file opens a file returns handle
|
||||
|
||||
---@class HyperionOS.kernel
|
||||
---@field EFI HyperionOS.kernel.EFI
|
||||
@@ -0,0 +1,15 @@
|
||||
---@meta
|
||||
---@class HyperionOS.kernel.config
|
||||
---@field initPath string The path that init takes to load the init system
|
||||
---@field allowGlobalOverwrites boolean Allow modifying of gloabal env (usually for debug purposes)
|
||||
---@field enableAdvancedDebug boolean Allow debug into the kernel
|
||||
---@field maxOpenFiles number The maximum open files allowed for the whole system
|
||||
---@field maxFilesPerTask number The maximum open files allowed for each task
|
||||
---@field preempt boolean Enable/Disable preemptive multitasking
|
||||
---@field debugSyscalls boolean Logs syscalls and their return values aswell as what task executed them (WILL HARM PREFORMANCE)
|
||||
---@field logTaskExit boolean Logs task exits and errors
|
||||
---@field showModLoad boolean Log module loading
|
||||
---@field tmpToDisk boolean Writes /tmp to disk instead of ramfs
|
||||
---@field logSymlinkTraverse boolean Logs symlink traversal (can harm preformance)
|
||||
---@field moreLogsaves boolean Enables log debug save points (can harm boot time
|
||||
---@field logPathResolution boolean Logs how a vfs path resolves to a disk path (can harm preformance)
|
||||
@@ -0,0 +1,112 @@
|
||||
---@meta Hyperion-kernel
|
||||
--#region kernel
|
||||
|
||||
---@class HyperionOS.kernel
|
||||
--- NOT AVAILBLE IN USERSPACE
|
||||
--- AT TOP DO "local kernel=..." OF YOUR MODULE
|
||||
local kernel={}
|
||||
|
||||
---@class HyperionOS.kernel
|
||||
---@field LOG_Text string
|
||||
---@field version string Human readable version
|
||||
---@field tag string version tag
|
||||
---@field process string current process name
|
||||
---@field users table user translation table
|
||||
---@field hostname string computer hostname
|
||||
---@field groups table unused
|
||||
---@field uid number current task user id
|
||||
---@field gid number unused?
|
||||
---@field status string run status
|
||||
---@field key table a uniq table to identifiy as the kernel if needed
|
||||
---@field cache {preload:{}} unused
|
||||
---@field unixSockets table unixSockets table
|
||||
---@field config HyperionOS.kernel.config
|
||||
|
||||
kernel._G=_G
|
||||
kernel.sleep=sleep
|
||||
|
||||
---@class HyperionOS.userspace.syscall
|
||||
local syscall
|
||||
kernel.syscalls=syscall
|
||||
|
||||
--- Logs a message to the system log and console.
|
||||
--- @param msg string The message to log
|
||||
--- @param tag? string Log tag (defaults to "INFO")
|
||||
--- @param c? number 24-bit RGB color (defaults to 0x6D6D6D)
|
||||
--- @param nopanic? boolean Prevents a logging error from triggering a kernel panic
|
||||
function kernel.log(msg, tag, c, nopanic) end
|
||||
|
||||
--- Crash the OS and display a message
|
||||
--- @param msg string
|
||||
function kernel.panic(msg) end
|
||||
kernel.PANIC=kernel.panic
|
||||
|
||||
--#endregion kernel
|
||||
|
||||
--#region userspace
|
||||
|
||||
--- Returns the current system time in milliseconds.
|
||||
--- @return number
|
||||
function syscall.time() end
|
||||
|
||||
--- Returns the current system date.
|
||||
--- @return string
|
||||
function syscall.date() end
|
||||
|
||||
--- Logs a message to the system log and console.
|
||||
--- @param msg string The message to log
|
||||
--- @param tag? string Log tag (defaults to "INFO")
|
||||
--- @param c? number 24-bit RGB color (defaults to 0x6D6D6D)
|
||||
--- @param nopanic? boolean Prevents a logging error from triggering a kernel panic
|
||||
function syscall.log(msg, tag, c, nopanic) end
|
||||
|
||||
--- Returns the HyperionOS version tag.
|
||||
--- @return string
|
||||
function syscall.tag() end
|
||||
|
||||
--- Returns the system uptime.
|
||||
--- @return number
|
||||
function syscall.getUptime() end
|
||||
|
||||
--- Returns a username.
|
||||
--- @param uid? number User ID (defaults to current user)
|
||||
--- @return string?
|
||||
function syscall.getUsername(uid) end
|
||||
|
||||
--- Returns the system hostname.
|
||||
--- @return string
|
||||
function syscall.getHostname() end
|
||||
|
||||
--- Returns the host environment identifier.
|
||||
--- @return string
|
||||
function syscall.getHost() end
|
||||
|
||||
--- Returns the HyperionOS version.
|
||||
--- @return string
|
||||
function syscall.version() end
|
||||
|
||||
--- Changes the system hostname. Requires root.
|
||||
--- @param name string New hostname
|
||||
function syscall.setHostname(name) end
|
||||
|
||||
--- Returns the system architecture.
|
||||
--- @return string
|
||||
function syscall.arch() end
|
||||
|
||||
--- Returns a list of registered syscall names.
|
||||
--- @return string[]
|
||||
function syscall.sysdump() end
|
||||
|
||||
--- Reboots the system. Requires root or wheel group.
|
||||
function syscall.reboot() end
|
||||
|
||||
--- Shuts down the system. Requires root or wheel group.
|
||||
function syscall.shutdown() end
|
||||
|
||||
--- Halts the system. Requires root or wheel group.
|
||||
function syscall.halt() end
|
||||
|
||||
--- Saves the system log. Requires root or wheel group.
|
||||
function syscall.saveLog() end
|
||||
|
||||
--#endregion userspace
|
||||
@@ -0,0 +1,42 @@
|
||||
--#region loopdev
|
||||
|
||||
---@meta
|
||||
|
||||
--#region kernel
|
||||
---@class HyperionOS.kernel
|
||||
---@field vfs HyperionOS.types.LoopDeviceInfo
|
||||
|
||||
---@class LoopDeviceInfo
|
||||
---@field path string Original directory or image path
|
||||
---@field mode "bind"|"image" Loop device mode
|
||||
|
||||
---Attaches a loop device backed by a directory or filesystem image.
|
||||
---Requires root privileges.
|
||||
---@param path string Directory or .hfs image path
|
||||
---@param forceImage? boolean Force image mode instead of directory bind mode
|
||||
---@return string id Loop device ID
|
||||
function syscall.losetup(path, forceImage) end
|
||||
|
||||
---Detaches a loop device.
|
||||
---The device must be unmounted first.
|
||||
---Requires root privileges.
|
||||
---@param id string Loop device ID
|
||||
function syscall.lodetach(id) end
|
||||
|
||||
---Lists currently attached loop devices.
|
||||
---@return table<string, LoopDeviceInfo> devices
|
||||
function syscall.lolist() end
|
||||
|
||||
---Creates a BHFS binary filesystem image from a VFS directory.
|
||||
---Requires root privileges.
|
||||
---@param srcdir string Source directory
|
||||
---@return string image BHFS binary image data
|
||||
function syscall.loimgcreate(srcdir) end
|
||||
|
||||
---Writes a BHFS image string to a file.
|
||||
---Requires root privileges.
|
||||
---@param image string BHFS binary image data
|
||||
---@param dest string Destination file path
|
||||
function syscall.loimgwrite(image, dest) end
|
||||
|
||||
--#endregion loopdev
|
||||
@@ -0,0 +1,393 @@
|
||||
---@meta
|
||||
|
||||
--#region kernel
|
||||
---@class HyperionOS.kernel
|
||||
---@field vfs HyperionOS.kernel.vfs
|
||||
|
||||
---@class HyperionOS.kernel.vfs
|
||||
local vfs={}
|
||||
|
||||
--- Opens a file and returns its file descriptor.
|
||||
--- @param path string File path
|
||||
--- @param mode string Open mode ("r", "w", or "a")
|
||||
--- @return integer fd
|
||||
function vfs.open(path, mode) end
|
||||
|
||||
--- Closes a file descriptor.
|
||||
--- @param fd integer
|
||||
function vfs.close(fd) end
|
||||
|
||||
--- Reads data from a file descriptor.
|
||||
--- @param fd integer
|
||||
--- @param count? integer Number of bytes to read
|
||||
--- @return string
|
||||
function vfs.read(fd, count) end
|
||||
|
||||
--- Writes data to a file descriptor.
|
||||
--- @param fd integer
|
||||
--- @param content string Data to write
|
||||
function vfs.write(fd, content) end
|
||||
|
||||
--- Reads data from a file at a specific offset without changing its position.
|
||||
--- @param fd integer
|
||||
--- @param count integer Number of bytes to read
|
||||
--- @param offset integer File offset
|
||||
--- @return string
|
||||
function vfs.pread(fd, count, offset) end
|
||||
|
||||
--- Writes data to a file at a specific offset without changing its position.
|
||||
--- @param fd integer
|
||||
--- @param content string Data to write
|
||||
--- @param offset integer File offset
|
||||
function vfs.pwrite(fd, content, offset) end
|
||||
|
||||
--- Changes the current file position.
|
||||
--- @param fd integer
|
||||
--- @param offset integer
|
||||
--- @param whence? string Position reference ("set", "cur", or "end")
|
||||
--- @return integer
|
||||
function vfs.lseek(fd, offset, whence) end
|
||||
|
||||
--- Flushes pending file writes.
|
||||
--- @param fd integer
|
||||
function vfs.fsync(fd) end
|
||||
|
||||
--- Copies data between file descriptors.
|
||||
--- @param outfd integer Destination file descriptor
|
||||
--- @param infd integer Source file descriptor
|
||||
--- @param count? integer Number of bytes to copy
|
||||
function vfs.sendfile(outfd, infd, count) end
|
||||
|
||||
--- Gets file information by path, following symlinks.
|
||||
--- @param path string
|
||||
--- @return table
|
||||
function vfs.stat(path) end
|
||||
|
||||
--- Gets file information by path without following symlinks.
|
||||
--- @param path string
|
||||
--- @return table
|
||||
function vfs.lstat(path) end
|
||||
|
||||
--- Gets file information from an open file descriptor.
|
||||
--- @param fd integer
|
||||
--- @return table
|
||||
function vfs.fstat(fd) end
|
||||
|
||||
--- Creates a directory.
|
||||
--- @param path string
|
||||
function vfs.mkdir(path) end
|
||||
|
||||
--- Removes a file, directory, or symlink.
|
||||
--- @param path string
|
||||
function vfs.remove(path) end
|
||||
|
||||
--- Lists the contents of a directory.
|
||||
--- @param path string
|
||||
--- @return string[]
|
||||
function vfs.listdir(path) end
|
||||
|
||||
--- Changes file permissions.
|
||||
--- @param path string
|
||||
--- @param perms integer Permission bitmask
|
||||
function vfs.chmod(path, perms) end
|
||||
|
||||
--- Changes permissions using a file descriptor.
|
||||
--- @param fd integer
|
||||
--- @param perms integer Permission bitmask
|
||||
function vfs.fchmod(fd, perms) end
|
||||
|
||||
--- Changes file ownership.
|
||||
--- @param path string
|
||||
--- @param uid integer User ID
|
||||
--- @param gid integer Group ID
|
||||
function vfs.chown(path, uid, gid) end
|
||||
|
||||
--- Changes ownership using a file descriptor.
|
||||
--- @param fd integer
|
||||
--- @param uid integer User ID
|
||||
--- @param gid integer Group ID
|
||||
function vfs.fchown(fd, uid, gid) end
|
||||
|
||||
--- Checks whether a path exists.
|
||||
--- @param path string
|
||||
--- @return boolean
|
||||
function vfs.exists(path) end
|
||||
|
||||
--- Returns the type of a path.
|
||||
--- @param path string
|
||||
--- @return string|nil
|
||||
function vfs.type(path) end
|
||||
|
||||
--- Mounts a disk or bind mount.
|
||||
--- @param target string Mount point
|
||||
--- @param diskOrId string|table Disk ID or disk object
|
||||
--- @param bind? boolean Whether this is a bind mount
|
||||
--- @param floating? boolean Whether this is a floating mount
|
||||
--- @return boolean
|
||||
function vfs.mount(target, diskOrId, bind, floating) end
|
||||
|
||||
--- Unmounts a filesystem.
|
||||
--- @param target string Mount point
|
||||
--- @return boolean
|
||||
function vfs.umount(target) end
|
||||
|
||||
--- Returns the current working directory.
|
||||
--- @return string
|
||||
function vfs.getcwd() end
|
||||
|
||||
--- Changes the current working directory.
|
||||
--- @param path string
|
||||
function vfs.chdir(path) end
|
||||
|
||||
--- Changes the process root directory. Requires root.
|
||||
--- @param path string
|
||||
function vfs.chroot(path) end
|
||||
|
||||
--- Duplicates a file descriptor.
|
||||
--- @param oldfd integer
|
||||
--- @return integer
|
||||
function vfs.dup(oldfd) end
|
||||
|
||||
--- Duplicates a file descriptor to a specific descriptor number.
|
||||
--- @param oldfd integer
|
||||
--- @param newfd integer
|
||||
--- @return integer
|
||||
function vfs.dup2(oldfd, newfd) end
|
||||
|
||||
--- Calls a method on an open device.
|
||||
--- @param fd integer Device file descriptor
|
||||
--- @param method string Device method name
|
||||
--- @param ... any Method arguments
|
||||
--- @return any ...
|
||||
function vfs.devctl(fd, method, ...) end
|
||||
|
||||
--- Lists available methods on an open device.
|
||||
--- @param fd integer Device file descriptor
|
||||
--- @return string[]
|
||||
function vfs.devlst(fd) end
|
||||
|
||||
--- Creates a symbolic link.
|
||||
--- @param target string Link target
|
||||
--- @param linkPath string Path of the new symlink
|
||||
function vfs.symlink(target, linkPath) end
|
||||
|
||||
--- Reads the target of a symbolic link.
|
||||
--- @param path string
|
||||
--- @return string
|
||||
function vfs.readlink(path) end
|
||||
|
||||
--- Checks access permissions for a path.
|
||||
--- @param path string
|
||||
--- @param mode string Permission checks ("r", "w", "x", or combinations)
|
||||
--- @return boolean
|
||||
function vfs.access(path, mode) end
|
||||
|
||||
--- Gets the SUID owner associated with an open file descriptor.
|
||||
--- @param fd integer
|
||||
--- @return integer|nil
|
||||
function vfs.fget_suid(fd) end
|
||||
|
||||
--- Returns the paths associated with open file descriptors.
|
||||
--- @return string[]
|
||||
function vfs.getOpenFds() end
|
||||
|
||||
--- Returns filesystem mount and disk information.
|
||||
--- @return table
|
||||
function vfs.fsinfo() end
|
||||
|
||||
--#endregion kernel
|
||||
|
||||
--#region userspace
|
||||
|
||||
---@class HyperionOS.userspace.syscall
|
||||
local syscall={}
|
||||
|
||||
--- Opens a file and returns its file descriptor.
|
||||
--- @param path string File path
|
||||
--- @param mode string Open mode ("r", "w", or "a")
|
||||
--- @return integer fd
|
||||
function syscall.open(path, mode) end
|
||||
|
||||
--- Closes a file descriptor.
|
||||
--- @param fd integer
|
||||
function syscall.close(fd) end
|
||||
|
||||
--- Reads data from a file descriptor.
|
||||
--- @param fd integer
|
||||
--- @param count? integer Number of bytes to read
|
||||
--- @return string
|
||||
function syscall.read(fd, count) end
|
||||
|
||||
--- Writes data to a file descriptor.
|
||||
--- @param fd integer
|
||||
--- @param content string Data to write
|
||||
function syscall.write(fd, content) end
|
||||
|
||||
--- Reads data from a file at a specific offset without changing its position.
|
||||
--- @param fd integer
|
||||
--- @param count integer Number of bytes to read
|
||||
--- @param offset integer File offset
|
||||
--- @return string
|
||||
function syscall.pread(fd, count, offset) end
|
||||
|
||||
--- Writes data to a file at a specific offset without changing its position.
|
||||
--- @param fd integer
|
||||
--- @param content string Data to write
|
||||
--- @param offset integer File offset
|
||||
function syscall.pwrite(fd, content, offset) end
|
||||
|
||||
--- Changes the current file position.
|
||||
--- @param fd integer
|
||||
--- @param offset integer
|
||||
--- @param whence? string Position reference ("set", "cur", or "end")
|
||||
--- @return integer
|
||||
function syscall.lseek(fd, offset, whence) end
|
||||
|
||||
--- Flushes pending file writes.
|
||||
--- @param fd integer
|
||||
function syscall.fsync(fd) end
|
||||
|
||||
--- Copies data between file descriptors.
|
||||
--- @param outfd integer Destination file descriptor
|
||||
--- @param infd integer Source file descriptor
|
||||
--- @param count? integer Number of bytes to copy
|
||||
function syscall.sendfile(outfd, infd, count) end
|
||||
|
||||
--- Gets file information by path, following symlinks.
|
||||
--- @param path string
|
||||
--- @return table
|
||||
function syscall.stat(path) end
|
||||
|
||||
--- Gets file information by path without following symlinks.
|
||||
--- @param path string
|
||||
--- @return table
|
||||
function syscall.lstat(path) end
|
||||
|
||||
--- Gets file information from an open file descriptor.
|
||||
--- @param fd integer
|
||||
--- @return table
|
||||
function syscall.fstat(fd) end
|
||||
|
||||
--- Creates a directory.
|
||||
--- @param path string
|
||||
function syscall.mkdir(path) end
|
||||
|
||||
--- Removes a file, directory, or symlink.
|
||||
--- @param path string
|
||||
function syscall.remove(path) end
|
||||
|
||||
--- Lists the contents of a directory.
|
||||
--- @param path string
|
||||
--- @return string[]
|
||||
function syscall.listdir(path) end
|
||||
|
||||
--- Changes file permissions.
|
||||
--- @param path string
|
||||
--- @param perms integer Permission bitmask
|
||||
function syscall.chmod(path, perms) end
|
||||
|
||||
--- Changes permissions using a file descriptor.
|
||||
--- @param fd integer
|
||||
--- @param perms integer Permission bitmask
|
||||
function syscall.fchmod(fd, perms) end
|
||||
|
||||
--- Changes file ownership.
|
||||
--- @param path string
|
||||
--- @param uid integer User ID
|
||||
--- @param gid integer Group ID
|
||||
function syscall.chown(path, uid, gid) end
|
||||
|
||||
--- Changes ownership using a file descriptor.
|
||||
--- @param fd integer
|
||||
--- @param uid integer User ID
|
||||
--- @param gid integer Group ID
|
||||
function syscall.fchown(fd, uid, gid) end
|
||||
|
||||
--- Checks whether a path exists.
|
||||
--- @param path string
|
||||
--- @return boolean
|
||||
function syscall.exists(path) end
|
||||
|
||||
--- Returns the type of a path.
|
||||
--- @param path string
|
||||
--- @return string|nil
|
||||
function syscall.type(path) end
|
||||
|
||||
--- Mounts a disk or bind mount.
|
||||
--- @param target string Mount point
|
||||
--- @param diskOrId string|table Disk ID or disk object
|
||||
--- @param bind? boolean Whether this is a bind mount
|
||||
--- @param floating? boolean Whether this is a floating mount
|
||||
--- @return boolean
|
||||
function syscall.mount(target, diskOrId, bind, floating) end
|
||||
|
||||
--- Unmounts a filesystem.
|
||||
--- @param target string Mount point
|
||||
--- @return boolean
|
||||
function syscall.umount(target) end
|
||||
|
||||
--- Returns the current working directory.
|
||||
--- @return string
|
||||
function syscall.getcwd() end
|
||||
|
||||
--- Changes the current working directory.
|
||||
--- @param path string
|
||||
function syscall.chdir(path) end
|
||||
|
||||
--- Changes the process root directory. Requires root.
|
||||
--- @param path string
|
||||
function syscall.chroot(path) end
|
||||
|
||||
--- Duplicates a file descriptor.
|
||||
--- @param oldfd integer
|
||||
--- @return integer
|
||||
function syscall.dup(oldfd) end
|
||||
|
||||
--- Duplicates a file descriptor to a specific descriptor number.
|
||||
--- @param oldfd integer
|
||||
--- @param newfd integer
|
||||
--- @return integer
|
||||
function syscall.dup2(oldfd, newfd) end
|
||||
|
||||
--- Calls a method on an open device.
|
||||
--- @param fd integer Device file descriptor
|
||||
--- @param method string Device method name
|
||||
--- @param ... any Method arguments
|
||||
--- @return any ...
|
||||
function syscall.devctl(fd, method, ...) end
|
||||
|
||||
--- Lists available methods on an open device.
|
||||
--- @param fd integer Device file descriptor
|
||||
--- @return string[]
|
||||
function syscall.devlst(fd) end
|
||||
|
||||
--- Creates a symbolic link.
|
||||
--- @param target string Link target
|
||||
--- @param linkPath string Path of the new symlink
|
||||
function syscall.symlink(target, linkPath) end
|
||||
|
||||
--- Reads the target of a symbolic link.
|
||||
--- @param path string
|
||||
--- @return string
|
||||
function syscall.readlink(path) end
|
||||
|
||||
--- Checks access permissions for a path.
|
||||
--- @param path string
|
||||
--- @param mode string Permission checks ("r", "w", "x", or combinations)
|
||||
--- @return boolean
|
||||
function syscall.access(path, mode) end
|
||||
|
||||
--- Gets the SUID owner associated with an open file descriptor.
|
||||
--- @param fd integer
|
||||
--- @return integer|nil
|
||||
function syscall.fget_suid(fd) end
|
||||
|
||||
--- Returns the paths associated with open file descriptors.
|
||||
--- @return string[]
|
||||
function syscall.getOpenFds() end
|
||||
|
||||
--- Returns filesystem mount and disk information.
|
||||
--- @return table
|
||||
function syscall.fsinfo() end
|
||||
|
||||
--#endregion userspace
|
||||
@@ -0,0 +1,6 @@
|
||||
---@meta
|
||||
---@class HyperionOS
|
||||
---@field version "1.2.5"
|
||||
|
||||
---@type HyperionOS.userspace.syscall
|
||||
syscall={}
|
||||
@@ -0,0 +1,509 @@
|
||||
|
||||
--#region vfs
|
||||
|
||||
--#endregion vfs
|
||||
|
||||
--#region signals
|
||||
|
||||
---@class SignalHandle
|
||||
---@field error string Error message if the handler fails
|
||||
---@field active boolean Whether the signal handler is active
|
||||
|
||||
---Sends a signal to a process.
|
||||
---@param pid number|string Process ID
|
||||
---@param sig number Signal number (0–256)
|
||||
function syscall.sigsend(pid, sig) end
|
||||
|
||||
---Registers a signal handler for the current process.
|
||||
---@param handler fun(sig: number) Signal callback
|
||||
---@return SignalHandle handle Signal handler state
|
||||
function syscall.sigcatch(handler) end
|
||||
|
||||
---Removes the current process's signal handler and pending signals.
|
||||
function syscall.sigignore() end
|
||||
|
||||
--#endregion signals
|
||||
|
||||
--#region socket
|
||||
|
||||
---Creates a new socket file descriptor.
|
||||
---@return number fd Socket file descriptor
|
||||
function syscall.socket() end
|
||||
|
||||
---Connects a socket to an address using a registered protocol handler.
|
||||
---@param fd number Socket file descriptor
|
||||
---@param address string Remote address
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error Error code on failure
|
||||
function syscall.connect(fd, address) end
|
||||
|
||||
---Starts listening on a socket.
|
||||
---@param fd number Socket file descriptor
|
||||
---@param backlog? number Maximum pending connections
|
||||
---@return any result
|
||||
---@return string|nil error Error code on failure
|
||||
function syscall.listen(fd, backlog) end
|
||||
|
||||
---Sends data through a connected socket.
|
||||
---@param fd number Socket file descriptor
|
||||
---@param data string Data to send
|
||||
---@return any result
|
||||
---@return string|nil error Error code on failure
|
||||
function syscall.send(fd, data) end
|
||||
|
||||
---Receives data from a connected socket.
|
||||
---May yield while waiting for data.
|
||||
---@param fd number Socket file descriptor
|
||||
---@param amount? number Maximum amount of data to receive
|
||||
---@return string|nil data Received data
|
||||
---@return string|nil error Error code on failure
|
||||
function syscall.recv(fd, amount) end
|
||||
|
||||
---Shuts down a socket connection.
|
||||
---@param fd number Socket file descriptor
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error Error code on failure
|
||||
function syscall.sockshutdown(fd) end
|
||||
|
||||
---Returns the registered socket protocol prefixes.
|
||||
---@return string[] endpoints
|
||||
function syscall.socketendpoints() end
|
||||
|
||||
--#endregion socket
|
||||
|
||||
--#region auth
|
||||
|
||||
---@class PasswdEntry
|
||||
---@field uid number User ID
|
||||
---@field gid number Group ID
|
||||
---@field username string Username
|
||||
---@field homedir string Home directory
|
||||
---@field shell string Login shell
|
||||
|
||||
---@class UserInfo: PasswdEntry
|
||||
---@field locked boolean Whether the account is locked
|
||||
|
||||
---Authenticates a user and sets the current task's user and group IDs.
|
||||
---@param uid number User ID
|
||||
---@param password string Password
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error
|
||||
function syscall.login(uid, password) end
|
||||
|
||||
---Changes a user's password.
|
||||
---Root can change any user's password; users can change their own.
|
||||
---@param uid number User ID
|
||||
---@param newPassword string New password (minimum 6 characters)
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error
|
||||
function syscall.setpassword(uid, newPassword) end
|
||||
|
||||
---Changes a user's username. Root only.
|
||||
---@param uid number User ID
|
||||
---@param newUsername string New username
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error
|
||||
function syscall.setusername(uid, newUsername) end
|
||||
|
||||
---Creates a new user account. Root only.
|
||||
---@param username string Username
|
||||
---@param password string Password (minimum 6 characters)
|
||||
---@param gid? number Group ID (defaults to the new UID)
|
||||
---@param homedir? string Home directory (defaults to /home/username)
|
||||
---@param shell? string Login shell (defaults to /bin/hysh)
|
||||
---@return number|nil uid New user ID
|
||||
---@return string|nil error
|
||||
function syscall.newuser(username, password, gid, homedir, shell) end
|
||||
|
||||
---Returns the current user's username.
|
||||
---@return string|nil username
|
||||
---@return string|nil error
|
||||
function syscall.whoami() end
|
||||
|
||||
---Gets a user's UID by username.
|
||||
---@param username string Username
|
||||
---@return number|nil uid
|
||||
function syscall.getuidbyname(username) end
|
||||
|
||||
---Gets a user's passwd information.
|
||||
---@param uid number User ID
|
||||
---@return PasswdEntry|nil entry
|
||||
function syscall.getpasswd(uid) end
|
||||
|
||||
---Elevates the current task to root after authenticating another account.
|
||||
---@param targetUsername string Username to authenticate against
|
||||
---@param password string Account password
|
||||
---@return boolean|nil success
|
||||
---@return number|string|nil previousUidOrError
|
||||
function syscall.elevate(targetUsername, password) end
|
||||
|
||||
---Deletes a user account. Root only. Cannot delete UID 0.
|
||||
---@param uid number User ID
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error
|
||||
function syscall.deleteuser(uid) end
|
||||
|
||||
---Locks a user account. Root only. Cannot lock UID 0.
|
||||
---@param uid number User ID
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error
|
||||
function syscall.lockuser(uid) end
|
||||
|
||||
---Unlocks a user account. Root only.
|
||||
---@param uid number User ID
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error
|
||||
function syscall.unlockuser(uid) end
|
||||
|
||||
---Lists all user accounts.
|
||||
---@return UserInfo[] users
|
||||
function syscall.listusers() end
|
||||
|
||||
---Changes a user's login shell.
|
||||
---Root or the account owner can change it.
|
||||
---@param uid number User ID
|
||||
---@param shell string Shell path
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error
|
||||
function syscall.setshell(uid, shell) end
|
||||
|
||||
---Changes a user's home directory. Root only.
|
||||
---@param uid number User ID
|
||||
---@param homedir string Home directory path
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error
|
||||
function syscall.sethomedir(uid, homedir) end
|
||||
|
||||
---Changes a user's primary group ID. Root only.
|
||||
---@param uid number User ID
|
||||
---@param gid number New group ID
|
||||
---@return boolean|nil success
|
||||
---@return string|nil error
|
||||
function syscall.setgid(uid, gid) end
|
||||
|
||||
--#endregion auth
|
||||
|
||||
--#region hpv
|
||||
|
||||
---@class TaskInfo
|
||||
---@field name string Task name or executable path
|
||||
---@field status string Current task state (R=running, S=sleeping, D=waiting for I/O, T=stopped, ST=stopped while sleeping, Z=exited)
|
||||
---@field pid number Unique process/task identifier
|
||||
---@field tgid number Thread group identifier
|
||||
---@field username string|nil Username associated with the task's real UID
|
||||
---@field uid number Real user ID
|
||||
---@field euid number Effective user ID used for permission checks
|
||||
---@field exit number|nil Exit code, if the task has exited
|
||||
---@field sleep number Sleep deadline in milliseconds
|
||||
---@field ivs number Internal virtual scheduling value
|
||||
---@field vs number Virtual scheduling value
|
||||
---@field children number[] PIDs of child tasks
|
||||
---@field siblings number[] PIDs of tasks sharing the same parent
|
||||
---@field parent number PID of the parent task
|
||||
---@field cwd string Current working directory
|
||||
|
||||
---Create a new task running a Lua function.
|
||||
---@param func fun(...: any): any Function executed by the new task
|
||||
---@param name? string Task name; defaults to an automatically generated name
|
||||
---@param envars? table<string, any> Environment variables inherited by the task
|
||||
---@param args? any[] Arguments passed to the function
|
||||
---@param tgid? number Thread group ID; defaults to the current task's group
|
||||
---@param clearFds? boolean If true, do not inherit the current task's file descriptors
|
||||
---@return number pid PID of the newly created task
|
||||
function syscall.spawn(func, name, envars, args, tgid, clearFds) end
|
||||
|
||||
---Create a new task by loading and executing a Lua executable file.
|
||||
---@param path string Path to the executable
|
||||
---@param name? string Task name; defaults to the executable path
|
||||
---@param envars? table<string, any> Environment variables for the new task
|
||||
---@param args? any[] Arguments passed to the executable
|
||||
---@param tgid? number Thread group ID; defaults to the current task's group
|
||||
---@param keepFds? boolean If true, inherit the current task's file descriptors
|
||||
---@return number pid PID of the newly created task
|
||||
function syscall.execspawn(path, name, envars, args, tgid, keepFds) end
|
||||
|
||||
---Replace the current task's program with another executable.
|
||||
---@param path string Path to the executable
|
||||
---@param args? any[] Arguments passed to the executable
|
||||
---@param envars? table<string, any> Environment variables for the executable
|
||||
---@param clearFds? boolean If true, close file descriptors greater than 2 before execution
|
||||
function syscall.exec(path, args, envars, clearFds) end
|
||||
|
||||
---Suspend the current task for the specified number of seconds.
|
||||
---@param seconds number Duration to sleep
|
||||
function syscall.sleep(seconds) end
|
||||
|
||||
---Retrieve information about a task by its PID.
|
||||
---@param pid number PID of the task to inspect
|
||||
---@return TaskInfo|nil task Task information, or nil if the task does not exist
|
||||
function syscall.getTask(pid) end
|
||||
|
||||
---Collect the exit status of a child task that has finished.
|
||||
---@param pid number PID of the child task
|
||||
---@return boolean success Whether collection succeeded
|
||||
---@return number|string|nil exitCodeOrError Exit code on success, or an error message on failure
|
||||
function syscall.collect(pid) end
|
||||
|
||||
---Terminate a task.
|
||||
---@param pid number PID of the task to terminate
|
||||
---@param force? boolean Allow termination of a task waiting for I/O
|
||||
---@return boolean success Whether the task was terminated
|
||||
---@return string|nil error Error message if termination failed
|
||||
function syscall.kill(pid, force) end
|
||||
|
||||
---Stop a running or sleeping task.
|
||||
---@param pid number PID of the task to stop
|
||||
---@return boolean success Whether the task was stopped
|
||||
---@return string|nil error Error message if stopping failed
|
||||
function syscall.stop(pid) end
|
||||
|
||||
---Resume a previously stopped task.
|
||||
---@param pid number PID of the task to resume
|
||||
---@return boolean success Whether the task was resumed
|
||||
---@return string|nil error Error message if resuming failed
|
||||
function syscall.continue(pid) end
|
||||
|
||||
---Get the PID of the currently running task.
|
||||
---@return number pid Current task PID
|
||||
function syscall.getpid() end
|
||||
|
||||
---Get the PID of the current task's parent.
|
||||
---@return number pid Parent task PID
|
||||
function syscall.getppid() end
|
||||
|
||||
---Get the PIDs of all currently tracked tasks.
|
||||
---@return number[] pids List of task PIDs
|
||||
function syscall.getTasks() end
|
||||
|
||||
---Retrieve an environment variable from the current task.
|
||||
---@param key string Environment variable name
|
||||
---@return any value Environment variable value, or nil if unset
|
||||
function syscall.getEnviron(key) end
|
||||
|
||||
---Set an environment variable for the current task.
|
||||
---@param key string Environment variable name
|
||||
---@param value any Value to assign
|
||||
function syscall.setEnviron(key, value) end
|
||||
|
||||
---Exit the current task.
|
||||
---@param code? number Optional numeric exit code
|
||||
function syscall.exit(code) end
|
||||
|
||||
---Set the real and effective user IDs of the current task.
|
||||
---@param uid number User ID to assign; requires effective root privileges unless setting the real UID to its existing value
|
||||
function syscall.setuid(uid) end
|
||||
|
||||
---Get the real user ID of the current task.
|
||||
---@return number uid Current task's real UID
|
||||
function syscall.getuid() end
|
||||
|
||||
---Get the effective user ID of the current task.
|
||||
---@return number euid Current task's effective UID
|
||||
function syscall.geteuid() end
|
||||
|
||||
--#endregion hpv
|
||||
|
||||
--#region gpio
|
||||
|
||||
---@param pin number|string GPIO pin identifier
|
||||
---@param data any Value to write
|
||||
---@return any result
|
||||
function syscall.gpio_write(pin, data) end
|
||||
|
||||
---@param pin number|string GPIO pin identifier
|
||||
---@param data number Analog value to write
|
||||
---@return any result
|
||||
function syscall.gpio_writeAnalog(pin, data) end
|
||||
|
||||
---@param pin number|string GPIO pin identifier
|
||||
---@return any value
|
||||
function syscall.gpio_read(pin) end
|
||||
|
||||
---@param pin number|string GPIO pin identifier
|
||||
---@return number|nil value
|
||||
function syscall.gpio_readAnalog(pin) end
|
||||
|
||||
--#endregion gpio
|
||||
|
||||
--#endregion syscalls
|
||||
|
||||
|
||||
|
||||
--#region globals
|
||||
|
||||
---@class DataList
|
||||
---@field contents table
|
||||
---@field push fun(self: DataList, ...: any)
|
||||
---@field pop fun(self: DataList): any
|
||||
|
||||
--- Rounds a number to the nearest integer.
|
||||
--- @param x number
|
||||
--- @return integer
|
||||
function math.round(x) end
|
||||
|
||||
--- Checks whether a string ends with a suffix.
|
||||
--- @param str string
|
||||
--- @param suffix string
|
||||
--- @return boolean
|
||||
function string.hasSuffix(str, suffix) end
|
||||
|
||||
--- Checks whether a string starts with a prefix.
|
||||
--- @param str string
|
||||
--- @param prefix string
|
||||
--- @return boolean
|
||||
function string.hasPrefix(str, prefix) end
|
||||
|
||||
--- Returns the part of a string after the given prefix.
|
||||
--- @param str string
|
||||
--- @param prefix string
|
||||
--- @return string
|
||||
function string.getSuffix(str, prefix) end
|
||||
|
||||
--- Returns the part of a string before the given suffix.
|
||||
--- @param str string
|
||||
--- @param suffix string
|
||||
--- @return string
|
||||
function string.getPrefix(str, suffix) end
|
||||
|
||||
--- Joins multiple values into a string.
|
||||
--- @param str string First value
|
||||
--- @param ... any Additional values
|
||||
--- @return string
|
||||
function string.join(str, ...) end
|
||||
|
||||
--- Joins multiple values using a delimiter.
|
||||
--- @param str string Delimiter
|
||||
--- @param ... any Values to join
|
||||
--- @return string
|
||||
function string.delim(str, ...) end
|
||||
|
||||
--- Splits a string using a single-character delimiter.
|
||||
--- @param str string
|
||||
--- @param delim string Single-character delimiter
|
||||
--- @param maxResultCountOrNil? number Maximum number of results
|
||||
--- @return string[]|false
|
||||
function string.split(str, delim, maxResultCountOrNil) end
|
||||
|
||||
--- Creates a deep copy of a value, preserving circular references.
|
||||
--- @generic T
|
||||
--- @param orig T
|
||||
--- @param copies? table
|
||||
--- @return T
|
||||
function table.deepcopy(orig, copies) end
|
||||
|
||||
--- Returns the value stored at the matching key, or false.
|
||||
--- @param tabl table
|
||||
--- @param query any
|
||||
--- @return any|false
|
||||
function table.hasKey(tabl, query) end
|
||||
|
||||
--- Returns the key associated with a matching value, or false.
|
||||
--- @param tabl table
|
||||
--- @param query any
|
||||
--- @return any|false
|
||||
function table.hasVal(tabl, query) end
|
||||
|
||||
--- Creates a read-only proxy for a table.
|
||||
--- @param tabl table
|
||||
--- @param typ? string Custom type name
|
||||
--- @return table
|
||||
function table.readOnly(tabl, typ) end
|
||||
|
||||
--- Serializes a table into a Lua-style table representation.
|
||||
--- @param tbl table
|
||||
--- @return string
|
||||
function table.serialize(tbl) end
|
||||
|
||||
--- Returns the type of an object, optionally returning its original Lua type.
|
||||
--- @param object any
|
||||
--- @param trueType? boolean Use the original Lua type
|
||||
--- @return string
|
||||
function type(object, trueType) end
|
||||
|
||||
--- Gets the metatable of an object, respecting custom user metatables.
|
||||
--- @param object any
|
||||
--- @return table|nil
|
||||
function getmetatable(object) end
|
||||
|
||||
--- Checks whether a value equals any of the supplied values.
|
||||
--- @param a any
|
||||
--- @param ... any Values to compare
|
||||
--- @return boolean
|
||||
function isEqualToAny(a, ...) end
|
||||
|
||||
--- Checks whether a value equals all of the supplied values.
|
||||
--- @param a any
|
||||
--- @param ... any Values to compare
|
||||
--- @return boolean
|
||||
function isEqualToAll(a, ...) end
|
||||
|
||||
--- Returns all keys in a table.
|
||||
--- @param t table
|
||||
--- @return any[]
|
||||
function table.keys(t) end
|
||||
|
||||
--- Returns all values in a table.
|
||||
--- @param t table
|
||||
--- @return any[]
|
||||
function table.values(t) end
|
||||
|
||||
--- Returns the index of a value in an array, or -1 if not found.
|
||||
--- @param t table
|
||||
--- @param value any
|
||||
--- @return integer
|
||||
function table.indexOf(t, value) end
|
||||
|
||||
--- Merges multiple tables into one table.
|
||||
--- @param ... table Tables to merge
|
||||
--- @return table
|
||||
function table.merge(...) end
|
||||
|
||||
--- Replaces occurrences of a substring.
|
||||
--- @param s string
|
||||
--- @param target string
|
||||
--- @param repl string
|
||||
--- @return string
|
||||
function string.replace(s, target, repl) end
|
||||
|
||||
--- Converts a number to a hexadecimal string.
|
||||
--- @param num number
|
||||
--- @return string
|
||||
function toHex(num) end
|
||||
|
||||
--- Creates a stack.
|
||||
--- @return DataList
|
||||
function stack() end
|
||||
|
||||
--- Creates a queue.
|
||||
--- @return DataList
|
||||
function queue() end
|
||||
|
||||
---Loads a module from the configured search paths.
|
||||
---Modules are cached and returned through a read-only wrapper.
|
||||
---@param module string Module name or path
|
||||
---@vararg any Arguments passed to the module's loader
|
||||
---@return table module Read-only module wrapper
|
||||
function require(module, ...) end
|
||||
|
||||
---Sleep the current task for a number of seconds.
|
||||
---@param seconds number
|
||||
function sleep(seconds) end
|
||||
|
||||
---@param ... any Values to print, separated by tabs
|
||||
function print(...) end
|
||||
|
||||
---@param fmt string Format string
|
||||
---@param ... any Format arguments
|
||||
function printf(fmt, ...) end
|
||||
|
||||
---@param ... any Values to print inline, separated by tabs
|
||||
function printInline(...) end
|
||||
|
||||
---@param fd? number Input file descriptor (defaults to 0)
|
||||
---@param helpstr? string Prompt displayed before reading
|
||||
---@param replacestr? string Replacement text echoed for each input
|
||||
---@param fdo? number Output file descriptor used for echo (defaults to 1)
|
||||
---@return string input
|
||||
function userinput(fd, helpstr, replacestr, fdo) end
|
||||
|
||||
--#endregion globals
|
||||
Reference in new issue
Block a user