|
AquilaOS documentation
How it works, and its code
|
#include <core/system.h>#include <aquila/syscall.h>#include <core/panic.h>#include <core/string.h>#include <core/arch.h>#include <core/time.h>#include <sys/proc.h>#include <sys/sched.h>#include <sys/signal.h>#include <sys/binfmt.h>#include <sys/uaccess.h>#include <sys/syscall.h>#include <fs/iobuf.h>#include <net/socket.h>#include <aquila/errno.h>#include <aquila/dirent.h>#include <aquila/utsname.h>#include <aquila/fcntl.h>#include <aquila/mman.h>#include <aquila/time.h>#include <aquila/ioctl.h>#include <aquila/wait.h>#include <aquila/poll.h>#include <aquila/un.h>#include <fs/devpts.h>#include <fs/pipe.h>#include <fs/stat.h>#include <mm/vm.h>#include <sys/reboot.h>#include <dev/random.h>Go to the source code of this file.
Macros | |
| #define | UPATH_MAX 1024 |
Functions | |
| struct file * | fd_file (int fd) |
| Finds the open file that a descriptor of the current process refers to, and holds it until the system call returns, so that a close() by another thread meanwhile doesn't free it. | |
| int | upath_get (const char *upath, char **path) |
| Copies a path from user memory into a new kernel buffer. | |
| long | sys_close (int fildes) |
| Implements close(): frees a descriptor. | |
| long | sys_fstat (int fildes, struct aquila_stat *buf) |
| Implements fstat(): an open file's attributes. | |
| long | sys_isatty (int fildes) |
| Says whether a descriptor refers to a character device, the only kind of file that can be a terminal. | |
| long | sys_link (const char *oldpath, const char *newpath) |
| Implements link(): a new name for a file. | |
| long | sys_linkat (int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) |
| Implements linkat(): link(), with paths relative to directories. | |
| long | sys_lseek (int fildes, off_t offset, int whence) |
| Implements lseek(): moves an open file's offset. | |
| long | sys_open (const char *path, int oflags, mode_t mode) |
| Implements open(): opens a file on a new descriptor, creating it with O_CREAT. | |
| long | sys_openat (int dirfd, const char *path, int oflags, mode_t mode) |
| Implements openat(): open(), with the path relative to a directory. | |
| long | sys_read (int fildes, void *buf, size_t nbytes) |
| Implements read(). | |
| long | sys_stat (const char *path, struct aquila_stat *buf) |
| Implements stat(): a file's attributes, following a symbolic link. | |
| long | sys_fstatat (int dirfd, const char *path, struct aquila_stat *buf, int flags) |
| Implements fstatat(): stat(), with the path relative to a directory. | |
| long | sys_unlink (const char *path) |
| Implements unlink(): removes a name of a file (not a directory's). | |
| long | sys_unlinkat (int dirfd, const char *path, int flags) |
| Implements unlinkat(): unlink(), or rmdir() with AT_REMOVEDIR, with the path relative to a directory. | |
| long | sys_write (int fd, void *buf, size_t nbytes) |
| Implements write(). | |
| long | sys_ioctl (int fd, int request, void *argp) |
| Implements ioctl(): a device's, a socket's, or a terminal's request. | |
| long | sys_readdir (int fd, struct dirent *dirent) |
| Reads a directory's next entry, for the C library's readdir(). | |
| long | sys_mount (struct aquila_mount_args *args) |
| Implements mount(): mounts a file system on a directory. | |
| long | sys_mkdir (const char *path, mode_t mode) |
| Implements mkdir(): makes a directory. | |
| long | sys_pipe (int fd[2]) |
| Implements pipe(): makes a pipe, its read end and its write end open on two new descriptors. | |
| long | sys_fcntl (int fd, int cmd, uintptr_t arg) |
| Implements fcntl(): duplicates a descriptor, or reads and sets the descriptor's flags (FD_CLOEXEC) or the open file's status flags. | |
| long | sys_chdir (const char *upath) |
| Implements chdir(): changes the working directory. | |
| long | sys_getcwd (char *buf, size_t size) |
| Implements getcwd(): the working directory's path. | |
| long | sys_mknod (const char *path, uint32_t mode, uint32_t dev) |
| Implements mknod(): makes a file, a directory, a FIFO, or (only root) a device file. | |
| long | sys_mknodat (int dirfd, const char *path, uint32_t mode, uint32_t dev) |
| Implements mknodat(): mknod(), with the path relative to a directory. | |
| long | sys_lstat (const char *path, struct aquila_stat *buf) |
| Implements lstat(): a file's attributes, a symbolic link's own. | |
| long | sys_ftruncate (int fildes, off_t len) |
| Implements ftruncate(): sets an open file's size. | |
| long | sys_umask (mode_t mask) |
| Implements umask(): sets the permissions that new files don't get. | |
| long | sys_chmod (const char *path, mode_t mode) |
| Implements chmod(): changes a file's permissions. | |
| long | sys_fchmodat (int dirfd, const char *path, mode_t mode, int flags) |
| Implements fchmodat(): chmod(), with the path relative to a directory. | |
| long | sys_fchmod (int fd, mode_t mode) |
| Implements fchmod(): changes an open file's permissions. | |
| long | sys_access (const char *path, int mode) |
| Implements access(): says whether the process may read, write or execute a file. | |
| long | sys_faccessat (int dirfd, const char *path, int mode, int flags) |
| Implements faccessat(): access(), with the path relative to a directory. | |
| long | sys_chown (const char *path, uid_t owner, gid_t group) |
| Implements chown(): changes a file's owner and group. | |
| long | sys_fchownat (int dirfd, const char *path, uid_t owner, gid_t group, int flags) |
| Implements fchownat(): chown(), with the path relative to a directory. | |
| long | sys_fchown (int fd, uid_t owner, gid_t group) |
| Implements fchown(): changes an open file's owner and group. | |
| long | sys_lchown (const char *path, uid_t owner, gid_t group) |
| Implements lchown(): chown() of a symbolic link itself. | |
| long | sys_utimensat (int dirfd, const char *path, const struct aquila_timespec times[2], int flags) |
| Implements utimensat() (and futimens()): sets a file's access and modification times. | |
| long | sys_rmdir (const char *path) |
| Implements rmdir(): removes an empty directory. | |
| long | sys_symlinkat (const char *utarget, int dirfd, const char *upath) |
| Implements symlinkat(): makes a symbolic link. | |
| long | sys_readlinkat (int dirfd, const char *upath, char *buf, size_t size) |
| Implements readlinkat(): what a symbolic link points to (not NUL-terminated). | |
| long | sys_renameat (int olddirfd, const char *oldpath, int newdirfd, const char *newpath) |
| Implements renameat() (and rename()): moves a file to another name, replacing what was there. | |
| long | sys_flock (int fd, int op) |
| Implements flock(): takes or releases an advisory lock on an open file. | |
| long | sys_sync (void) |
| Implements sync(): writes out what the devices' caches hold. | |
| long | sys_fchdir (int fd) |
| Implements fchdir(): changes the working directory to an open directory. | |
| long | sys_exit (int code) |
| Implements _exit(): ends the calling process. | |
| long | sys_execve (const char *path, char *const argp[], char *const envp[]) |
| Implements execve(): runs another program in the calling process. | |
| long | sys_fork (void) |
| Implements fork(): makes a child process, a copy of the caller. | |
| long | sys_getpid (void) |
| Implements getpid(). | |
| long | sys_sbrk (ptrdiff_t incr) |
| Implements sbrk(): grows or shrinks the heap. | |
| long | sys_times (struct aquila_tms *buf) |
| Implements times(): the CPU times of the process and of its children that it waited for, in ticks (AQUILA_CLK_TCK a second). | |
| long | sys_waitpid (int pid, int *stat_loc, int options) |
| Implements waitpid(): waits for a child to end (or stop, or continue, if asked), and reaps it if it ended. | |
| long | sys_uname (struct utsname *name) |
| Implements uname(): the system's name, release, version and machine, and the host name. | |
| long | sys_thread_create (struct aquila_thread_args *__uthread) |
| Makes a new thread in the calling process (for pthread_create()), and makes it ready to run. | |
| long | sys_thread_exit (void *value_ptr) |
| Ends the calling thread (for pthread_exit()). | |
| long | sys_thread_join (int tid, void **value_ptr) |
| Waits for a thread of the calling process to end, and frees it (for pthread_join()). | |
| long | sys_setpgid (pid_t pid, pid_t pgid) |
| Implements setpgid(): moves a process (the caller or one of its children) into a process group of its session. | |
| long | sys_setuid (uid_t uid) |
| Implements setuid(): sets the process's user ID. | |
| long | sys_setgid (gid_t gid) |
| Implements setgid(): sets the process's group ID. | |
| long | sys_getuid (void) |
| Implements getuid(). | |
| long | sys_getgid (void) |
| Implements getgid(). | |
| long | sys_mmap (struct aquila_mmap_args *uargs, void **ret) |
| Implements mmap(): maps anonymous memory or a file into the calling process. | |
| long | sys_munmap (void *addr, size_t len) |
| Implements munmap(): removes a mapping. | |
| long | sys_sysconf (int name) |
| Implements sysconf(): not supported; the C library answers it. | |
| long | sys_getppid (void) |
| Implements getppid(). | |
| long | sys_getpgrp (void) |
| Implements getpgrp(). | |
| long | sys_getrandom (void *buf, size_t len, unsigned flags) |
| Implements getrandom() (and the C library's getentropy()): fills a buffer with random bytes. | |
| long | sys_thread_self (void) |
| Returns the calling thread's ID, for pthread_self(). | |
| long | sys_reboot (unsigned cmd) |
| Implements reboot(): restarts, halts or powers off the machine, or sets what Ctrl+Alt+Del does. | |
| long | sys_setsid (void) |
| Implements setsid(): makes the calling process the leader of a new session and process group. | |
| long | sys_sethostname (const char *name, size_t len) |
| Implements sethostname(). | |
| long | sys_kill (pid_t pid, int sig) |
| Implements kill(): sends a signal to a process or a process group. | |
| long | sys_sigaction (int sig, const struct aquila_sigaction *act, struct aquila_sigaction *oact) |
| Implements sigaction(): reads a signal's action, and sets a new one. | |
| long | sys_gettimeofday (struct timeval *tv, struct timezone *tz) |
| Implements gettimeofday(): the time of day. | |
| long | sys_sigmask (int how, const sigset_t *set, sigset_t *oldset) |
| Implements sigprocmask(): reads and changes the process's signal mask. | |
| long | sys_sigsuspend (const sigset_t *set) |
| Implements sigsuspend(): replaces the signal mask and waits for a signal. | |
| long | sys_sigreturn (void) |
| Implements sigreturn(): a signal handler returns, and the registers and signal mask that its frame saved are restored. | |
| long | sys_setitimer (int which, const struct aquila_itimer *new, struct aquila_itimer *old) |
| Implements setitimer(): sets the real time timer, which sends SIGALRM, and reads the old one. | |
| long | sys_nanosleep (const struct aquila_timespec *req, struct aquila_timespec *rem) |
| Implements nanosleep(): sleeps for a time. | |
| long | sys_clock_gettime (int clock, struct aquila_timespec *ts) |
| Implements clock_gettime(): reads a clock. | |
| long | sys_socket (int domain, int type, int protocol) |
| Implements socket(): makes a socket, open on a new descriptor. | |
| long | sys_accept (int fd, const struct sockaddr *addr, socklen_t *len) |
| Implements accept(): takes a connection from a listening socket, open on a new descriptor. | |
| long | sys_bind (int fd, const struct sockaddr *addr, socklen_t len) |
| Implements bind(): gives a socket its local address. | |
| long | sys_connect (int fd, const struct sockaddr *addr, socklen_t len) |
| Implements connect(): connects a socket to a peer. | |
| long | sys_listen (int fd, int backlog) |
| Implements listen(): makes a socket accept connections. | |
| long | sys_send (struct aquila_socket_io_args *us) |
| Implements send() and sendto(). | |
| long | sys_recv (struct aquila_socket_io_args *us) |
| Implements recv() and recvfrom(). | |
| long | sys_getsockname (int fd, struct sockaddr *addr, socklen_t *len) |
| Implements getsockname(): a socket's local address. | |
| long | sys_getpeername (int fd, struct sockaddr *addr, socklen_t *len) |
| Implements getpeername(): the address of a socket's peer. | |
| long | sys_getsockopt (int fd, int level, int name, void *val, socklen_t *len) |
| Implements getsockopt(): reads a socket option. | |
| long | sys_setsockopt (int fd, int level, int name, const void *val, socklen_t len) |
| Implements setsockopt(): sets a socket option. | |
| long | sys_shutdown (int fd, int how) |
| Implements shutdown(): shuts down reading, writing or both on a socket, which stays open. | |
| long | sys_select (struct aquila_select_args *args) |
| Implements select() and pselect(): waits until a descriptor of the sets can be read or written, or the timeout passes, and says which can. | |
| long | sys_poll (struct pollfd *fds, nfds_t nfds, int timeout_ms) |
| Implements poll(): waits until one of the descriptors can be read or written, or the timeout passes, and says which can. | |
| #define UPATH_MAX 1024 |
Definition at line 54 of file syscalls.h.
Referenced by sys_getcwd(), sys_readlinkat(), and upath_get().
| struct file * fd_file | ( | int | fd | ) |
Finds the open file that a descriptor of the current process refers to, and holds it until the system call returns, so that a close() by another thread meanwhile doesn't free it.
| fd | the descriptor |
Definition at line 22 of file syscall.c.
References curproc, fd_file(), file_hold(), NULL, and proc_fd_file().
Referenced by at_uio(), fd_file(), fd_vnode(), socket_name(), sys_accept(), sys_bind(), sys_connect(), sys_fchdir(), sys_fcntl(), sys_flock(), sys_fstat(), sys_ftruncate(), sys_getsockopt(), sys_ioctl(), sys_isatty(), sys_listen(), sys_lseek(), sys_mmap(), sys_read(), sys_readdir(), sys_recv(), sys_send(), sys_setsockopt(), sys_shutdown(), and sys_write().
| long sys_accept | ( | int | fd, |
| const struct sockaddr * | addr, | ||
| socklen_t * | len ) |
Implements accept(): takes a connection from a listening socket, open on a new descriptor.
| fd | the listening socket |
| addr | where to put the peer's address, or NULL |
| len | the room at addr, set to the address's size |
Definition at line 97 of file sys_net.c.
References curproc, fd_file(), file_new(), kfree(), LOG_DEBUG, memset(), NULL, proc_fd_close(), proc_fd_get(), proc_fd_install(), proc_fd_release(), ksockaddr::sa, sockaddr_copyout(), sockaddr_room(), socket_accept(), and sys_accept().
Referenced by sys_accept().
| long sys_access | ( | const char * | path, |
| int | mode ) |
Implements access(): says whether the process may read, write or execute a file.
Definition at line 1220 of file sys_file.c.
References do_faccessat(), LOG_DEBUG, and sys_access().
Referenced by sys_access().
| long sys_bind | ( | int | fd, |
| const struct sockaddr * | addr, | ||
| socklen_t | len ) |
Implements bind(): gives a socket its local address.
| fd | the socket |
| addr | the address |
| len | its size |
Definition at line 161 of file sys_net.c.
References fd_file(), LOG_DEBUG, memset(), ksockaddr::sa, sockaddr_copyin(), socket_bind(), and sys_bind().
Referenced by sys_bind().
| long sys_chdir | ( | const char * | upath | ) |
Implements chdir(): changes the working directory.
| upath | the directory's path |
Definition at line 956 of file sys_file.c.
References curproc, cwd_set(), kfree(), LOG_DEBUG, NULL, PROC_UIO, sys_chdir(), upath_get(), vfs_close(), and vfs_lookup().
Referenced by sys_chdir().
| long sys_chmod | ( | const char * | path, |
| mode_t | mode ) |
Implements chmod(): changes a file's permissions.
| path | the file's path |
| mode | the new permissions |
Definition at line 1129 of file sys_file.c.
References do_fchmodat(), LOG_DEBUG, and sys_chmod().
Referenced by sys_chmod().
Implements chown(): changes a file's owner and group.
| path | the file's path |
| owner | the new owner, or -1 to keep it |
| group | the new group, or -1 to keep it |
Definition at line 1269 of file sys_file.c.
References do_fchownat(), LOG_DEBUG, and sys_chown().
Referenced by sys_chown().
| long sys_clock_gettime | ( | int | clock, |
| struct aquila_timespec * | ts ) |
Implements clock_gettime(): reads a clock.
| clock | CLOCK_REALTIME or CLOCK_MONOTONIC |
| ts | where to put the time |
Definition at line 293 of file sys_signal.c.
References arch_rtime_ns(), clock, gettime(), LOG_DEBUG, sys_clock_gettime(), timespec::tv_nsec, and timespec::tv_sec.
Referenced by sys_clock_gettime().
| long sys_close | ( | int | fildes | ) |
Implements close(): frees a descriptor.
The open file is closed once nothing else refers to it (another descriptor, or a call using it).
| fildes | the descriptor |
Definition at line 86 of file sys_file.c.
References curproc, LOG_DEBUG, proc_fd_close(), and sys_close().
Referenced by sys_close().
| long sys_connect | ( | int | fd, |
| const struct sockaddr * | addr, | ||
| socklen_t | len ) |
Implements connect(): connects a socket to a peer.
| fd | the socket |
| addr | the peer's address |
| len | its size |
Definition at line 192 of file sys_net.c.
References fd_file(), LOG_DEBUG, memset(), ksockaddr::sa, sockaddr_copyin(), socket_connect(), and sys_connect().
Referenced by sys_connect().
| long sys_execve | ( | const char * | path, |
| char *const | argp[], | ||
| char *const | envp[] ) |
Implements execve(): runs another program in the calling process.
| path | the program's path |
| argp | its arguments, a NULL-terminated array |
| envp | its environment, a NULL-terminated array |
Definition at line 42 of file sys_proc.c.
References curthread, kfree(), LOG_DEBUG, proc_execve(), sched_thread_spawn(), sys_execve(), and upath_get().
Referenced by sys_execve().
| long sys_exit | ( | int | code | ) |
Implements _exit(): ends the calling process.
It doesn't return.
| code | the exit status, which the parent's wait() reports |
Definition at line 16 of file sys_proc.c.
References arch_sleep(), curproc, proc::exit, LOG_DEBUG, PROC_EXIT, proc_kill(), and sys_exit().
Referenced by sys_exit(), and sys_thread_exit().
| long sys_faccessat | ( | int | dirfd, |
| const char * | path, | ||
| int | mode, | ||
| int | flags ) |
Implements faccessat(): access(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| mode | F_OK, or R_OK, W_OK and X_OK together |
| flags | AT_EACCESS (which changes nothing), AT_SYMLINK_NOFOLLOW |
Definition at line 1236 of file sys_file.c.
References do_faccessat(), uio::flags, LOG_DEBUG, and sys_faccessat().
Referenced by sys_faccessat().
| long sys_fchdir | ( | int | fd | ) |
Implements fchdir(): changes the working directory to an open directory.
| fd | the directory's descriptor |
Definition at line 1523 of file sys_file.c.
References cwd_set(), fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, file::ref, sys_fchdir(), and vfs_close().
Referenced by sys_fchdir().
| long sys_fchmod | ( | int | fd, |
| mode_t | mode ) |
Implements fchmod(): changes an open file's permissions.
| fd | the descriptor |
| mode | the new permissions |
Definition at line 1172 of file sys_file.c.
References curproc, fd_vnode(), LOG_DEBUG, vnode::mode, PROC_UIO, sys_fchmod(), and vfs_chmod().
Referenced by sys_fchmod().
| long sys_fchmodat | ( | int | dirfd, |
| const char * | path, | ||
| mode_t | mode, | ||
| int | flags ) |
Implements fchmodat(): chmod(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| mode | the new permissions |
| flags | 0 (AT_SYMLINK_NOFOLLOW isn't supported) |
Definition at line 1145 of file sys_file.c.
References do_fchmodat(), uio::flags, LOG_DEBUG, and sys_fchmodat().
Referenced by sys_fchmodat().
Implements fchown(): changes an open file's owner and group.
| fd | the descriptor |
| owner | the new owner, or -1 |
| group | the new group, or -1 |
Definition at line 1301 of file sys_file.c.
References curproc, fd_vnode(), LOG_DEBUG, PROC_UIO, sys_fchown(), and vfs_chown().
Referenced by sys_fchown().
Implements fchownat(): chown(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| owner | the new owner, or -1 |
| group | the new group, or -1 |
| flags | AT_SYMLINK_NOFOLLOW for a symbolic link's own |
Definition at line 1286 of file sys_file.c.
References do_fchownat(), uio::flags, LOG_DEBUG, and sys_fchownat().
Referenced by sys_fchownat().
| long sys_fcntl | ( | int | fd, |
| int | cmd, | ||
| uintptr_t | arg ) |
Implements fcntl(): duplicates a descriptor, or reads and sets the descriptor's flags (FD_CLOEXEC) or the open file's status flags.
| fd | the descriptor |
| cmd | F_DUPFD, F_DUPFD_CLOEXEC, F_GETFD, F_SETFD, F_GETFL or F_SETFL |
| arg | the command's argument |
Definition at line 876 of file sys_file.c.
References curproc, fd_file(), FDS_COUNT, file_ref(), FILE_SOCKET, file::flags, LOG_DEBUG, proc_fd_install(), and sys_fcntl().
Referenced by sys_fcntl().
| long sys_flock | ( | int | fd, |
| int | op ) |
Implements flock(): takes or releases an advisory lock on an open file.
| fd | the descriptor |
| op | LOCK_SH, LOCK_EX or LOCK_UN, with LOCK_NB to not wait |
Definition at line 1490 of file sys_file.c.
References fd_file(), LOG_DEBUG, sys_flock(), and vfs_file_flock().
Referenced by sys_flock().
| long sys_fork | ( | void | ) |
Implements fork(): makes a child process, a copy of the caller.
Definition at line 76 of file sys_proc.c.
References curthread, queue::head, LOG_DEBUG, NULL, proc::pid, proc_fork(), sched_thread_ready(), sys_fork(), proc::threads, and qnode::value.
Referenced by sys_fork().
| long sys_fstat | ( | int | fildes, |
| struct aquila_stat * | buf ) |
Implements fstat(): an open file's attributes.
A socket only reports its type.
| fildes | the descriptor |
| buf | where to put them |
Definition at line 103 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, memset(), sys_fstat(), and vfs_stat().
Referenced by sys_fstat().
| long sys_fstatat | ( | int | dirfd, |
| const char * | path, | ||
| struct aquila_stat * | buf, | ||
| int | flags ) |
Implements fstatat(): stat(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| buf | where to put its attributes |
| flags | AT_SYMLINK_NOFOLLOW for a symbolic link's own |
Definition at line 520 of file sys_file.c.
References do_fstatat(), LOG_DEBUG, and sys_fstatat().
Referenced by sys_fstatat().
| long sys_ftruncate | ( | int | fildes, |
| off_t | len ) |
Implements ftruncate(): sets an open file's size.
| fildes | the descriptor, open for writing |
| len | the new size |
Definition at line 1065 of file sys_file.c.
References fd_file(), file::flags, LOG_DEBUG, sys_ftruncate(), and vfs_file_trunc().
Referenced by sys_ftruncate().
| long sys_getcwd | ( | char * | buf, |
| size_t | size ) |
Implements getcwd(): the working directory's path.
| buf | where to put it |
| size | the room at buf |
Definition at line 985 of file sys_file.c.
References curproc, kfree(), kmalloc(), LOG_DEBUG, MIN, NULL, vnode::size, sys_getcwd(), UPATH_MAX, and vfs_vnode_path().
Referenced by sys_getcwd().
| long sys_getgid | ( | void | ) |
Implements getgid().
Definition at line 498 of file sys_proc.c.
References curproc, LOG_DEBUG, and sys_getgid().
Referenced by sys_getgid().
| long sys_getpeername | ( | int | fd, |
| struct sockaddr * | addr, | ||
| socklen_t * | len ) |
Implements getpeername(): the address of a socket's peer.
| fd | the socket |
| addr | where to put the address |
| len | the room at addr, set to the address's size |
Definition at line 412 of file sys_net.c.
References LOG_DEBUG, socket_name(), and sys_getpeername().
Referenced by sys_getpeername().
| long sys_getpgrp | ( | void | ) |
Implements getpgrp().
Definition at line 683 of file sys_proc.c.
References curproc, LOG_DEBUG, and sys_getpgrp().
Referenced by sys_getpgrp().
| long sys_getpid | ( | void | ) |
Implements getpid().
Definition at line 100 of file sys_proc.c.
References curproc, LOG_DEBUG, and sys_getpid().
Referenced by sys_getpid().
| long sys_getppid | ( | void | ) |
Implements getppid().
Definition at line 670 of file sys_proc.c.
References curproc, LOG_DEBUG, and sys_getppid().
Referenced by sys_getppid().
| long sys_getrandom | ( | void * | buf, |
| size_t | len, | ||
| unsigned | flags ) |
Implements getrandom() (and the C library's getentropy()): fills a buffer with random bytes.
| buf | the buffer |
| len | its size |
| flags | not used |
Definition at line 698 of file sys_proc.c.
References memset(), MIN, random_get(), sys_getrandom(), and uaccess_check().
Referenced by sys_getrandom().
| long sys_getsockname | ( | int | fd, |
| struct sockaddr * | addr, | ||
| socklen_t * | len ) |
Implements getsockname(): a socket's local address.
| fd | the socket |
| addr | where to put the address |
| len | the room at addr, set to the address's size |
Definition at line 398 of file sys_net.c.
References LOG_DEBUG, socket_name(), and sys_getsockname().
Referenced by sys_getsockname().
| long sys_getsockopt | ( | int | fd, |
| int | level, | ||
| int | name, | ||
| void * | val, | ||
| socklen_t * | len ) |
Implements getsockopt(): reads a socket option.
| fd | the socket |
| level | SOL_SOCKET, or a protocol's level |
| name | the option |
| val | where to put its value |
| len | the room at val, set to the value's size |
Definition at line 429 of file sys_net.c.
References fd_file(), LOG_DEBUG, memset(), MIN, socket_getsockopt(), and sys_getsockopt().
Referenced by sys_getsockopt().
Implements gettimeofday(): the time of day.
| tv | where to put the time, or NULL |
| tz | where to put the time zone, or NULL |
Definition at line 85 of file sys_signal.c.
References gettimeofday(), LOG_DEBUG, and sys_gettimeofday().
Referenced by sys_gettimeofday().
| long sys_getuid | ( | void | ) |
Implements getuid().
Definition at line 487 of file sys_proc.c.
References curproc, LOG_DEBUG, and sys_getuid().
Referenced by sys_getuid().
| long sys_ioctl | ( | int | fd, |
| int | request, | ||
| void * | argp ) |
Implements ioctl(): a device's, a socket's, or a terminal's request.
FIONBIO, which sets the descriptor's O_NONBLOCK, works on any file.
| fd | the descriptor |
| request | the request |
| argp | its argument, in user memory |
Definition at line 622 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, socket_ioctl(), sys_ioctl(), and vfs_file_ioctl().
Referenced by sys_ioctl().
| long sys_isatty | ( | int | fildes | ) |
Says whether a descriptor refers to a character device, the only kind of file that can be a terminal.
(The C library's isatty() asks the device with TCGETS instead.)
| fildes | the descriptor |
Definition at line 137 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, and sys_isatty().
Referenced by sys_isatty().
| long sys_kill | ( | pid_t | pid, |
| int | sig ) |
Implements kill(): sends a signal to a process or a process group.
| pid | whom to: a process if > 0, the caller's process group if 0, every process but init and the caller if -1, or process group -pid if < -1 |
| sig | the signal, or 0 to only check that the target exists |
Definition at line 19 of file sys_signal.c.
References LOG_DEBUG, signal_send(), and sys_kill().
Referenced by sys_kill().
Implements lchown(): chown() of a symbolic link itself.
| path | the link's path |
| owner | the new owner, or -1 |
| group | the new group, or -1 |
Definition at line 1322 of file sys_file.c.
References do_fchownat(), LOG_DEBUG, and sys_lchown().
Referenced by sys_lchown().
| long sys_link | ( | const char * | oldpath, |
| const char * | newpath ) |
Implements link(): a new name for a file.
| oldpath | the file's path |
| newpath | the new name |
Definition at line 188 of file sys_file.c.
References do_linkat(), LOG_DEBUG, and sys_link().
Referenced by sys_link().
| long sys_linkat | ( | int | olddirfd, |
| const char * | oldpath, | ||
| int | newdirfd, | ||
| const char * | newpath, | ||
| int | flags ) |
Implements linkat(): link(), with paths relative to directories.
| olddirfd | the directory oldpath is relative to, or AT_FDCWD |
| oldpath | the file's path |
| newdirfd | the directory newpath is relative to, or AT_FDCWD |
| newpath | the new name |
| flags | AT_SYMLINK_FOLLOW to link what a symbolic link points to |
Definition at line 205 of file sys_file.c.
References do_linkat(), uio::flags, LOG_DEBUG, and sys_linkat().
Referenced by sys_linkat().
| long sys_listen | ( | int | fd, |
| int | backlog ) |
Implements listen(): makes a socket accept connections.
| fd | the socket |
| backlog | how many connections may wait to be accepted |
Definition at line 221 of file sys_net.c.
References fd_file(), LOG_DEBUG, socket_listen(), and sys_listen().
Referenced by sys_listen().
| long sys_lseek | ( | int | fildes, |
| off_t | offset, | ||
| int | whence ) |
Implements lseek(): moves an open file's offset.
| fildes | the descriptor |
| offset | the offset |
| whence | SEEK_SET, SEEK_CUR or SEEK_END |
Definition at line 221 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, file::offset, sys_lseek(), and vfs_file_lseek().
Referenced by sys_lseek().
| long sys_lstat | ( | const char * | path, |
| struct aquila_stat * | buf ) |
Implements lstat(): a file's attributes, a symbolic link's own.
| path | the file's path |
| buf | where to put them |
Definition at line 1052 of file sys_file.c.
References do_fstatat(), LOG_DEBUG, and sys_lstat().
Referenced by sys_lstat().
| long sys_mkdir | ( | const char * | path, |
| mode_t | mode ) |
Implements mkdir(): makes a directory.
| path | its path |
| mode | its permissions (less the umask) |
Definition at line 797 of file sys_file.c.
References do_mknodat(), LOG_DEBUG, and sys_mkdir().
Referenced by sys_mkdir().
Implements mknod(): makes a file, a directory, a FIFO, or (only root) a device file.
| path | its path |
| mode | its type and permissions |
| dev | a device file's device number |
Definition at line 1023 of file sys_file.c.
References do_mknodat(), LOG_DEBUG, vnode::mode, and sys_mknod().
Referenced by sys_mknod().
Implements mknodat(): mknod(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the new file's path |
| mode | its type and permissions |
| dev | a device file's device number |
Definition at line 1039 of file sys_file.c.
References do_mknodat(), LOG_DEBUG, vnode::mode, and sys_mknodat().
Referenced by sys_mknodat().
| long sys_mmap | ( | struct aquila_mmap_args * | uargs, |
| void ** | ret ) |
Implements mmap(): maps anonymous memory or a file into the calling process.
Pages are brought in by page faults, when first touched.
| uargs | the arguments, in user memory: the address, length, protection, flags, descriptor and offset |
| ret | where to put the mapping's address |
Definition at line 514 of file sys_proc.c.
References vm_entry::base, curproc, fd_file(), FILE_SOCKET, file::flags, vm_entry::flags, kfree(), LOG_DEBUG, NULL, vm_entry::off, PAGE_MASK, PAGE_ROUND, vm_entry::qnode, vm_entry::size, sys_mmap(), uaccess_check(), vfs_map(), vm_entry_new(), vm_entry::vm_object, vm_object_decref(), vm_object_incref(), vm_object_vnode(), VM_SHARED, vm_space_insert(), VM_UR, VM_UW, and VM_UX.
Referenced by sys_mmap().
| long sys_mount | ( | struct aquila_mount_args * | args | ) |
Implements mount(): mounts a file system on a directory.
Only root may.
| args | the arguments, in user memory: the file system's type, the directory, flags, and the data (the device and the options) |
Definition at line 706 of file sys_file.c.
References curproc, kfree(), LOG_DEBUG, NULL, PROC_UIO, sys_mount(), upath_get(), and vfs_mount().
Referenced by sys_mount().
| long sys_munmap | ( | void * | addr, |
| size_t | len ) |
Implements munmap(): removes a mapping.
Only a whole mapping can be removed, not a part of one; the heap and the stack can't be.
| addr | the mapping's address |
| len | its length |
Definition at line 622 of file sys_proc.c.
References vm_entry::base, curproc, kfree(), LOG_DEBUG, PAGE_ROUND, vm_entry::qnode, queue_for, vm_entry::size, sys_munmap(), vm_space::vm_entries, vm_entry_destroy(), and vm_unmap_full().
Referenced by sys_munmap().
| long sys_nanosleep | ( | const struct aquila_timespec * | req, |
| struct aquila_timespec * | rem ) |
Implements nanosleep(): sleeps for a time.
A stop doesn't change the deadline: the call is restarted until the same time.
| req | how long to sleep |
| rem | where to put the time left if a signal ends the sleep, or NULL |
Definition at line 242 of file sys_signal.c.
References arch_rtime_ns(), curthread, ERESTARTNOHAND, LOG_DEBUG, sched_sleep(), and sys_nanosleep().
Referenced by sys_nanosleep().
| long sys_open | ( | const char * | path, |
| int | oflags, | ||
| mode_t | mode ) |
Implements open(): opens a file on a new descriptor, creating it with O_CREAT.
| path | the file's path |
| oflags | O_* flags |
| mode | the new file's permissions, with O_CREAT (less the umask) |
Definition at line 424 of file sys_file.c.
References do_openat(), LOG_DEBUG, and sys_open().
Referenced by sys_open().
| long sys_openat | ( | int | dirfd, |
| const char * | path, | ||
| int | oflags, | ||
| mode_t | mode ) |
Implements openat(): open(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| oflags | O_* flags |
| mode | the new file's permissions, with O_CREAT |
Definition at line 439 of file sys_file.c.
References do_openat(), LOG_DEBUG, and sys_openat().
Referenced by sys_openat().
| long sys_pipe | ( | int | fd[2] | ) |
Implements pipe(): makes a pipe, its read end and its write end open on two new descriptors.
| fd | where to put the two descriptors |
Definition at line 810 of file sys_file.c.
References curproc, file_new(), kfree(), LOG_DEBUG, NULL, pipefs_pipe(), proc_fd_close(), proc_fd_get(), proc_fd_install(), proc_fd_release(), sys_pipe(), and uaccess_check().
Referenced by sys_pipe().
| long sys_poll | ( | struct pollfd * | fds, |
| nfds_t | nfds, | ||
| int | timeout_ms ) |
Implements poll(): waits until one of the descriptors can be read or written, or the timeout passes, and says which can.
| fds | the descriptors and the events wanted, in user memory; their revents are set |
| nfds | how many there are |
| timeout_ms | the timeout in ms, or -1 for none |
Definition at line 198 of file sys_poll.c.
References curthread, ERESTARTNOHAND, fd_peek(), fd_ready(), fd_watch(), FDS_COUNT, kfree(), kmalloc(), LOG_DEBUG, NULL, poll_deadline(), poll_unregister(), sched_wait(), and sys_poll().
Referenced by sys_poll().
| long sys_read | ( | int | fildes, |
| void * | buf, | ||
| size_t | nbytes ) |
Implements read().
| fildes | the descriptor |
| buf | where to put the data |
| nbytes | how much to read, at most |
Definition at line 454 of file sys_file.c.
References fd_file(), iobuf_init(), LOG_DEBUG, sys_read(), uaccess_check(), and vfs_file_read().
Referenced by sys_read().
| long sys_readdir | ( | int | fd, |
| struct dirent * | dirent ) |
Reads a directory's next entry, for the C library's readdir().
| fd | the directory's descriptor |
| dirent | where to put the entry |
Definition at line 667 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, memset(), sys_readdir(), and vfs_file_readdir().
Referenced by sys_readdir().
| long sys_readlinkat | ( | int | dirfd, |
| const char * | upath, | ||
| char * | buf, | ||
| size_t | size ) |
Implements readlinkat(): what a symbolic link points to (not NUL-terminated).
| dirfd | the directory upath is relative to, or AT_FDCWD |
| upath | the link's path |
| buf | where to put the target |
| size | the room at buf; a longer target is cut |
Definition at line 1426 of file sys_file.c.
References at_uio(), kfree(), kmalloc(), LOG_DEBUG, MIN, NULL, sys_readlinkat(), uaccess_check(), upath_get(), UPATH_MAX, and vfs_readlink().
Referenced by sys_readlinkat().
| long sys_reboot | ( | unsigned | cmd | ) |
Implements reboot(): restarts, halts or powers off the machine, or sets what Ctrl+Alt+Del does.
Only root may.
| cmd | the command (RB_*) |
Definition at line 740 of file sys_proc.c.
References curproc, kernel_reboot(), LOG_DEBUG, and sys_reboot().
Referenced by sys_reboot().
| long sys_recv | ( | struct aquila_socket_io_args * | us | ) |
Implements recv() and recvfrom().
| us | the arguments, in user memory: the socket, the buffer, the flags, and where recvfrom() puts the sender's address |
Definition at line 313 of file sys_net.c.
References fd_file(), fd::flags, iobuf_init(), LOG_DEBUG, memset(), NULL, ksockaddr::sa, sockaddr_copyout(), sockaddr_room(), socket_recv(), sys_recv(), and uaccess_check().
Referenced by sys_recv().
| long sys_renameat | ( | int | olddirfd, |
| const char * | oldpath, | ||
| int | newdirfd, | ||
| const char * | newpath ) |
Implements renameat() (and rename()): moves a file to another name, replacing what was there.
| olddirfd | the directory oldpath is relative to, or AT_FDCWD |
| oldpath | the file's path |
| newdirfd | the directory newpath is relative to, or AT_FDCWD |
| newpath | its new path |
Definition at line 1464 of file sys_file.c.
References at_path(), kfree(), LOG_DEBUG, NULL, sys_renameat(), and vfs_rename().
Referenced by sys_renameat().
| long sys_rmdir | ( | const char * | path | ) |
Implements rmdir(): removes an empty directory.
| path | the directory's path |
Definition at line 1383 of file sys_file.c.
References do_unlinkat(), LOG_DEBUG, and sys_rmdir().
Referenced by sys_rmdir().
| long sys_sbrk | ( | ptrdiff_t | incr | ) |
Implements sbrk(): grows or shrinks the heap.
The heap may grow up to the next mapping (or the stack).
| incr | how many bytes to add (or take off, if negative) |
Definition at line 114 of file sys_proc.c.
References vm_entry::base, curproc, LOG_DEBUG, qnode::next, PAGE_ROUND, sys_sbrk(), USER_STACK_BASE, and qnode::value.
Referenced by sys_sbrk().
| long sys_select | ( | struct aquila_select_args * | args | ) |
Implements select() and pselect(): waits until a descriptor of the sets can be read or written, or the timeout passes, and says which can.
Exceptional conditions are never reported.
| args | the arguments, in user memory: nfds, the read, write and except sets, the timeout, and pselect()'s signal mask |
Definition at line 68 of file sys_poll.c.
References curproc, curthread, ERESTARTNOHAND, FD_ADD, FD_BIT, fd_peek(), fd_ready(), FD_SETSIZE, fd_watch(), LOG_DEBUG, poll_deadline(), poll_unregister(), sched_wait(), SIG_UNMASKABLE, sys_select(), timeval::tv_sec, and timeval::tv_usec.
Referenced by sys_select().
| long sys_send | ( | struct aquila_socket_io_args * | us | ) |
Implements send() and sendto().
A send on a connection that can't send anymore also raises SIGPIPE, unless MSG_NOSIGNAL is set.
| us | the arguments, in user memory: the socket, the data, the flags, and sendto()'s destination |
Definition at line 249 of file sys_net.c.
References curproc, fd_file(), fd::flags, iobuf_init(), LOG_DEBUG, memset(), NULL, ksockaddr::sa, signal_proc_send(), sockaddr_copyin(), socket_send(), sys_send(), and uaccess_check().
Referenced by sys_send().
| long sys_setgid | ( | gid_t | gid | ) |
Implements setgid(): sets the process's group ID.
Root may set any ID, other users only their own.
| gid | the group ID |
Definition at line 470 of file sys_proc.c.
References curproc, LOG_DEBUG, and sys_setgid().
Referenced by sys_setgid().
| long sys_sethostname | ( | const char * | name, |
| size_t | len ) |
Implements sethostname().
Only root may.
| name | the host name (not NUL-terminated) |
| len | its length |
Definition at line 793 of file sys_proc.c.
References curproc, LOG_DEBUG, memcpy(), nodename, and sys_sethostname().
Referenced by sys_sethostname().
| long sys_setitimer | ( | int | which, |
| const struct aquila_itimer * | new, | ||
| struct aquila_itimer * | old ) |
Implements setitimer(): sets the real time timer, which sends SIGALRM, and reads the old one.
| which | AQUILA_ITIMER_REAL (the only timer supported) |
| new | the new timer, or NULL to only read the old one |
| old | where to put the old timer, or NULL |
Definition at line 201 of file sys_signal.c.
References curproc, LOG_DEBUG, sched_alarm(), sched_alarm_get(), and sys_setitimer().
Referenced by sys_setitimer().
Implements setpgid(): moves a process (the caller or one of its children) into a process group of its session.
| pid | the process, or 0 for the caller |
| pgid | the group's ID, or 0 for the process's own ID (a new group) |
Definition at line 418 of file sys_proc.c.
References curproc, session::leader, LOG_DEBUG, proc::parent, proc::pgrp, proc::pid, proc_pid_find(), proc_setpgid(), pgroup::session, and sys_setpgid().
Referenced by sys_setpgid().
| long sys_setsid | ( | void | ) |
Implements setsid(): makes the calling process the leader of a new session and process group.
Definition at line 758 of file sys_proc.c.
References curproc, LOG_DEBUG, pgroup::pgid, proc::pgrp, proc::pgrp_node, pgrp_release(), proc::pid, pgroup::procs, session_new(), and sys_setsid().
Referenced by sys_setsid().
| long sys_setsockopt | ( | int | fd, |
| int | level, | ||
| int | name, | ||
| const void * | val, | ||
| socklen_t | len ) |
Implements setsockopt(): sets a socket option.
| fd | the socket |
| level | SOL_SOCKET, or a protocol's level |
| name | the option |
| val | its value |
| len | the value's size |
Definition at line 470 of file sys_net.c.
References fd_file(), LOG_DEBUG, MIN, socket_setsockopt(), and sys_setsockopt().
Referenced by sys_setsockopt().
| long sys_setuid | ( | uid_t | uid | ) |
Implements setuid(): sets the process's user ID.
There are no separate effective or saved IDs: root may set any ID, other users only their own.
| uid | the user ID |
Definition at line 451 of file sys_proc.c.
References curproc, LOG_DEBUG, and sys_setuid().
Referenced by sys_setuid().
| long sys_shutdown | ( | int | fd, |
| int | how ) |
Implements shutdown(): shuts down reading, writing or both on a socket, which stays open.
| fd | the socket |
| how | SHUT_RD, SHUT_WR or SHUT_RDWR |
Definition at line 501 of file sys_net.c.
References fd_file(), LOG_DEBUG, socket_shutdown_dir(), and sys_shutdown().
Referenced by sys_shutdown().
| long sys_sigaction | ( | int | sig, |
| const struct aquila_sigaction * | act, | ||
| struct aquila_sigaction * | oact ) |
Implements sigaction(): reads a signal's action, and sets a new one.
| sig | the signal |
| act | the new action, or NULL to leave it |
| oact | where to put the old action, or NULL |
Definition at line 37 of file sys_signal.c.
References curproc, LOG_DEBUG, SIG_DFL, SIG_IGN, SIG_MAX, signal_action_set(), sys_sigaction(), and uaccess_check().
Referenced by sys_sigaction().
Implements sigprocmask(): reads and changes the process's signal mask.
SIGKILL and SIGSTOP can't be blocked.
| how | SIG_BLOCK, SIG_UNBLOCK or SIG_SETMASK |
| set | the signals, or NULL to leave the mask |
| oldset | where to put the old mask, or NULL |
Definition at line 108 of file sys_signal.c.
References curproc, LOG_DEBUG, SIG_UNMASKABLE, and sys_sigmask().
Referenced by sys_sigmask().
| long sys_sigreturn | ( | void | ) |
Implements sigreturn(): a signal handler returns, and the registers and signal mask that its frame saved are restored.
The kernel's signal code page calls it when a handler returns.
Definition at line 182 of file sys_signal.c.
References arch_sigreturn(), LOG_DEBUG, and sys_sigreturn().
Referenced by sys_sigreturn().
| long sys_sigsuspend | ( | const sigset_t * | set | ) |
Implements sigsuspend(): replaces the signal mask and waits for a signal.
The old mask comes back once a handler has run.
| set | the mask to wait with |
Definition at line 146 of file sys_signal.c.
References curproc, curthread, ERESTARTNOHAND, LOG_DEBUG, thread::sig_oldmask, thread::sig_oldmask_set, SIG_UNMASKABLE, sys_sigsuspend(), and waitq_sleep().
Referenced by sys_sigsuspend().
| long sys_socket | ( | int | domain, |
| int | type, | ||
| int | protocol ) |
Implements socket(): makes a socket, open on a new descriptor.
| domain | AF_UNIX or AF_INET |
| type | SOCK_STREAM or SOCK_DGRAM |
| protocol | the protocol, or 0 for the type's default |
Definition at line 19 of file sys_net.c.
References curproc, file_new(), kfree(), LOG_DEBUG, proc_fd_get(), proc_fd_install(), proc_fd_release(), socket_create(), and sys_socket().
Referenced by sys_socket().
| long sys_stat | ( | const char * | path, |
| struct aquila_stat * | buf ) |
Implements stat(): a file's attributes, following a symbolic link.
| path | the file's path |
| buf | where to put them |
Definition at line 504 of file sys_file.c.
References do_fstatat(), LOG_DEBUG, and sys_stat().
Referenced by sys_stat().
| long sys_symlinkat | ( | const char * | utarget, |
| int | dirfd, | ||
| const char * | upath ) |
Implements symlinkat(): makes a symbolic link.
| utarget | what it points to |
| dirfd | the directory upath is relative to, or AT_FDCWD |
| upath | the link's path |
Definition at line 1397 of file sys_file.c.
References at_uio(), kfree(), LOG_DEBUG, NULL, sys_symlinkat(), upath_get(), and vfs_symlink().
Referenced by sys_symlinkat().
| long sys_sync | ( | void | ) |
Implements sync(): writes out what the devices' caches hold.
Definition at line 1508 of file sys_file.c.
References kdev_sync(), LOG_DEBUG, and sys_sync().
Referenced by sys_sync().
| long sys_sysconf | ( | int | name | ) |
Implements sysconf(): not supported; the C library answers it.
| name | the variable |
Definition at line 659 of file sys_proc.c.
References LOG_DEBUG, and sys_sysconf().
Referenced by sys_sysconf().
| long sys_thread_create | ( | struct aquila_thread_args * | __uthread | ) |
Makes a new thread in the calling process (for pthread_create()), and makes it ready to run.
| __uthread | the arguments, in user memory: the thread's stack, the C library's start, the thread's function and its argument |
Definition at line 286 of file sys_proc.c.
References curthread, LOG_DEBUG, NULL, sched_thread_ready(), thread::stack, sys_thread_create(), thread_create(), thread::tid, and uaccess_check().
Referenced by sys_thread_create().
| long sys_thread_exit | ( | void * | value_ptr | ) |
Ends the calling thread (for pthread_exit()).
It stays as a zombie until another thread joins it. The last live thread ending ends the process. It doesn't return.
| value_ptr | the value that thread_join() returns |
Definition at line 325 of file sys_proc.c.
References arch_cur_thread_kill(), curproc, curthread, LOG_DEBUG, thread::owner, queue_for, thread::state, sys_exit(), sys_thread_exit(), proc::thread_join, proc::threads, waitq_wakeup(), and ZOMBIE.
Referenced by sys_thread_exit().
| long sys_thread_join | ( | int | tid, |
| void ** | value_ptr ) |
Waits for a thread of the calling process to end, and frees it (for pthread_join()).
| tid | the thread's ID |
| value_ptr | where to put the value it ended with, or NULL |
Definition at line 367 of file sys_proc.c.
References curproc, curthread, ERESTARTSYS, thread::exit_value, kfree(), LOG_DEBUG, NULL, thread::owner, queue_for, thread::state, sys_thread_join(), proc::threads, thread::tid, waitq_sleep(), and ZOMBIE.
Referenced by sys_thread_join().
| long sys_thread_self | ( | void | ) |
Returns the calling thread's ID, for pthread_self().
Definition at line 727 of file sys_proc.c.
References curthread, and sys_thread_self().
Referenced by sys_thread_self().
| long sys_times | ( | struct aquila_tms * | buf | ) |
Implements times(): the CPU times of the process and of its children that it waited for, in ticks (AQUILA_CLK_TCK a second).
| buf | where to put them |
Definition at line 148 of file sys_proc.c.
References arch_rtime_ns(), curproc, LOG_DEBUG, sys_times(), and tick.
Referenced by sys_times().
| long sys_umask | ( | mode_t | mask | ) |
Implements umask(): sets the permissions that new files don't get.
| mask | the new mask |
Definition at line 1089 of file sys_file.c.
References curproc, LOG_DEBUG, and sys_umask().
Referenced by sys_umask().
| long sys_uname | ( | struct utsname * | name | ) |
Implements uname(): the system's name, release, version and machine, and the host name.
| name | where to put them |
Definition at line 259 of file sys_proc.c.
References LOG_DEBUG, memcpy(), memset(), MIN, nodename, sys_uname(), UTSNAME_MACHINE, UTSNAME_RELEASE, UTSNAME_SYSNAME, and UTSNAME_VERSION.
Referenced by sys_uname().
| long sys_unlink | ( | const char * | path | ) |
Implements unlink(): removes a name of a file (not a directory's).
| path | the name |
Definition at line 553 of file sys_file.c.
References do_unlinkat(), LOG_DEBUG, and sys_unlink().
Referenced by sys_unlink().
| long sys_unlinkat | ( | int | dirfd, |
| const char * | path, | ||
| int | flags ) |
Implements unlinkat(): unlink(), or rmdir() with AT_REMOVEDIR, with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the name |
| flags | AT_REMOVEDIR to remove a directory |
Definition at line 568 of file sys_file.c.
References do_unlinkat(), uio::flags, LOG_DEBUG, and sys_unlinkat().
Referenced by sys_unlinkat().
| long sys_utimensat | ( | int | dirfd, |
| const char * | path, | ||
| const struct aquila_timespec | times[2], | ||
| int | flags ) |
Implements utimensat() (and futimens()): sets a file's access and modification times.
| dirfd | the directory path is relative to, or AT_FDCWD; with a NULL path, the file itself (futimens()) |
| path | the file's path, or NULL |
| times | the two times, or NULL for now |
| flags | AT_SYMLINK_NOFOLLOW for a symbolic link's own |
Definition at line 1340 of file sys_file.c.
References at_lookup(), curproc, fd_vnode(), uio::flags, LOG_DEBUG, NULL, PROC_UIO, sys_utimensat(), vfs_close(), and vfs_utimens().
Referenced by sys_utimensat().
| long sys_waitpid | ( | int | pid, |
| int * | stat_loc, | ||
| int | options ) |
Implements waitpid(): waits for a child to end (or stop, or continue, if asked), and reaps it if it ended.
| pid | which child: that one if > 0, any if -1, any in the caller's process group if 0, or any in process group -pid if < -1 |
| stat_loc | where to put its status, or NULL |
| options | WNOHANG, WUNTRACED, WCONTINUED |
Definition at line 181 of file sys_proc.c.
References curproc, ERESTARTSYS, proc::exit, LOG_DEBUG, options(), proc::parent, pgroup::pgid, proc::pgrp, proc::pid, proc_reap(), procs, queue_for, proc::stopped, sys_waitpid(), WAIT_CONTINUED, proc::wait_event, WAIT_STOPPED, waitq_sleep(), and proc::zombie.
Referenced by sys_waitpid().
| long sys_write | ( | int | fd, |
| void * | buf, | ||
| size_t | nbytes ) |
Implements write().
Writing to a pipe that no one reads also raises SIGPIPE.
| fd | the descriptor |
| buf | the data |
| nbytes | how much to write |
Definition at line 584 of file sys_file.c.
References curproc, fd_file(), iobuf_init(), LOG_DEBUG, signal_proc_send(), sys_write(), uaccess_check(), and vfs_file_write().
Referenced by sys_write().
| int upath_get | ( | const char * | upath, |
| char ** | path ) |
Copies a path from user memory into a new kernel buffer.
| upath | the path, in user memory |
| path | set to the kernel's copy, which the caller frees with kfree(); NULL on failure |
Definition at line 46 of file syscall.c.
References kfree(), kmalloc(), NULL, upath_get(), and UPATH_MAX.
Referenced by at_lookup(), at_path(), do_mknodat(), do_openat(), do_unlinkat(), sys_chdir(), sys_execve(), sys_mount(), sys_readlinkat(), sys_symlinkat(), and upath_get().