Module syscalls

Source
Expand description

This module exposes SafaOS’s syscalls and their rust counterparts

Modules§

types
Contains documentation-only types for syscall arguments

Enums§

SyscallNum
defines Syscall numbers

Functions§

chdir
Changes the current work dir to path
close
Closes the file with the resource id fd
create
Creates the file with the path path
createdir
Creates the directory with the path path
diriter_close
Closes the directory iterator with the resource id fd
diriter_next
Gets the next directory entry from a directory iterator,
diriter_open
Opens a directory iterator for the directory with the resource id dir_ri, returns the resource id of the directory iterator
dup
Duplicates the resource referred to by the resource id ri and returns the new resource id
exit
fattrs
Gets the file attributes of the file with the resource id fd
fsize
Gets the size of the file with the resource id fd
getcwd
Retrieves the current work dir
getdirentry
open
Opens the path path and returns the resource id of the file descriptor
pspawn
same as unsafe_pspawn but safe because it makes it clear that argv are consumed
read
Reads buf.len() bytes from the file with the resource id fd at offset offset into buf
reboot
sbrk
Increases the range of the process’s data break by size bytes returns the new break pointer
shutdown
sync
Syncs the resource with the resource id ri
syschdir
Changes the current working directory to the path buf with length buf_len (expects given buffer to be utf-8)
sysclose
Closes the file with the resource id fd
syscreate_dir
Creates the directory with the path path
syscreate_file
Creates the file with the path path path must be valid utf-8
sysdiriter_close
Closes a directory iterator
sysdiriter_next
Gets the next directory entry from a directory iterator,
sysdiriter_open
Opens a directory iterator for the directory with the resource id dir_ri
sysdup
Duplicates the resource referred to by the resource id ri and puts the new resource id in dest_ri
sysexit
Exits the process with the exit code code
sysfattrs
Gets the file attributes of the file with the resource id fd and puts them in dest_attrs
sysfsize
Gets the size of the file with the resource id fd and puts it in dest_size
sysgetcwd
Gets the current working directory and puts it in cwd_buf with length cwd_buf_len if dest_len is not null, it will be set to the length of the cwd if the cwd is too long to fit in cwd_buf, the syscall will return ErrorStatus::Generic (1) the cwd is currently maximumally 1024 bytes
sysgetdirentry
Gets the directory entry for the path path and puts it in dest_direntry path must be valid utf-8 if dest_direntry is not null, it will be set to the directory entry
sysopen
Opens the file with the path path and puts the resource id in dest_fd
sysread
Reads len bytes from the file with the resource id fd at offset offset into buf
sysreboot
Reboots the system
syssbrk
Increases the range of the process’s data break by size bytes and puts the new break pointer in target_ptr
sysshutdown
Shuts down the system
syssync
Syncs the resource with the resource id fd
systruncate
Truncates the file with the resource id fd to len bytes
syswait
Waits for the process with the resource id pid to exit if exit_code is not null, it will be set to the exit code of the process
syswrite
Writes len bytes from buf to the file with the resource id fd at offset offset
sysyield
Switches to the next process/thread
truncate
Truncates the file with the resource id fd to len bytes
unsafe_pspawn
spawns a new process
wait
Waits for the process with the resource id pid to exit and returns the exit code of the process
write
Writes buf.len() bytes from buf to the file with the resource id fd at offset offset and returns the number of bytes written
yield_now