|
ginnOS
The reference: libc, the libraries and the kernel
|
This file contains the declarations of POSIX-like system call wrappers. More...
Go to the source code of this file.
Data Structures | |
| struct | key_event_t |
| keyboard event structure (matches kernel keyboard_event_t). More... | |
Functions | |
| ssize_t | write (int fd, const void *buf, size_t count) |
| write bytes to a file descriptor. | |
| ssize_t | read (int fd, void *buf, size_t count) |
| read bytes from a file descriptor. | |
| int | close (int fd) |
| close a file descriptor. | |
| pid_t | exec (const char *path, const char **argv) |
| execute a program, spawning a child process. | |
| pid_t | fork (void) |
| create a child process that is a copy of the caller. | |
| int | execve (const char *path, char *const argv[], char *const envp[]) |
| replace the calling process's program. | |
| int | execv (const char *path, char *const argv[]) |
| execve with the environment of the calling process. | |
| int | execvp (const char *file, char *const argv[]) |
| execv, but a file name with no '/' is looked for in the directories of PATH (/bin when PATH is not set). | |
| int | execl (const char *path, const char *arg,...) |
| execv, execvp and execve with the arguments as a list that ends with NULL. | |
| int | execlp (const char *file, const char *arg,...) |
| int | execle (const char *path, const char *arg,...) |
| void | _exit (int status) __attribute__((noreturn)) |
| terminate the current process. | |
| int | dup (int fd) |
| duplicate a descriptor to the lowest free one; both share the open file. | |
| int | access (const char *path, int mode) |
| check that a file exists and may be accessed. | |
| int | faccessat (int dirfd, const char *path, int mode, int flags) |
| ssize_t | pread (int fd, void *buf, size_t count, off_t offset) |
| read or write at an offset, without moving the file offset. | |
| ssize_t | pwrite (int fd, const void *buf, size_t count, off_t offset) |
| int | fsync (int fd) |
| write an open file's data to disk. | |
| unsigned int | alarm (unsigned int seconds) |
| send SIGALRM to the calling process after a number of seconds. | |
| int | pause (void) |
| sleep until a signal is caught. | |
| unsigned int | sleep (unsigned int seconds) |
| sleep for a number of seconds (or microseconds). | |
| int | usleep (unsigned int microseconds) |
| int | setpgid (pid_t pid, pid_t pgid) |
| process groups and sessions (job control). | |
| pid_t | getpgid (pid_t pid) |
| pid_t | getpgrp (void) |
| pid_t | setsid (void) |
| int | nice (int increment) |
| add increment to the caller's nice value (see sys/resource.h). | |
| int | chroot (const char *path) |
| make a directory the root of the caller's paths ("/" is then that directory; root only). | |
| pid_t | getsid (pid_t pid) |
| uid_t | getuid (void) |
| user and group ids: real (who started the process) and effective (what it may do). | |
| uid_t | geteuid (void) |
| gid_t | getgid (void) |
| gid_t | getegid (void) |
| int | setuid (uid_t uid) |
| int | setgid (gid_t gid) |
| int | seteuid (uid_t uid) |
| int | setegid (gid_t gid) |
| int | chown (const char *path, uid_t uid, gid_t gid) |
| change the owner of a file. | |
| int | fchown (int fd, uid_t uid, gid_t gid) |
| int | lchown (const char *path, uid_t uid, gid_t gid) |
| int | fchownat (int dirfd, const char *path, uid_t uid, gid_t gid, int flags) |
| pid_t | getppid (void) |
| get the parent's process ID. | |
| int | sched_yield (void) |
| let other ready processes run before this one continues. | |
| pid_t | getpid (void) |
| get the current process ID. | |
| void * | sbrk (int increment) |
| grow the program break (allocate heap memory). | |
| char * | getcwd (char *buf, size_t size) |
| get the current working directory. | |
| int | chdir (const char *path) |
| change the current working directory. | |
| int | unlink (const char *path) |
| remove (unlink) a file. | |
| int | symlink (const char *target, const char *path) |
| make a symbolic link at path that points at target | |
| int | symlinkat (const char *target, int dirfd, const char *path) |
| ssize_t | readlink (const char *restrict path, char *restrict buffer, size_t size) |
| read a symbolic link's target (no NUL; a longer target is cut). | |
| ssize_t | readlinkat (int dirfd, const char *restrict path, char *restrict buffer, size_t size) |
| int | link (const char *old_path, const char *new_path) |
| give a file one more name (a hard link) | |
| int | linkat (int old_dirfd, const char *old_path, int new_dirfd, const char *new_path, int flags) |
| int | unlinkat (int dirfd, const char *path, int flags) |
| remove a file, or with AT_REMOVEDIR a directory, relative to dirfd | |
| int | rmdir (const char *path) |
| remove a directory. | |
| int | create (const char *path) |
| create a file, or truncate it if it exists (the file is not left open). | |
| int | ttyctl (int mode) |
| switch the terminal on fd 0 between two modes (a wrapper over termios): TTY_COOKED is line input with echo and signal keys; TTY_RAW gives one key_event_t per read (read_event), with no echo and Ctrl+C as a key. | |
| char * | getpass (const char *prompt) |
| ask for a password on the terminal (standard input), without echo. | |
| int | isatty (int fd) |
| true if fd refers to a terminal. | |
| int | ioctl (int fd, unsigned int request, void *arg) |
| issue a device-control request on an open file descriptor. | |
| int | read_event (key_event_t *event) |
| read a single keyboard event from stdin (raw mode). | |
| int | pipe (int fds[2]) |
| create a pipe (pair of connected file descriptors). | |
| int | dup2 (int old_fd, int new_fd) |
| duplicate a file descriptor to a specific number. | |
| int | ftruncate (int fd, off_t length) |
| cut or grow a file to length bytes (the new bytes read as zeros). | |
| int | truncate (const char *path, off_t length) |
| off_t | lseek (int fd, off_t offset, int whence) |
| set file cursor position. | |
| long | sysconf (int name) |
| a limit of the system (a SC name), or -1 with EINVAL | |
| long | pathconf (const char *path, int name) |
| a limit of the files at path (a PC name). | |
| long | fpathconf (int fd, int name) |
| size_t | confstr (int name, char *buffer, size_t size) |
| a string value of the system (a CS name) into buffer. | |
| int | gethostname (char *name, size_t length) |
| the name of this computer (uname's nodename) into name | |
| int | sethostname (const char *name, size_t length) |
| set the host name (root only; at most 64 bytes) | |
| char * | ttyname (int fd) |
| the name of the terminal open as fd (as "/dev/pts/0"). | |
| int | ttyname_r (int fd, char *buffer, size_t size) |
| void | sync (void) |
| make every write reach the disk. | |
| int | daemon (int keep_dir, int keep_files) |
| go on in the background: a new process in a new session, with no terminal. | |
| int | getopt (int argc, char *const argv[], const char *options) |
| the next option of a command line (POSIX getopt). | |
| int | getentropy (void *buf, size_t length) |
| fill buf with length random bytes (at most 256) from the kernel. | |
| char * | getlogin (void) |
| the name of the user who runs the program (from the password file), or NULL | |
Variables | |
| char * | optarg |
| int | optind |
| int | opterr |
| int | optopt |
This file contains the declarations of POSIX-like system call wrappers.
| #define STDIN_FILENO 0 |
| #define STDOUT_FILENO 1 |
| #define STDERR_FILENO 2 |
| #define F_OK 0 |
| #define X_OK 1 |
| #define W_OK 2 |
| #define R_OK 4 |
| #define TTY_COOKED 0 |
| #define TTY_RAW 1 |
| #define CONSOLE_KEY_EVENT_CHAR 0 |
| #define CONSOLE_KEY_EVENT_SPECIAL 1 |
| #define CONSOLE_KEY_EVENT_RAW 2 |
| #define CONSOLE_KEY_UP 1 |
| #define CONSOLE_KEY_DOWN 2 |
| #define CONSOLE_KEY_LEFT 3 |
| #define CONSOLE_KEY_RIGHT 4 |
| #define CONSOLE_KEY_HOME 5 |
| #define CONSOLE_KEY_END 6 |
| #define CONSOLE_KEY_PAGE_UP 7 |
| #define CONSOLE_KEY_PAGE_DOWN 8 |
| #define CONSOLE_KEY_INSERT 9 |
| #define CONSOLE_KEY_DELETE 10 |
| #define SEEK_SET 0 |
| #define SEEK_CUR 1 |
| #define SEEK_END 2 |
| #define _SC_ARG_MAX 0 |
| #define _SC_CHILD_MAX 1 |
| #define _SC_CLK_TCK 2 |
| #define _SC_OPEN_MAX 4 |
| #define _SC_PAGESIZE 30 |
| #define _SC_PAGE_SIZE _SC_PAGESIZE |
| #define _SC_NPROCESSORS_CONF 83 |
| #define _SC_NPROCESSORS_ONLN 84 |
| #define _SC_LINE_MAX 43 |
| #define _SC_HOST_NAME_MAX 180 |
| #define _SC_LOGIN_NAME_MAX 71 |
| #define _SC_PHYS_PAGES 85 |
| #define _PC_LINK_MAX 0 |
| #define _PC_MAX_CANON 1 |
| #define _PC_MAX_INPUT 2 |
| #define _PC_NAME_MAX 3 |
| #define _PC_PATH_MAX 4 |
| #define _PC_PIPE_BUF 5 |
| #define _PC_CHOWN_RESTRICTED 6 |
| #define _PC_NO_TRUNC 7 |
| #define _PC_VDISABLE 8 |
| #define _CS_PATH 0 |
write bytes to a file descriptor.
| fd | file descriptor (1 = stdout, 2 = stderr). |
| buf | pointer to data to write. |
| count | number of bytes to write. |
read bytes from a file descriptor.
| fd | file descriptor (0 = stdin). |
| buf | buffer to read into. |
| count | maximum bytes to read. |
| int close | ( | int | fd | ) |
close a file descriptor.
| fd | file descriptor to close. |
| pid_t exec | ( | const char * | path, |
| const char ** | argv ) |
execute a program, spawning a child process.
| path | path to the ELF executable. |
| argv | null-terminated array of argument strings (may be NULL). |
| pid_t fork | ( | void | ) |
create a child process that is a copy of the caller.
the two share nothing after the call: memory is copied (lazily, on the first write), and the child gets its own copy of every fd.
| int execve | ( | const char * | path, |
| char *const | argv[], | ||
| char *const | envp[] ) |
replace the calling process's program.
the pid, cwd and open fds stay.
| path | path to the ELF executable. |
| argv | NULL-terminated argument strings. |
| envp | NULL-terminated "KEY=VALUE" environment strings. |
| int execv | ( | const char * | path, |
| char *const | argv[] ) |
execve with the environment of the calling process.
| int execvp | ( | const char * | file, |
| char *const | argv[] ) |
execv, but a file name with no '/' is looked for in the directories of PATH (/bin when PATH is not set).
| int execl | ( | const char * | path, |
| const char * | arg, | ||
| ... ) |
execv, execvp and execve with the arguments as a list that ends with NULL.
execle takes the environment after the NULL.
| int execlp | ( | const char * | file, |
| const char * | arg, | ||
| ... ) |
| int execle | ( | const char * | path, |
| const char * | arg, | ||
| ... ) |
| void _exit | ( | int | status | ) |
terminate the current process.
| status | exit code. |
| int dup | ( | int | fd | ) |
duplicate a descriptor to the lowest free one; both share the open file.
| int access | ( | const char * | path, |
| int | mode ) |
check that a file exists and may be accessed.
there are no users yet, so every existing file allows every access.
| path | the file. |
| mode | F_OK, or R_OK | W_OK | X_OK. |
| int faccessat | ( | int | dirfd, |
| const char * | path, | ||
| int | mode, | ||
| int | flags ) |
read or write at an offset, without moving the file offset.
| int fsync | ( | int | fd | ) |
write an open file's data to disk.
| unsigned int alarm | ( | unsigned int | seconds | ) |
send SIGALRM to the calling process after a number of seconds.
| seconds | 0 cancels the alarm. |
| int pause | ( | void | ) |
sleep until a signal is caught.
always returns -1 with EINTR.
| unsigned int sleep | ( | unsigned int | seconds | ) |
sleep for a number of seconds (or microseconds).
| int usleep | ( | unsigned int | microseconds | ) |
| pid_t getpgrp | ( | void | ) |
| pid_t setsid | ( | void | ) |
| int nice | ( | int | increment | ) |
add increment to the caller's nice value (see sys/resource.h).
| int chroot | ( | const char * | path | ) |
make a directory the root of the caller's paths ("/" is then that directory; root only).
the working directory stays: chdir("/") after.
| uid_t getuid | ( | void | ) |
user and group ids: real (who started the process) and effective (what it may do).
setuid/setgid as root set all ids; otherwise only to the real or saved id. set the group before giving up root.
| uid_t geteuid | ( | void | ) |
| gid_t getgid | ( | void | ) |
| gid_t getegid | ( | void | ) |
| int setuid | ( | uid_t | uid | ) |
| int setgid | ( | gid_t | gid | ) |
| int seteuid | ( | uid_t | uid | ) |
| int setegid | ( | gid_t | gid | ) |
| pid_t getppid | ( | void | ) |
get the parent's process ID.
| int sched_yield | ( | void | ) |
let other ready processes run before this one continues.
| pid_t getpid | ( | void | ) |
get the current process ID.
| void * sbrk | ( | int | increment | ) |
grow the program break (allocate heap memory).
| increment | number of bytes to grow by. |
| char * getcwd | ( | char * | buf, |
| size_t | size ) |
get the current working directory.
| buf | buffer to write the path into; NULL: a new one from malloc (of size bytes, or as long as needed when size is 0). |
| size | size of the buffer. |
| int chdir | ( | const char * | path | ) |
change the current working directory.
| path | path to change to. |
| int unlink | ( | const char * | path | ) |
remove (unlink) a file.
| path | path to the file to remove. |
| int symlink | ( | const char * | target, |
| const char * | path ) |
make a symbolic link at path that points at target
| int symlinkat | ( | const char * | target, |
| int | dirfd, | ||
| const char * | path ) |
read a symbolic link's target (no NUL; a longer target is cut).
| int link | ( | const char * | old_path, |
| const char * | new_path ) |
give a file one more name (a hard link)
| int linkat | ( | int | old_dirfd, |
| const char * | old_path, | ||
| int | new_dirfd, | ||
| const char * | new_path, | ||
| int | flags ) |
| int unlinkat | ( | int | dirfd, |
| const char * | path, | ||
| int | flags ) |
remove a file, or with AT_REMOVEDIR a directory, relative to dirfd
| int rmdir | ( | const char * | path | ) |
remove a directory.
| path | path to the directory to remove. |
| int create | ( | const char * | path | ) |
create a file, or truncate it if it exists (the file is not left open).
| path | path to the file to create. |
| int ttyctl | ( | int | mode | ) |
switch the terminal on fd 0 between two modes (a wrapper over termios): TTY_COOKED is line input with echo and signal keys; TTY_RAW gives one key_event_t per read (read_event), with no echo and Ctrl+C as a key.
the mode belongs to the terminal, so it stays after the program exits.
| mode | TTY_COOKED or TTY_RAW. |
| char * getpass | ( | const char * | prompt | ) |
ask for a password on the terminal (standard input), without echo.
| int isatty | ( | int | fd | ) |
true if fd refers to a terminal.
| int ioctl | ( | int | fd, |
| unsigned int | request, | ||
| void * | arg ) |
issue a device-control request on an open file descriptor.
only device nodes under /dev service ioctls; other fds return -1/ENOTTY.
| fd | open file descriptor (e.g. an open "/dev/fb0"). |
| request | driver-defined request code. |
| arg | request-specific argument, usually a pointer to a struct. |
| int read_event | ( | key_event_t * | event | ) |
read a single keyboard event from stdin (raw mode).
blocks until an event is available.
| event | pointer to event struct to fill. |
| int pipe | ( | int | fds[2] | ) |
create a pipe (pair of connected file descriptors).
| fds | array of two ints: fds[0] = read end, fds[1] = write end. |
| int dup2 | ( | int | old_fd, |
| int | new_fd ) |
duplicate a file descriptor to a specific number.
if new_fd is already open, it is closed first.
| old_fd | the fd to duplicate. |
| new_fd | the target fd number. |
| int ftruncate | ( | int | fd, |
| off_t | length ) |
cut or grow a file to length bytes (the new bytes read as zeros).
the file offset stays.
| int truncate | ( | const char * | path, |
| off_t | length ) |
set file cursor position.
| fd | file descriptor. |
| offset | byte offset. |
| whence | SEEK_SET (from start), SEEK_CUR (from current), SEEK_END (from end). |
| long sysconf | ( | int | name | ) |
a limit of the system (a SC name), or -1 with EINVAL
| long pathconf | ( | const char * | path, |
| int | name ) |
a limit of the files at path (a PC name).
ginnOS's limits are the same on every filesystem.
| long fpathconf | ( | int | fd, |
| int | name ) |
a string value of the system (a CS name) into buffer.
| int gethostname | ( | char * | name, |
| size_t | length ) |
the name of this computer (uname's nodename) into name
| int sethostname | ( | const char * | name, |
| size_t | length ) |
set the host name (root only; at most 64 bytes)
| char * ttyname | ( | int | fd | ) |
the name of the terminal open as fd (as "/dev/pts/0").
| int ttyname_r | ( | int | fd, |
| char * | buffer, | ||
| size_t | size ) |
| void sync | ( | void | ) |
make every write reach the disk.
ginnOS writes through its cache at once, so there is nothing to wait for.
| int daemon | ( | int | keep_dir, |
| int | keep_files ) |
go on in the background: a new process in a new session, with no terminal.
| keep_dir | 0: change to "/". |
| keep_files | 0: read and write /dev/null on 0, 1 and 2. |
| int getopt | ( | int | argc, |
| char *const | argv[], | ||
| const char * | options ) |
the next option of a command line (POSIX getopt).
| options | the option letters; a letter with ':' after it takes an argument. a ':' first: no messages, and ':' for a missing argument. |
| int getentropy | ( | void * | buf, |
| size_t | length ) |
fill buf with length random bytes (at most 256) from the kernel.
| char * getlogin | ( | void | ) |
the name of the user who runs the program (from the password file), or NULL
|
extern |
|
extern |
|
extern |
|
extern |