SYS_OPEN
Open a file or device and return a file descriptor. Syscall Number: 6Parameters
Path to the file or device to open (e.g., “/dev/tty”, “/home/user/file.txt”)
Open flags (currently stored but not enforced)
Returns
- On success: file descriptor (0-31)
- On error: -1 (file not found or no free fd slots)
Behavior
- Resolves the path using
vfs_resolve() - Searches the process’s fd table for an unused entry
- Marks the entry as in-use and associates it with the VFS node
- Sets the file offset to 0
- Returns the fd index
File descriptors 0, 1, and 2 are pre-allocated for stdin, stdout, and stderr during process creation.
Example
SYS_CLOSE
Close a file descriptor and release associated resources. Syscall Number: 7Parameters
File descriptor to close
Returns
- On success: 0
- On error: -1 (invalid fd or not in use)
Behavior
Marks the fd table entry as unused and clears the VFS node pointer. If the fd is associated with a pipe, the pipe may be released when both ends are closed.Example
SYS_READ
Read bytes from a file descriptor into a buffer. Syscall Number: 8Parameters
File descriptor to read from
Buffer to store read data
Maximum number of bytes to read
Returns
- On success: number of bytes read (may be less than count)
- On end-of-file: 0
- On error: -1
Behavior
The implementation delegates to either:- Pipe:
pipe_read()for IPC pipes (stored infd_entry.fs_priv) - VFS:
vfs_read()for regular files and devices
Implementation
Example
SYS_WRITE
Write bytes from a buffer to a file descriptor. Syscall Number: 1Parameters
File descriptor to write to
Buffer containing data to write
Number of bytes to write
Returns
- On success: number of bytes written
- On error: -1
Behavior
Delegates to:- Pipe:
pipe_write()if the fd is associated with a pipe - VFS:
vfs_write()for regular files - Fallback: Direct VGA output for early boot before VFS is initialized
Example
SYS_STAT
Get file status information by path. Syscall Number: 9Parameters
Path to the file
Pointer to stat structure to fill
Returns
- On success: 0
- On error: -1 (file not found)
vfs_stat Structure
Example
SYS_FSTAT
Get file status information by file descriptor. Syscall Number: 34Parameters
File descriptor
Pointer to stat structure to fill
Returns
- On success: 0
- On error: -1 (invalid fd or no VFS node)
SYS_LSEEK
Reposition the file offset for a file descriptor. Syscall Number: 33Parameters
File descriptor
Offset value (interpretation depends on whence)
0(SEEK_SET): Set offset tooffset1(SEEK_CUR): Set offset to current position +offset2(SEEK_END): Set offset to file size +offset
Returns
- On success: new file offset
- On error: -1
Example
SYS_GETDENTS
Read directory entries from an open directory file descriptor. Syscall Number: 10Parameters
File descriptor for an open directory
Index of the directory entry to read (0-based)
Buffer to store the entry name (null-terminated string)
Returns
- On success: 1 (entry found and copied)
- At end of directory: 0
- On error: -1
Behavior
Callsvfs_readdir() to get the VFS node for the child at the given index, then copies the child’s name to the user buffer.
Example
SYS_MKDIR
Create a new directory. Syscall Number: 11Parameters
Path of the directory to create (e.g., “/tmp/newdir”)
Returns
- On success: 0
- On error: -1
Behavior
Current implementation only supports creating directories under the root (”/”). The leading ”/” is stripped before calling
vfs_mkdir().SYS_UNLINK
Remove a file or directory entry. Syscall Number: 12Parameters
Path to the file to remove
Returns
- On success: 0
- On error: -1
SYS_GETCWD
Get the current working directory. Syscall Number: 17Parameters
Buffer to store the path
Size of the buffer
Returns
- On success: pointer to buf (same as arg1)
- On error: -1
Behavior
Aurora OS currently does not maintain per-process working directories. This syscall always returns ”/” (root directory).
SYS_IOCTL
Perform device-specific control operations. Syscall Number: 36Parameters
File descriptor
Device-specific request code
Request-specific argument pointer
Returns
- On success: 0
- On error: -1