393 lines
11 KiB
Lua
393 lines
11 KiB
Lua
---@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 |