unistd.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. /* standard symbolic constants and types
  7. *
  8. * values from POSIX standard unix specification
  9. *
  10. * https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html
  11. */
  12. #pragma once
  13. #include <Kernel/API/POSIX/unistd.h>
  14. #include <fd_set.h>
  15. #include <limits.h>
  16. __BEGIN_DECLS
  17. #define HZ 1000
  18. /* lseek whence values */
  19. #ifndef _STDIO_H /* also defined in stdio.h */
  20. # define SEEK_SET 0 /* from beginning of file. */
  21. # define SEEK_CUR 1 /* from current position in file. */
  22. # define SEEK_END 2 /* from the end of the file. */
  23. #endif
  24. extern char** environ;
  25. int get_process_name(char* buffer, int buffer_size);
  26. int set_process_name(char const* name, size_t name_length);
  27. void dump_backtrace(void);
  28. int fsync(int fd);
  29. int sysbeep(void);
  30. int gettid(void);
  31. int getpagesize(void);
  32. pid_t fork(void);
  33. pid_t vfork(void);
  34. int daemon(int nochdir, int noclose);
  35. int execv(char const* path, char* const argv[]);
  36. int execve(char const* filename, char* const argv[], char* const envp[]);
  37. int execvpe(char const* filename, char* const argv[], char* const envp[]);
  38. int execvp(char const* filename, char* const argv[]);
  39. int execl(char const* filename, char const* arg, ...);
  40. int execle(char const* filename, char const* arg, ...);
  41. int execlp(char const* filename, char const* arg, ...);
  42. void sync(void);
  43. __attribute__((noreturn)) void _exit(int status);
  44. pid_t getsid(pid_t);
  45. pid_t setsid(void);
  46. int setpgid(pid_t pid, pid_t pgid);
  47. pid_t getpgid(pid_t);
  48. pid_t getpgrp(void);
  49. uid_t geteuid(void);
  50. gid_t getegid(void);
  51. uid_t getuid(void);
  52. gid_t getgid(void);
  53. pid_t getpid(void);
  54. pid_t getppid(void);
  55. int getresuid(uid_t*, uid_t*, uid_t*);
  56. int getresgid(gid_t*, gid_t*, gid_t*);
  57. int getgroups(int size, gid_t list[]);
  58. int setgroups(size_t, gid_t const*);
  59. int seteuid(uid_t);
  60. int setegid(gid_t);
  61. int setuid(uid_t);
  62. int setgid(gid_t);
  63. int setreuid(uid_t, uid_t);
  64. int setresuid(uid_t, uid_t, uid_t);
  65. int setresgid(gid_t, gid_t, gid_t);
  66. pid_t tcgetpgrp(int fd);
  67. int tcsetpgrp(int fd, pid_t pgid);
  68. ssize_t read(int fd, void* buf, size_t count);
  69. ssize_t pread(int fd, void* buf, size_t count, off_t);
  70. ssize_t write(int fd, void const* buf, size_t count);
  71. ssize_t pwrite(int fd, void const* buf, size_t count, off_t);
  72. int close(int fd);
  73. int chdir(char const* path);
  74. int fchdir(int fd);
  75. char* getcwd(char* buffer, size_t size);
  76. char* getwd(char* buffer);
  77. unsigned int sleep(unsigned int seconds);
  78. int usleep(useconds_t);
  79. int gethostname(char*, size_t);
  80. int sethostname(char const*, ssize_t);
  81. ssize_t readlink(char const* path, char* buffer, size_t);
  82. char* ttyname(int fd);
  83. int ttyname_r(int fd, char* buffer, size_t);
  84. off_t lseek(int fd, off_t, int whence);
  85. int link(char const* oldpath, char const* newpath);
  86. int unlink(char const* pathname);
  87. int symlink(char const* target, char const* linkpath);
  88. int rmdir(char const* pathname);
  89. int dup(int old_fd);
  90. int dup2(int old_fd, int new_fd);
  91. int pipe(int pipefd[2]);
  92. int pipe2(int pipefd[2], int flags);
  93. unsigned int alarm(unsigned int seconds);
  94. int access(char const* pathname, int mode);
  95. int isatty(int fd);
  96. int mknod(char const* pathname, mode_t, dev_t);
  97. long fpathconf(int fd, int name);
  98. long pathconf(char const* path, int name);
  99. char* getlogin(void);
  100. int lchown(char const* pathname, uid_t uid, gid_t gid);
  101. int chown(char const* pathname, uid_t, gid_t);
  102. int fchown(int fd, uid_t, gid_t);
  103. int fchownat(int fd, char const* pathname, uid_t uid, gid_t gid, int flags);
  104. int ftruncate(int fd, off_t length);
  105. int truncate(char const* path, off_t length);
  106. int mount(int source_fd, char const* target, char const* fs_type, int flags);
  107. int umount(char const* mountpoint);
  108. int pledge(char const* promises, char const* execpromises);
  109. int unveil(char const* path, char const* permissions);
  110. char* getpass(char const* prompt);
  111. int pause(void);
  112. int chroot(char const*);
  113. int getdtablesize(void);
  114. enum {
  115. _PC_NAME_MAX,
  116. _PC_PATH_MAX,
  117. _PC_PIPE_BUF,
  118. _PC_VDISABLE,
  119. _PC_LINK_MAX
  120. };
  121. #define _POSIX_MONOTONIC_CLOCK 200112L
  122. #define _POSIX_SAVED_IDS
  123. #define _POSIX_TIMERS 200809L
  124. /*
  125. * We aren't fully compliant (don't support policies, and don't have a wide
  126. * range of values), but we do have process priorities.
  127. */
  128. #define _POSIX_PRIORITY_SCHEDULING
  129. #define _POSIX_VDISABLE '\0'
  130. long sysconf(int name);
  131. // If opterr is set (the default), print error messages to stderr.
  132. extern int opterr;
  133. // On errors, optopt is set to the erroneous *character*.
  134. extern int optopt;
  135. // Index of the next argument to process upon a getopt*() call.
  136. extern int optind;
  137. // If set, reset the internal state kept by getopt*(). You may also want to set
  138. // optind to 1 in that case. Alternatively, setting optind to 0 is treated like
  139. // doing both of the above.
  140. extern int optreset;
  141. // After parsing an option that accept an argument, set to point to the argument
  142. // value.
  143. extern char* optarg;
  144. int getopt(int argc, char* const* argv, char const* short_options);
  145. __END_DECLS