2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-10-04 12:02:42 +03:00
|
|
|
/* standard symbolic constants and types
|
|
|
|
*
|
|
|
|
* values from POSIX standard unix specification
|
|
|
|
*
|
|
|
|
* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html
|
|
|
|
*/
|
|
|
|
|
2018-10-22 14:57:25 +03:00
|
|
|
#pragma once
|
|
|
|
|
2021-08-14 20:03:23 +03:00
|
|
|
#include <Kernel/API/POSIX/unistd.h>
|
2023-07-15 19:51:44 +03:00
|
|
|
#include <bits/getopt.h>
|
2021-01-19 01:05:11 +03:00
|
|
|
#include <fd_set.h>
|
2019-05-28 12:53:16 +03:00
|
|
|
#include <limits.h>
|
2022-08-15 18:57:43 +03:00
|
|
|
#include <sys/cdefs.h>
|
2018-10-22 14:57:25 +03:00
|
|
|
|
2018-10-31 04:09:11 +03:00
|
|
|
__BEGIN_DECLS
|
2018-10-22 14:57:25 +03:00
|
|
|
|
2019-02-23 19:24:50 +03:00
|
|
|
#define HZ 1000
|
|
|
|
|
2019-10-04 12:02:42 +03:00
|
|
|
/* lseek whence values */
|
2019-11-16 11:35:48 +03:00
|
|
|
#ifndef _STDIO_H /* also defined in stdio.h */
|
|
|
|
# define SEEK_SET 0 /* from beginning of file. */
|
|
|
|
# define SEEK_CUR 1 /* from current position in file. */
|
|
|
|
# define SEEK_END 2 /* from the end of the file. */
|
2019-10-04 12:02:42 +03:00
|
|
|
#endif
|
|
|
|
|
2018-10-31 19:50:43 +03:00
|
|
|
extern char** environ;
|
|
|
|
|
2019-08-15 21:55:10 +03:00
|
|
|
int get_process_name(char* buffer, int buffer_size);
|
2022-04-01 20:58:27 +03:00
|
|
|
int set_process_name(char const* name, size_t name_length);
|
2022-01-08 17:32:59 +03:00
|
|
|
void dump_backtrace(void);
|
2019-05-19 20:54:20 +03:00
|
|
|
int fsync(int fd);
|
2022-01-08 17:32:59 +03:00
|
|
|
int gettid(void);
|
|
|
|
int getpagesize(void);
|
|
|
|
pid_t fork(void);
|
|
|
|
pid_t vfork(void);
|
2022-01-11 11:50:09 +03:00
|
|
|
int daemon(int nochdir, int noclose);
|
2022-04-01 20:58:27 +03:00
|
|
|
int execv(char const* path, char* const argv[]);
|
|
|
|
int execve(char const* filename, char* const argv[], char* const envp[]);
|
|
|
|
int execvpe(char const* filename, char* const argv[], char* const envp[]);
|
|
|
|
int execvp(char const* filename, char* const argv[]);
|
|
|
|
int execl(char const* filename, char const* arg, ...);
|
|
|
|
int execle(char const* filename, char const* arg, ...);
|
|
|
|
int execlp(char const* filename, char const* arg, ...);
|
2022-01-08 17:32:59 +03:00
|
|
|
void sync(void);
|
2020-05-26 13:15:14 +03:00
|
|
|
__attribute__((noreturn)) void _exit(int status);
|
2018-11-02 14:56:51 +03:00
|
|
|
pid_t getsid(pid_t);
|
2022-01-08 17:32:59 +03:00
|
|
|
pid_t setsid(void);
|
2018-11-02 14:56:51 +03:00
|
|
|
int setpgid(pid_t pid, pid_t pgid);
|
|
|
|
pid_t getpgid(pid_t);
|
2022-01-08 17:32:59 +03:00
|
|
|
pid_t getpgrp(void);
|
|
|
|
uid_t geteuid(void);
|
|
|
|
gid_t getegid(void);
|
|
|
|
uid_t getuid(void);
|
|
|
|
gid_t getgid(void);
|
|
|
|
pid_t getpid(void);
|
|
|
|
pid_t getppid(void);
|
2020-07-01 02:34:20 +03:00
|
|
|
int getresuid(uid_t*, uid_t*, uid_t*);
|
|
|
|
int getresgid(gid_t*, gid_t*, gid_t*);
|
2018-11-07 03:38:51 +03:00
|
|
|
int getgroups(int size, gid_t list[]);
|
2022-04-01 20:58:27 +03:00
|
|
|
int setgroups(size_t, gid_t const*);
|
2020-06-17 15:58:00 +03:00
|
|
|
int seteuid(uid_t);
|
|
|
|
int setegid(gid_t);
|
2019-02-22 01:35:07 +03:00
|
|
|
int setuid(uid_t);
|
|
|
|
int setgid(gid_t);
|
2021-04-09 14:13:15 +03:00
|
|
|
int setreuid(uid_t, uid_t);
|
2020-06-17 15:58:00 +03:00
|
|
|
int setresuid(uid_t, uid_t, uid_t);
|
2022-10-01 15:47:38 +03:00
|
|
|
int setregid(gid_t, gid_t);
|
2020-06-17 15:58:00 +03:00
|
|
|
int setresgid(gid_t, gid_t, gid_t);
|
2018-11-02 15:14:25 +03:00
|
|
|
pid_t tcgetpgrp(int fd);
|
|
|
|
int tcsetpgrp(int fd, pid_t pgid);
|
2018-10-23 11:12:50 +03:00
|
|
|
ssize_t read(int fd, void* buf, size_t count);
|
2020-02-20 08:59:23 +03:00
|
|
|
ssize_t pread(int fd, void* buf, size_t count, off_t);
|
2022-04-01 20:58:27 +03:00
|
|
|
ssize_t write(int fd, void const* buf, size_t count);
|
|
|
|
ssize_t pwrite(int fd, void const* buf, size_t count, off_t);
|
2018-10-23 11:12:50 +03:00
|
|
|
int close(int fd);
|
2022-04-01 20:58:27 +03:00
|
|
|
int chdir(char const* path);
|
2019-09-12 02:18:25 +03:00
|
|
|
int fchdir(int fd);
|
2018-10-24 15:28:22 +03:00
|
|
|
char* getcwd(char* buffer, size_t size);
|
2018-11-06 17:59:57 +03:00
|
|
|
char* getwd(char* buffer);
|
2021-04-11 20:00:36 +03:00
|
|
|
unsigned int sleep(unsigned int seconds);
|
2019-02-03 18:11:28 +03:00
|
|
|
int usleep(useconds_t);
|
2018-10-26 10:54:29 +03:00
|
|
|
int gethostname(char*, size_t);
|
2022-04-01 20:58:27 +03:00
|
|
|
int sethostname(char const*, ssize_t);
|
|
|
|
ssize_t readlink(char const* path, char* buffer, size_t);
|
2022-10-01 14:20:08 +03:00
|
|
|
ssize_t readlinkat(int dirfd, char const* path, char* buffer, size_t);
|
2018-10-31 00:03:02 +03:00
|
|
|
char* ttyname(int fd);
|
|
|
|
int ttyname_r(int fd, char* buffer, size_t);
|
2018-10-31 19:50:43 +03:00
|
|
|
off_t lseek(int fd, off_t, int whence);
|
2022-04-01 20:58:27 +03:00
|
|
|
int link(char const* oldpath, char const* newpath);
|
|
|
|
int unlink(char const* pathname);
|
2022-02-10 14:30:33 +03:00
|
|
|
int unlinkat(int dirfd, char const* pathname, int flags);
|
2022-04-01 20:58:27 +03:00
|
|
|
int symlink(char const* target, char const* linkpath);
|
2022-10-01 14:15:02 +03:00
|
|
|
int symlinkat(char const* target, int newdirfd, char const* linkpath);
|
2022-04-01 20:58:27 +03:00
|
|
|
int rmdir(char const* pathname);
|
2018-11-05 21:01:22 +03:00
|
|
|
int dup(int old_fd);
|
|
|
|
int dup2(int old_fd, int new_fd);
|
2018-11-11 02:20:53 +03:00
|
|
|
int pipe(int pipefd[2]);
|
2019-08-05 15:29:05 +03:00
|
|
|
int pipe2(int pipefd[2], int flags);
|
2018-11-11 02:20:53 +03:00
|
|
|
unsigned int alarm(unsigned int seconds);
|
2022-04-01 20:58:27 +03:00
|
|
|
int access(char const* pathname, int mode);
|
2022-10-01 15:24:56 +03:00
|
|
|
int faccessat(int dirfd, char const* pathname, int mode, int flags);
|
2018-11-11 12:11:09 +03:00
|
|
|
int isatty(int fd);
|
2022-04-01 20:58:27 +03:00
|
|
|
int mknod(char const* pathname, mode_t, dev_t);
|
2018-11-17 17:56:09 +03:00
|
|
|
long fpathconf(int fd, int name);
|
2022-04-01 20:58:27 +03:00
|
|
|
long pathconf(char const* path, int name);
|
2022-01-08 17:32:59 +03:00
|
|
|
char* getlogin(void);
|
2022-04-01 20:58:27 +03:00
|
|
|
int lchown(char const* pathname, uid_t uid, gid_t gid);
|
|
|
|
int chown(char const* pathname, uid_t, gid_t);
|
2019-06-01 21:31:36 +03:00
|
|
|
int fchown(int fd, uid_t, gid_t);
|
2022-04-01 20:58:27 +03:00
|
|
|
int fchownat(int fd, char const* pathname, uid_t uid, gid_t gid, int flags);
|
2019-03-24 02:53:39 +03:00
|
|
|
int ftruncate(int fd, off_t length);
|
2022-04-01 20:58:27 +03:00
|
|
|
int truncate(char const* path, off_t length);
|
2022-12-15 12:42:40 +03:00
|
|
|
int fsopen(char const* fs_type, int flags);
|
|
|
|
int fsmount(int mount_fd, int source_fd, char const* target);
|
|
|
|
int bindmount(int source_fd, char const* target, int flags);
|
2022-04-01 20:58:27 +03:00
|
|
|
int mount(int source_fd, char const* target, char const* fs_type, int flags);
|
|
|
|
int umount(char const* mountpoint);
|
|
|
|
int pledge(char const* promises, char const* execpromises);
|
|
|
|
int unveil(char const* path, char const* permissions);
|
|
|
|
char* getpass(char const* prompt);
|
2022-01-08 17:32:59 +03:00
|
|
|
int pause(void);
|
2022-04-01 20:58:27 +03:00
|
|
|
int chroot(char const*);
|
2022-03-29 23:47:06 +03:00
|
|
|
int getdtablesize(void);
|
2022-04-03 20:36:27 +03:00
|
|
|
int nice(int incr);
|
2022-06-29 06:00:28 +03:00
|
|
|
int brk(void* addr);
|
|
|
|
void* sbrk(intptr_t incr);
|
2018-11-17 17:56:09 +03:00
|
|
|
|
2019-06-07 18:13:23 +03:00
|
|
|
enum {
|
2018-11-17 17:56:09 +03:00
|
|
|
_PC_NAME_MAX,
|
2019-09-02 08:36:22 +03:00
|
|
|
_PC_PATH_MAX,
|
2019-12-01 13:34:34 +03:00
|
|
|
_PC_PIPE_BUF,
|
2021-07-23 09:34:22 +03:00
|
|
|
_PC_VDISABLE,
|
|
|
|
_PC_LINK_MAX
|
2018-11-17 17:56:09 +03:00
|
|
|
};
|
2018-10-26 10:54:29 +03:00
|
|
|
|
2022-04-29 21:49:18 +03:00
|
|
|
#define _POSIX_FSYNC 200112L
|
|
|
|
#define _POSIX_MAPPED_FILES 200112L
|
|
|
|
#define _POSIX_MEMORY_PROTECTION 200112L
|
2021-06-04 02:45:04 +03:00
|
|
|
#define _POSIX_MONOTONIC_CLOCK 200112L
|
2022-04-29 21:49:18 +03:00
|
|
|
#define _POSIX_RAW_SOCKETS 200112L
|
|
|
|
#define _POSIX_REGEXP 1
|
|
|
|
#define _POSIX_SAVED_IDS 1
|
|
|
|
#define _POSIX_SPAWN 200112L
|
|
|
|
#define _POSIX_THREADS 200112L
|
|
|
|
#define _POSIX_THREAD_ATTR_STACKADDR 200112L
|
|
|
|
#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
|
2021-06-04 02:45:04 +03:00
|
|
|
#define _POSIX_TIMERS 200809L
|
2020-06-17 15:58:00 +03:00
|
|
|
|
2019-05-30 00:20:51 +03:00
|
|
|
/*
|
|
|
|
* We aren't fully compliant (don't support policies, and don't have a wide
|
|
|
|
* range of values), but we do have process priorities.
|
|
|
|
*/
|
|
|
|
#define _POSIX_PRIORITY_SCHEDULING
|
2019-12-01 13:34:34 +03:00
|
|
|
#define _POSIX_VDISABLE '\0'
|
2019-05-30 00:20:51 +03:00
|
|
|
|
2020-07-14 23:41:59 +03:00
|
|
|
long sysconf(int name);
|
|
|
|
|
2018-10-31 04:09:11 +03:00
|
|
|
__END_DECLS
|