The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
sys_misc.c File Reference
#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.

Macro Definition Documentation

◆ RB_AUTOBOOT

#define RB_AUTOBOOT   0x01234567

◆ RB_POWER_OFF

#define RB_POWER_OFF   0x4321FEDC

Function Documentation

◆ sys_getcwd()

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.

◆ sys_chroot()

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).

◆ sys_chdir()

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.

◆ sys_ioctl()

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.

◆ sys_reboot()

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.

◆ sys_getrandom()

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.