|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "syscall_internal.h"#include "syscall.h"#include "kernel/random/random.h"#include "kernel/vfs/vfs.h"#include "kernel/process/process.h"#include "common/string.h"#include "fd_table.h"#include "kernel/vfs/permission.h"#include "kernel/acpi/acpi.h"#include "kernel/klog/klog.h"Macros | |
| #define | RB_AUTOBOOT 0x01234567 |
| #define | RB_POWER_OFF 0x4321FEDC |
Functions | |
| syscall_ret_t | sys_getcwd (struct registers *regs) |
| SYS_getcwd: copy the current working directory into a user buffer. | |
| syscall_ret_t | sys_chroot (struct registers *regs) |
| SYS_chroot: make a directory the caller's root: its paths start there, and ".." stops there (root only). | |
| syscall_ret_t | sys_chdir (struct registers *regs) |
| SYS_chdir: change the current working directory. | |
| syscall_ret_t | sys_ioctl (struct registers *regs) |
| SYS_ioctl: issue a device-control request on an open file descriptor. | |
| syscall_ret_t | sys_reboot (struct registers *regs) |
| SYS_reboot: restart (RB_AUTOBOOT) or turn off (RB_POWER_OFF) the machine. | |
| syscall_ret_t | sys_getrandom (struct registers *regs) |
| SYS_getrandom: random bytes. | |
| #define RB_AUTOBOOT 0x01234567 |
| #define RB_POWER_OFF 0x4321FEDC |
| syscall_ret_t sys_getcwd | ( | struct registers * | regs | ) |
SYS_getcwd: copy the current working directory into a user buffer.
args: EBX = buffer pointer, ECX = buffer size. returns 0 on success, negative errno on failure.
| syscall_ret_t sys_chroot | ( | struct registers * | regs | ) |
SYS_chroot: make a directory the caller's root: its paths start there, and ".." stops there (root only).
the working directory stays; a tool then changes it to "/". args: path. returns 0, or a negative errno (EPERM, ENOTDIR, ENOENT, EACCES).
| syscall_ret_t sys_chdir | ( | struct registers * | regs | ) |
SYS_chdir: change the current working directory.
args: EBX = path string pointer. returns 0 on success, negative errno on failure.
| syscall_ret_t sys_ioctl | ( | struct registers * | regs | ) |
SYS_ioctl: issue a device-control request on an open file descriptor.
args: EBX = fd, ECX = request code, EDX = argument (usually a user pointer). only file-backed fds carry a filesystem that can service ioctls; devfs device nodes forward to the backing device. everything else is -ENOTTY. returns 0 (or a request-specific value) on success, negative errno on error.
note: the arg pointer is request-specific, so its size is only known to the device handler; this layer passes it through and the handler validates it.
| syscall_ret_t sys_reboot | ( | struct registers * | regs | ) |
SYS_reboot: restart (RB_AUTOBOOT) or turn off (RB_POWER_OFF) the machine.
only root (effective user 0) may. the disk writes are already done: the block cache writes through. returns -EPERM for other users and -EINVAL for another value; it does not return for root.
| syscall_ret_t sys_getrandom | ( | struct registers * | regs | ) |
SYS_getrandom: random bytes.
args: buf, length, flags (GRND_NONBLOCK, GRND_RANDOM, GRND_INSECURE). waits until the generator is seeded, unless GRND_NONBLOCK or GRND_INSECURE. returns the bytes given, or -EAGAIN, -EINVAL, -EFAULT, -EINTR.