| 
									
										
										
										
											2021-11-22 15:43:57 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2022-06-30 16:19:03 +02:00
										 |  |  |  * Copyright (c) 2021-2022, Kenneth Myhra <kennethmyhra@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-12-25 12:52:19 +00:00
										 |  |  |  * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-11-22 15:43:57 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/Error.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  | #include <AK/Noncopyable.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-15 20:51:55 -07:00
										 |  |  | #include <AK/OwnPtr.h>
 | 
					
						
							| 
									
										
										
										
											2022-01-14 10:20:29 +01:00
										 |  |  | #include <AK/StringView.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  | #include <AK/Vector.h>
 | 
					
						
							| 
									
										
										
										
											2022-04-10 18:25:22 +02:00
										 |  |  | #include <dirent.h>
 | 
					
						
							| 
									
										
										
										
											2021-12-25 12:52:19 +00:00
										 |  |  | #include <fcntl.h>
 | 
					
						
							| 
									
										
										
										
											2021-12-06 21:24:18 +01:00
										 |  |  | #include <grp.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  | #include <netdb.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-11 23:40:25 +01:00
										 |  |  | #include <poll.h>
 | 
					
						
							| 
									
										
										
										
											2021-11-29 22:03:19 +01:00
										 |  |  | #include <pwd.h>
 | 
					
						
							| 
									
										
										
										
											2021-11-22 16:11:03 +01:00
										 |  |  | #include <signal.h>
 | 
					
						
							| 
									
										
										
										
											2021-12-13 18:38:48 +01:00
										 |  |  | #include <spawn.h>
 | 
					
						
							| 
									
										
										
										
											2021-12-25 12:52:19 +00:00
										 |  |  | #include <sys/ioctl.h>
 | 
					
						
							|  |  |  | #include <sys/socket.h>
 | 
					
						
							| 
									
										
										
										
											2021-11-23 11:10:19 +01:00
										 |  |  | #include <sys/stat.h>
 | 
					
						
							| 
									
										
										
										
											2022-01-16 17:25:26 -07:00
										 |  |  | #include <sys/time.h>
 | 
					
						
							| 
									
										
										
										
											2022-01-03 19:56:28 -07:00
										 |  |  | #include <sys/utsname.h>
 | 
					
						
							| 
									
										
										
										
											2021-12-13 18:43:39 +01:00
										 |  |  | #include <sys/wait.h>
 | 
					
						
							| 
									
										
										
										
											2021-11-29 23:28:10 +01:00
										 |  |  | #include <termios.h>
 | 
					
						
							| 
									
										
										
										
											2021-11-27 22:01:40 +01:00
										 |  |  | #include <time.h>
 | 
					
						
							| 
									
										
										
										
											2021-12-21 01:27:51 +01:00
										 |  |  | #include <utime.h>
 | 
					
						
							| 
									
										
										
										
											2021-11-22 15:43:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-12 22:47:09 +02:00
										 |  |  | #ifdef AK_OS_SERENITY
 | 
					
						
							|  |  |  | #    include <Kernel/API/Jail.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-11 01:06:29 -06:00
										 |  |  | #if !defined(AK_OS_BSD_GENERIC) && !defined(AK_OS_ANDROID)
 | 
					
						
							| 
									
										
										
										
											2022-01-01 18:26:17 +01:00
										 |  |  | #    include <shadow.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-25 17:00:10 +02:00
										 |  |  | #ifdef AK_OS_FREEBSD
 | 
					
						
							|  |  |  | #    include <sys/ucred.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-25 18:53:46 +01:00
										 |  |  | #ifdef AK_OS_SOLARIS
 | 
					
						
							|  |  |  | #    include <sys/filio.h>
 | 
					
						
							| 
									
										
										
										
											2023-02-25 18:58:53 +01:00
										 |  |  | #    include <ucred.h>
 | 
					
						
							| 
									
										
										
										
											2023-02-25 18:53:46 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-23 10:59:50 +01:00
										 |  |  | namespace Core::System { | 
					
						
							| 
									
										
										
										
											2021-11-22 15:43:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-09 15:23:23 -06:00
										 |  |  | #ifdef AK_OS_SERENITY
 | 
					
						
							| 
									
										
										
										
											2023-03-01 22:05:04 +02:00
										 |  |  | ErrorOr<void> beep(Optional<size_t> tone); | 
					
						
							| 
									
										
										
										
											2021-11-27 14:23:58 -08:00
										 |  |  | ErrorOr<void> pledge(StringView promises, StringView execpromises = {}); | 
					
						
							| 
									
										
										
										
											2021-11-22 15:43:57 +01:00
										 |  |  | ErrorOr<void> unveil(StringView path, StringView permissions); | 
					
						
							| 
									
										
										
										
											2022-11-04 19:20:11 +02:00
										 |  |  | ErrorOr<void> unveil_after_exec(StringView path, StringView permissions); | 
					
						
							| 
									
										
										
										
											2021-11-28 09:12:29 +01:00
										 |  |  | ErrorOr<void> sendfd(int sockfd, int fd); | 
					
						
							|  |  |  | ErrorOr<int> recvfd(int sockfd, int options); | 
					
						
							| 
									
										
										
										
											2021-11-25 23:04:52 +01:00
										 |  |  | ErrorOr<void> ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf); | 
					
						
							| 
									
										
										
										
											2021-12-16 20:23:21 +01:00
										 |  |  | ErrorOr<void> mount(int source_fd, StringView target, StringView fs_type, int flags); | 
					
						
							| 
									
										
										
										
											2023-02-25 19:30:28 +02:00
										 |  |  | ErrorOr<void> bindmount(int source_fd, StringView target, int flags); | 
					
						
							| 
									
										
										
										
											2022-12-15 11:42:40 +02:00
										 |  |  | ErrorOr<int> fsopen(StringView fs_type, int flags); | 
					
						
							|  |  |  | ErrorOr<void> fsmount(int mount_fd, int source_fd, StringView target_path); | 
					
						
							| 
									
										
										
										
											2023-02-25 19:30:28 +02:00
										 |  |  | ErrorOr<void> remount(StringView target, int flags); | 
					
						
							| 
									
										
										
										
											2022-01-21 23:10:59 +01:00
										 |  |  | ErrorOr<void> umount(StringView mount_point); | 
					
						
							| 
									
										
										
										
											2021-12-25 11:04:40 +01:00
										 |  |  | ErrorOr<long> ptrace(int request, pid_t tid, void* address, void* data); | 
					
						
							| 
									
										
										
										
											2021-12-29 16:22:22 +01:00
										 |  |  | ErrorOr<void> disown(pid_t pid); | 
					
						
							| 
									
										
										
										
											2022-02-13 00:07:51 +02:00
										 |  |  | ErrorOr<void> profiling_enable(pid_t, u64 event_mask); | 
					
						
							| 
									
										
										
										
											2022-02-13 00:08:16 +02:00
										 |  |  | ErrorOr<void> profiling_disable(pid_t); | 
					
						
							| 
									
										
										
										
											2022-02-13 00:08:37 +02:00
										 |  |  | ErrorOr<void> profiling_free_buffer(pid_t); | 
					
						
							| 
									
										
										
										
											2022-07-04 10:03:31 -06:00
										 |  |  | #else
 | 
					
						
							|  |  |  | inline ErrorOr<void> unveil(StringView, StringView) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return {}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | inline ErrorOr<void> pledge(StringView, StringView = {}) { return {}; } | 
					
						
							| 
									
										
										
										
											2021-11-23 10:59:50 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-11 20:49:07 +00:00
										 |  |  | template<size_t N> | 
					
						
							|  |  |  | ALWAYS_INLINE ErrorOr<void> pledge(char const (&promises)[N]) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return pledge(StringView { promises, N - 1 }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<size_t NPromises, size_t NExecPromises> | 
					
						
							|  |  |  | ALWAYS_INLINE ErrorOr<void> pledge(char const (&promises)[NPromises], char const (&execpromises)[NExecPromises]) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return pledge(StringView { promises, NPromises - 1 }, StringView { execpromises, NExecPromises - 1 }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<size_t NPath, size_t NPermissions> | 
					
						
							|  |  |  | ALWAYS_INLINE ErrorOr<void> unveil(char const (&path)[NPath], char const (&permissions)[NPermissions]) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return unveil(StringView { path, NPath - 1 }, StringView { permissions, NPermissions - 1 }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-13 10:29:30 +03:30
										 |  |  | ALWAYS_INLINE ErrorOr<void> unveil(nullptr_t, nullptr_t) | 
					
						
							| 
									
										
										
										
											2022-07-11 20:49:07 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return unveil(StringView {}, StringView {}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-11 01:06:29 -06:00
										 |  |  | #if !defined(AK_OS_BSD_GENERIC) && !defined(AK_OS_ANDROID)
 | 
					
						
							| 
									
										
										
										
											2022-01-01 18:26:17 +01:00
										 |  |  | ErrorOr<Optional<struct spwd>> getspent(); | 
					
						
							|  |  |  | ErrorOr<Optional<struct spwd>> getspnam(StringView name); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-27 21:11:12 +02:00
										 |  |  | #if !defined(AK_OS_MACOS) && !defined(AK_OS_HAIKU)
 | 
					
						
							| 
									
										
										
										
											2021-12-25 12:52:19 +00:00
										 |  |  | ErrorOr<int> accept4(int sockfd, struct sockaddr*, socklen_t*, int flags); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 16:11:03 +01:00
										 |  |  | ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action); | 
					
						
							| 
									
										
										
										
											2023-02-25 18:50:03 +01:00
										 |  |  | #if defined(AK_OS_SOLARIS)
 | 
					
						
							|  |  |  | ErrorOr<SIG_TYP> signal(int signal, SIG_TYP handler); | 
					
						
							|  |  |  | #elif defined(AK_OS_BSD_GENERIC)
 | 
					
						
							| 
									
										
										
										
											2021-11-23 21:03:53 +01:00
										 |  |  | ErrorOr<sig_t> signal(int signal, sig_t handler); | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | ErrorOr<sighandler_t> signal(int signal, sighandler_t handler); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2021-11-23 11:10:19 +01:00
										 |  |  | ErrorOr<struct stat> fstat(int fd); | 
					
						
							| 
									
										
										
										
											2023-03-17 15:23:24 +00:00
										 |  |  | ErrorOr<struct stat> fstatat(int fd, StringView path, int flags); | 
					
						
							| 
									
										
										
										
											2021-11-23 11:10:19 +01:00
										 |  |  | ErrorOr<int> fcntl(int fd, int command, ...); | 
					
						
							| 
									
										
										
										
											2021-11-23 11:47:32 +01:00
										 |  |  | ErrorOr<void*> mmap(void* address, size_t, int protection, int flags, int fd, off_t, size_t alignment = 0, StringView name = {}); | 
					
						
							| 
									
										
										
										
											2021-11-23 11:51:11 +01:00
										 |  |  | ErrorOr<void> munmap(void* address, size_t); | 
					
						
							| 
									
										
										
										
											2022-01-23 23:03:09 +01:00
										 |  |  | ErrorOr<int> anon_create(size_t size, int options); | 
					
						
							| 
									
										
										
										
											2022-04-10 18:25:22 +02:00
										 |  |  | ErrorOr<int> open(StringView path, int options, mode_t mode = 0); | 
					
						
							|  |  |  | ErrorOr<int> openat(int fd, StringView path, int options, mode_t mode = 0); | 
					
						
							| 
									
										
										
										
											2021-11-23 12:05:56 +01:00
										 |  |  | ErrorOr<void> close(int fd); | 
					
						
							| 
									
										
										
										
											2021-11-23 12:16:07 +01:00
										 |  |  | ErrorOr<void> ftruncate(int fd, off_t length); | 
					
						
							| 
									
										
										
										
											2021-11-23 12:22:21 +01:00
										 |  |  | ErrorOr<struct stat> stat(StringView path); | 
					
						
							| 
									
										
										
										
											2021-12-02 22:41:40 +01:00
										 |  |  | ErrorOr<struct stat> lstat(StringView path); | 
					
						
							| 
									
										
										
										
											2021-11-27 13:02:33 -08:00
										 |  |  | ErrorOr<ssize_t> read(int fd, Bytes buffer); | 
					
						
							|  |  |  | ErrorOr<ssize_t> write(int fd, ReadonlyBytes buffer); | 
					
						
							| 
									
										
										
										
											2021-11-23 16:06:56 +01:00
										 |  |  | ErrorOr<void> kill(pid_t, int signal); | 
					
						
							| 
									
										
										
										
											2022-03-01 20:04:41 +01:00
										 |  |  | ErrorOr<void> killpg(int pgrp, int signal); | 
					
						
							| 
									
										
										
										
											2021-11-28 12:08:28 +01:00
										 |  |  | ErrorOr<int> dup(int source_fd); | 
					
						
							| 
									
										
										
										
											2021-11-24 22:36:28 +01:00
										 |  |  | ErrorOr<int> dup2(int source_fd, int destination_fd); | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  | ErrorOr<DeprecatedString> ptsname(int fd); | 
					
						
							|  |  |  | ErrorOr<DeprecatedString> gethostname(); | 
					
						
							| 
									
										
										
										
											2022-01-14 10:20:29 +01:00
										 |  |  | ErrorOr<void> sethostname(StringView); | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  | ErrorOr<DeprecatedString> getcwd(); | 
					
						
							| 
									
										
										
										
											2021-11-29 23:07:33 +01:00
										 |  |  | ErrorOr<void> ioctl(int fd, unsigned request, ...); | 
					
						
							| 
									
										
										
										
											2021-11-29 23:28:10 +01:00
										 |  |  | ErrorOr<struct termios> tcgetattr(int fd); | 
					
						
							|  |  |  | ErrorOr<void> tcsetattr(int fd, int optional_actions, struct termios const&); | 
					
						
							| 
									
										
										
										
											2022-03-01 20:05:14 +01:00
										 |  |  | ErrorOr<int> tcsetpgrp(int fd, pid_t pgrp); | 
					
						
							| 
									
										
										
										
											2021-11-27 15:46:11 +01:00
										 |  |  | ErrorOr<void> chmod(StringView pathname, mode_t mode); | 
					
						
							| 
									
										
										
										
											2021-12-31 19:20:17 +01:00
										 |  |  | ErrorOr<void> lchown(StringView pathname, uid_t uid, gid_t gid); | 
					
						
							| 
									
										
										
										
											2021-11-27 15:23:16 +01:00
										 |  |  | ErrorOr<void> chown(StringView pathname, uid_t uid, gid_t gid); | 
					
						
							| 
									
										
										
										
											2022-12-13 14:49:32 -05:00
										 |  |  | ErrorOr<Optional<struct passwd>> getpwent(Span<char> buffer); | 
					
						
							| 
									
										
										
										
											2021-12-23 09:41:00 +01:00
										 |  |  | ErrorOr<Optional<struct passwd>> getpwnam(StringView name); | 
					
						
							|  |  |  | ErrorOr<Optional<struct group>> getgrnam(StringView name); | 
					
						
							| 
									
										
										
										
											2022-01-01 17:53:57 +01:00
										 |  |  | ErrorOr<Optional<struct passwd>> getpwuid(uid_t); | 
					
						
							| 
									
										
										
										
											2022-12-13 15:08:58 -05:00
										 |  |  | ErrorOr<Optional<struct group>> getgrent(Span<char> buffer); | 
					
						
							| 
									
										
										
										
											2022-01-01 17:53:57 +01:00
										 |  |  | ErrorOr<Optional<struct group>> getgrgid(gid_t); | 
					
						
							| 
									
										
										
										
											2021-11-27 22:01:40 +01:00
										 |  |  | ErrorOr<void> clock_settime(clockid_t clock_id, struct timespec* ts); | 
					
						
							| 
									
										
										
										
											2022-05-11 20:24:39 +01:00
										 |  |  | ErrorOr<pid_t> posix_spawn(StringView path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const arguments[], char* const envp[]); | 
					
						
							|  |  |  | ErrorOr<pid_t> posix_spawnp(StringView path, posix_spawn_file_actions_t* const file_actions, posix_spawnattr_t* const attr, char* const arguments[], char* const envp[]); | 
					
						
							| 
									
										
										
										
											2022-01-18 14:42:45 +00:00
										 |  |  | ErrorOr<off_t> lseek(int fd, off_t, int whence); | 
					
						
							| 
									
										
										
										
											2022-06-08 14:39:59 +02:00
										 |  |  | ErrorOr<void> endgrent(); | 
					
						
							| 
									
										
										
										
											2022-01-10 14:34:09 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct WaitPidResult { | 
					
						
							|  |  |  |     pid_t pid; | 
					
						
							|  |  |  |     int status; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | ErrorOr<WaitPidResult> waitpid(pid_t waitee, int options = 0); | 
					
						
							| 
									
										
										
										
											2021-12-16 19:17:44 +01:00
										 |  |  | ErrorOr<void> setuid(uid_t); | 
					
						
							|  |  |  | ErrorOr<void> seteuid(uid_t); | 
					
						
							|  |  |  | ErrorOr<void> setgid(gid_t); | 
					
						
							|  |  |  | ErrorOr<void> setegid(gid_t); | 
					
						
							| 
									
										
										
										
											2021-12-21 06:17:50 +03:30
										 |  |  | ErrorOr<void> setpgid(pid_t pid, pid_t pgid); | 
					
						
							| 
									
										
										
										
											2022-01-03 01:58:58 +01:00
										 |  |  | ErrorOr<pid_t> setsid(); | 
					
						
							| 
									
										
										
										
											2022-09-05 22:12:58 -06:00
										 |  |  | ErrorOr<pid_t> getsid(pid_t pid = 0); | 
					
						
							| 
									
										
										
										
											2022-03-21 00:05:42 -07:00
										 |  |  | ErrorOr<void> drop_privileges(); | 
					
						
							| 
									
										
										
										
											2021-12-16 19:24:58 +01:00
										 |  |  | ErrorOr<bool> isatty(int fd); | 
					
						
							| 
									
										
										
										
											2022-07-25 16:03:51 +02:00
										 |  |  | ErrorOr<void> link(StringView old_path, StringView new_path); | 
					
						
							| 
									
										
										
										
											2021-12-16 20:23:21 +01:00
										 |  |  | ErrorOr<void> symlink(StringView target, StringView link_path); | 
					
						
							| 
									
										
										
										
											2021-12-16 20:27:25 +01:00
										 |  |  | ErrorOr<void> mkdir(StringView path, mode_t); | 
					
						
							| 
									
										
										
										
											2022-01-03 02:07:26 -07:00
										 |  |  | ErrorOr<void> chdir(StringView path); | 
					
						
							| 
									
										
										
										
											2022-02-12 18:35:38 -07:00
										 |  |  | ErrorOr<void> rmdir(StringView path); | 
					
						
							| 
									
										
										
										
											2021-12-16 20:28:54 +01:00
										 |  |  | ErrorOr<pid_t> fork(); | 
					
						
							| 
									
										
										
										
											2021-12-16 21:10:59 +01:00
										 |  |  | ErrorOr<int> mkstemp(Span<char> pattern); | 
					
						
							| 
									
										
										
										
											2023-03-17 23:54:19 +00:00
										 |  |  | ErrorOr<String> mkdtemp(Span<char> pattern); | 
					
						
							| 
									
										
										
										
											2021-12-16 21:12:23 +01:00
										 |  |  | ErrorOr<void> fchmod(int fd, mode_t mode); | 
					
						
							| 
									
										
										
										
											2022-02-06 17:54:15 +00:00
										 |  |  | ErrorOr<void> fchown(int fd, uid_t, gid_t); | 
					
						
							| 
									
										
										
										
											2021-12-16 21:40:42 +01:00
										 |  |  | ErrorOr<void> rename(StringView old_path, StringView new_path); | 
					
						
							| 
									
										
										
										
											2021-12-29 21:47:38 +01:00
										 |  |  | ErrorOr<void> unlink(StringView path); | 
					
						
							| 
									
										
										
										
											2021-12-20 19:48:30 +01:00
										 |  |  | ErrorOr<void> utime(StringView path, Optional<struct utimbuf>); | 
					
						
							| 
									
										
										
										
											2023-03-20 18:16:44 +11:00
										 |  |  | ErrorOr<void> utimensat(int fd, StringView path, struct timespec const times[2], int flag); | 
					
						
							| 
									
										
										
										
											2022-01-03 19:56:28 -07:00
										 |  |  | ErrorOr<struct utsname> uname(); | 
					
						
							| 
									
										
										
										
											2021-12-21 06:16:46 +03:30
										 |  |  | ErrorOr<Array<int, 2>> pipe2(int flags); | 
					
						
							| 
									
										
										
										
											2023-08-27 21:37:02 +02:00
										 |  |  | #if !defined(AK_OS_ANDROID) && !defined(AK_OS_HAIKU)
 | 
					
						
							| 
									
										
										
										
											2022-01-16 17:25:26 -07:00
										 |  |  | ErrorOr<void> adjtime(const struct timeval* delta, struct timeval* old_delta); | 
					
						
							| 
									
										
										
										
											2022-07-11 01:06:29 -06:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2022-03-12 20:23:43 +00:00
										 |  |  | enum class SearchInPath { | 
					
						
							|  |  |  |     No, | 
					
						
							|  |  |  |     Yes, | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2022-11-04 11:50:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef AK_OS_SERENITY
 | 
					
						
							|  |  |  | ErrorOr<void> exec_command(Vector<StringView>& command, bool preserve_env); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-05 19:02:54 +00:00
										 |  |  | ErrorOr<void> exec(StringView filename, ReadonlySpan<StringView> arguments, SearchInPath, Optional<ReadonlySpan<StringView>> environment = {}); | 
					
						
							| 
									
										
										
										
											2021-11-22 15:43:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-02 22:28:58 +02:00
										 |  |  | #ifdef AK_OS_SERENITY
 | 
					
						
							|  |  |  | ErrorOr<void> join_jail(u64 jail_index); | 
					
						
							| 
									
										
										
										
											2023-01-12 22:47:09 +02:00
										 |  |  | ErrorOr<u64> create_jail(StringView jail_name, JailIsolationFlags); | 
					
						
							| 
									
										
										
										
											2022-11-02 22:28:58 +02:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-25 12:52:19 +00:00
										 |  |  | ErrorOr<int> socket(int domain, int type, int protocol); | 
					
						
							|  |  |  | ErrorOr<void> bind(int sockfd, struct sockaddr const*, socklen_t); | 
					
						
							|  |  |  | ErrorOr<void> listen(int sockfd, int backlog); | 
					
						
							|  |  |  | ErrorOr<int> accept(int sockfd, struct sockaddr*, socklen_t*); | 
					
						
							|  |  |  | ErrorOr<void> connect(int sockfd, struct sockaddr const*, socklen_t); | 
					
						
							|  |  |  | ErrorOr<void> shutdown(int sockfd, int how); | 
					
						
							|  |  |  | ErrorOr<ssize_t> send(int sockfd, void const*, size_t, int flags); | 
					
						
							|  |  |  | ErrorOr<ssize_t> sendmsg(int sockfd, const struct msghdr*, int flags); | 
					
						
							|  |  |  | ErrorOr<ssize_t> sendto(int sockfd, void const*, size_t, int flags, struct sockaddr const*, socklen_t); | 
					
						
							|  |  |  | ErrorOr<ssize_t> recv(int sockfd, void*, size_t, int flags); | 
					
						
							|  |  |  | ErrorOr<ssize_t> recvmsg(int sockfd, struct msghdr*, int flags); | 
					
						
							|  |  |  | ErrorOr<ssize_t> recvfrom(int sockfd, void*, size_t, int flags, struct sockaddr*, socklen_t*); | 
					
						
							|  |  |  | ErrorOr<void> getsockopt(int sockfd, int level, int option, void* value, socklen_t* value_size); | 
					
						
							|  |  |  | ErrorOr<void> setsockopt(int sockfd, int level, int option, void const* value, socklen_t value_size); | 
					
						
							|  |  |  | ErrorOr<void> getsockname(int sockfd, struct sockaddr*, socklen_t*); | 
					
						
							|  |  |  | ErrorOr<void> getpeername(int sockfd, struct sockaddr*, socklen_t*); | 
					
						
							|  |  |  | ErrorOr<void> socketpair(int domain, int type, int protocol, int sv[2]); | 
					
						
							| 
									
										
										
										
											2022-01-01 16:19:51 +01:00
										 |  |  | ErrorOr<Vector<gid_t>> getgroups(); | 
					
						
							| 
									
										
										
										
											2023-02-05 19:02:54 +00:00
										 |  |  | ErrorOr<void> setgroups(ReadonlySpan<gid_t>); | 
					
						
							| 
									
										
										
										
											2022-01-14 17:08:46 +01:00
										 |  |  | ErrorOr<void> mknod(StringView pathname, mode_t mode, dev_t dev); | 
					
						
							| 
									
										
										
										
											2022-01-17 10:04:00 +01:00
										 |  |  | ErrorOr<void> mkfifo(StringView pathname, mode_t mode); | 
					
						
							| 
									
										
										
										
											2022-03-01 23:43:55 +01:00
										 |  |  | ErrorOr<void> setenv(StringView, StringView, bool); | 
					
						
							| 
									
										
										
										
											2023-02-04 15:44:33 +00:00
										 |  |  | ErrorOr<void> putenv(StringView); | 
					
						
							| 
									
										
										
										
											2022-03-01 23:44:53 +01:00
										 |  |  | ErrorOr<int> posix_openpt(int flags); | 
					
						
							|  |  |  | ErrorOr<void> grantpt(int fildes); | 
					
						
							|  |  |  | ErrorOr<void> unlockpt(int fildes); | 
					
						
							| 
									
										
										
										
											2023-05-09 09:35:45 +02:00
										 |  |  | ErrorOr<void> access(StringView pathname, int mode, int flags = 0); | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  | ErrorOr<DeprecatedString> readlink(StringView pathname); | 
					
						
							| 
									
										
										
										
											2022-12-11 23:40:25 +01:00
										 |  |  | ErrorOr<int> poll(Span<struct pollfd>, int timeout); | 
					
						
							| 
									
										
										
										
											2022-03-01 23:43:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-25 13:07:58 +03:00
										 |  |  | #ifdef AK_OS_SERENITY
 | 
					
						
							|  |  |  | ErrorOr<void> create_block_device(StringView name, mode_t mode, unsigned major, unsigned minor); | 
					
						
							|  |  |  | ErrorOr<void> create_char_device(StringView name, mode_t mode, unsigned major, unsigned minor); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  | class AddressInfoVector { | 
					
						
							|  |  |  |     AK_MAKE_NONCOPYABLE(AddressInfoVector); | 
					
						
							| 
									
										
										
										
											2023-06-16 16:15:15 +02:00
										 |  |  |     AK_MAKE_DEFAULT_MOVABLE(AddressInfoVector); | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     ~AddressInfoVector() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-05 19:02:54 +00:00
										 |  |  |     ReadonlySpan<struct addrinfo> addresses() const { return m_addresses; } | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     friend ErrorOr<AddressInfoVector> getaddrinfo(char const* nodename, char const* servname, struct addrinfo const& hints); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-15 20:51:55 -07:00
										 |  |  |     AddressInfoVector(Vector<struct addrinfo>&& addresses, struct addrinfo* ptr) | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  |         : m_addresses(move(addresses)) | 
					
						
							| 
									
										
										
										
											2022-12-15 20:51:55 -07:00
										 |  |  |         , m_ptr(adopt_own_if_nonnull(ptr)) | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-15 20:51:55 -07:00
										 |  |  |     struct AddrInfoDeleter { | 
					
						
							|  |  |  |         void operator()(struct addrinfo* ptr) { ::freeaddrinfo(ptr); } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  |     Vector<struct addrinfo> m_addresses {}; | 
					
						
							| 
									
										
										
										
											2022-12-15 20:51:55 -07:00
										 |  |  |     OwnPtr<struct addrinfo, AddrInfoDeleter> m_ptr {}; | 
					
						
							| 
									
										
										
										
											2022-12-08 00:47:25 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ErrorOr<AddressInfoVector> getaddrinfo(char const* nodename, char const* servname, struct addrinfo const& hints); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-27 19:46:03 +01:00
										 |  |  | #ifdef AK_OS_SERENITY
 | 
					
						
							|  |  |  | ErrorOr<void> posix_fallocate(int fd, off_t offset, off_t length); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-29 22:15:13 +02:00
										 |  |  | ErrorOr<String> resolve_executable_from_environment(StringView filename, int flags = 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-17 16:41:43 +12:00
										 |  |  | char** environment(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-02 16:56:53 -06:00
										 |  |  | ErrorOr<String> current_executable_path(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 15:43:57 +01:00
										 |  |  | } |