unistd.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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(const char* name, size_t name_length);
  27. void dump_backtrace();
  28. int fsync(int fd);
  29. int sysbeep();
  30. int gettid();
  31. int getpagesize();
  32. pid_t fork();
  33. pid_t vfork();
  34. int execv(const char* path, char* const argv[]);
  35. int execve(const char* filename, char* const argv[], char* const envp[]);
  36. int execvpe(const char* filename, char* const argv[], char* const envp[]);
  37. int execvp(const char* filename, char* const argv[]);
  38. int execl(const char* filename, const char* arg, ...);
  39. int execle(const char* filename, const char* arg, ...);
  40. int execlp(const char* filename, const char* arg, ...);
  41. void sync();
  42. __attribute__((noreturn)) void _exit(int status);
  43. pid_t getsid(pid_t);
  44. pid_t setsid();
  45. int setpgid(pid_t pid, pid_t pgid);
  46. pid_t getpgid(pid_t);
  47. pid_t getpgrp();
  48. uid_t geteuid();
  49. gid_t getegid();
  50. uid_t getuid();
  51. gid_t getgid();
  52. pid_t getpid();
  53. pid_t getppid();
  54. int getresuid(uid_t*, uid_t*, uid_t*);
  55. int getresgid(gid_t*, gid_t*, gid_t*);
  56. int getgroups(int size, gid_t list[]);
  57. int setgroups(size_t, const gid_t*);
  58. int seteuid(uid_t);
  59. int setegid(gid_t);
  60. int setuid(uid_t);
  61. int setgid(gid_t);
  62. int setreuid(uid_t, uid_t);
  63. int setresuid(uid_t, uid_t, uid_t);
  64. int setresgid(gid_t, gid_t, gid_t);
  65. pid_t tcgetpgrp(int fd);
  66. int tcsetpgrp(int fd, pid_t pgid);
  67. ssize_t read(int fd, void* buf, size_t count);
  68. ssize_t pread(int fd, void* buf, size_t count, off_t);
  69. ssize_t write(int fd, const void* buf, size_t count);
  70. ssize_t pwrite(int fd, const void* buf, size_t count, off_t);
  71. int close(int fd);
  72. int chdir(const char* path);
  73. int fchdir(int fd);
  74. char* getcwd(char* buffer, size_t size);
  75. char* getwd(char* buffer);
  76. unsigned int sleep(unsigned int seconds);
  77. int usleep(useconds_t);
  78. int gethostname(char*, size_t);
  79. int sethostname(const char*, ssize_t);
  80. ssize_t readlink(const char* path, char* buffer, size_t);
  81. char* ttyname(int fd);
  82. int ttyname_r(int fd, char* buffer, size_t);
  83. off_t lseek(int fd, off_t, int whence);
  84. int link(const char* oldpath, const char* newpath);
  85. int unlink(const char* pathname);
  86. int symlink(const char* target, const char* linkpath);
  87. int rmdir(const char* pathname);
  88. int dup(int old_fd);
  89. int dup2(int old_fd, int new_fd);
  90. int pipe(int pipefd[2]);
  91. int pipe2(int pipefd[2], int flags);
  92. unsigned int alarm(unsigned int seconds);
  93. int access(const char* pathname, int mode);
  94. int isatty(int fd);
  95. int mknod(const char* pathname, mode_t, dev_t);
  96. long fpathconf(int fd, int name);
  97. long pathconf(const char* path, int name);
  98. char* getlogin();
  99. int lchown(const char* pathname, uid_t uid, gid_t gid);
  100. int chown(const char* pathname, uid_t, gid_t);
  101. int fchown(int fd, uid_t, gid_t);
  102. int fchownat(int fd, const char* pathname, uid_t uid, gid_t gid, int flags);
  103. int ftruncate(int fd, off_t length);
  104. int truncate(const char* path, off_t length);
  105. int mount(int source_fd, const char* target, const char* fs_type, int flags);
  106. int umount(const char* mountpoint);
  107. int pledge(const char* promises, const char* execpromises);
  108. int unveil(const char* path, const char* permissions);
  109. char* getpass(const char* prompt);
  110. int pause();
  111. int chroot(const char*);
  112. enum {
  113. _PC_NAME_MAX,
  114. _PC_PATH_MAX,
  115. _PC_PIPE_BUF,
  116. _PC_VDISABLE,
  117. _PC_LINK_MAX
  118. };
  119. #define _POSIX_MONOTONIC_CLOCK 200112L
  120. #define _POSIX_SAVED_IDS
  121. #define _POSIX_TIMERS 200809L
  122. /*
  123. * We aren't fully compliant (don't support policies, and don't have a wide
  124. * range of values), but we do have process priorities.
  125. */
  126. #define _POSIX_PRIORITY_SCHEDULING
  127. #define _POSIX_VDISABLE '\0'
  128. long sysconf(int name);
  129. // If opterr is set (the default), print error messages to stderr.
  130. extern int opterr;
  131. // On errors, optopt is set to the erroneous *character*.
  132. extern int optopt;
  133. // Index of the next argument to process upon a getopt*() call.
  134. extern int optind;
  135. // If set, reset the internal state kept by getopt*(). You may also want to set
  136. // optind to 1 in that case. Alternatively, setting optind to 0 is treated like
  137. // doing both of the above.
  138. extern int optreset;
  139. // After parsing an option that accept an argument, set to point to the argument
  140. // value.
  141. extern char* optarg;
  142. int getopt(int argc, char* const* argv, const char* short_options);
  143. __END_DECLS