/* * Copyright (c) 2021, Andreas Kling * Copyright (c) 2021-2022, Kenneth Myhra * Copyright (c) 2021, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AK_OS_BSD_GENERIC # include #endif namespace Core::System { #ifdef __serenity__ ErrorOr beep(); ErrorOr pledge(StringView promises, StringView execpromises = {}); ErrorOr unveil(StringView path, StringView permissions); ErrorOr sendfd(int sockfd, int fd); ErrorOr recvfd(int sockfd, int options); ErrorOr ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf); ErrorOr setgroups(Span); ErrorOr mount(int source_fd, StringView target, StringView fs_type, int flags); ErrorOr umount(StringView mount_point); ErrorOr ptrace(int request, pid_t tid, void* address, void* data); ErrorOr disown(pid_t pid); ErrorOr profiling_enable(pid_t, u64 event_mask); ErrorOr profiling_disable(pid_t); ErrorOr profiling_free_buffer(pid_t); #endif #ifndef AK_OS_BSD_GENERIC ErrorOr> getspent(); ErrorOr> getspnam(StringView name); #endif #ifndef AK_OS_MACOS ErrorOr accept4(int sockfd, struct sockaddr*, socklen_t*, int flags); #endif ErrorOr sigaction(int signal, struct sigaction const* action, struct sigaction* old_action); #if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) ErrorOr signal(int signal, sig_t handler); #else ErrorOr signal(int signal, sighandler_t handler); #endif ErrorOr fstat(int fd); ErrorOr fcntl(int fd, int command, ...); ErrorOr mmap(void* address, size_t, int protection, int flags, int fd, off_t, size_t alignment = 0, StringView name = {}); ErrorOr munmap(void* address, size_t); ErrorOr anon_create(size_t size, int options); ErrorOr open(StringView path, int options, mode_t mode = 0); ErrorOr openat(int fd, StringView path, int options, mode_t mode = 0); ErrorOr close(int fd); ErrorOr ftruncate(int fd, off_t length); ErrorOr stat(StringView path); ErrorOr lstat(StringView path); ErrorOr read(int fd, Bytes buffer); ErrorOr write(int fd, ReadonlyBytes buffer); ErrorOr kill(pid_t, int signal); ErrorOr killpg(int pgrp, int signal); ErrorOr dup(int source_fd); ErrorOr dup2(int source_fd, int destination_fd); ErrorOr ptsname(int fd); ErrorOr gethostname(); ErrorOr sethostname(StringView); ErrorOr getcwd(); ErrorOr ioctl(int fd, unsigned request, ...); ErrorOr tcgetattr(int fd); ErrorOr tcsetattr(int fd, int optional_actions, struct termios const&); ErrorOr tcsetpgrp(int fd, pid_t pgrp); ErrorOr chmod(StringView pathname, mode_t mode); ErrorOr lchown(StringView pathname, uid_t uid, gid_t gid); ErrorOr chown(StringView pathname, uid_t uid, gid_t gid); ErrorOr> getpwnam(StringView name); ErrorOr> getgrnam(StringView name); ErrorOr> getpwuid(uid_t); ErrorOr> getgrgid(gid_t); ErrorOr clock_settime(clockid_t clock_id, struct timespec* ts); ErrorOr posix_spawn(StringView path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const arguments[], char* const envp[]); ErrorOr posix_spawnp(StringView path, posix_spawn_file_actions_t* const file_actions, posix_spawnattr_t* const attr, char* const arguments[], char* const envp[]); ErrorOr lseek(int fd, off_t, int whence); ErrorOr endgrent(); struct WaitPidResult { pid_t pid; int status; }; ErrorOr waitpid(pid_t waitee, int options = 0); ErrorOr setuid(uid_t); ErrorOr seteuid(uid_t); ErrorOr setgid(gid_t); ErrorOr setegid(gid_t); ErrorOr setpgid(pid_t pid, pid_t pgid); ErrorOr setsid(); ErrorOr drop_privileges(); ErrorOr isatty(int fd); ErrorOr symlink(StringView target, StringView link_path); ErrorOr mkdir(StringView path, mode_t); ErrorOr chdir(StringView path); ErrorOr rmdir(StringView path); ErrorOr fork(); ErrorOr mkstemp(Span pattern); ErrorOr fchmod(int fd, mode_t mode); ErrorOr fchown(int fd, uid_t, gid_t); ErrorOr rename(StringView old_path, StringView new_path); ErrorOr unlink(StringView path); ErrorOr utime(StringView path, Optional); ErrorOr uname(); ErrorOr> pipe2(int flags); ErrorOr adjtime(const struct timeval* delta, struct timeval* old_delta); enum class SearchInPath { No, Yes, }; ErrorOr exec(StringView filename, Span arguments, SearchInPath, Optional> environment = {}); ErrorOr socket(int domain, int type, int protocol); ErrorOr bind(int sockfd, struct sockaddr const*, socklen_t); ErrorOr listen(int sockfd, int backlog); ErrorOr accept(int sockfd, struct sockaddr*, socklen_t*); ErrorOr connect(int sockfd, struct sockaddr const*, socklen_t); ErrorOr shutdown(int sockfd, int how); ErrorOr send(int sockfd, void const*, size_t, int flags); ErrorOr sendmsg(int sockfd, const struct msghdr*, int flags); ErrorOr sendto(int sockfd, void const*, size_t, int flags, struct sockaddr const*, socklen_t); ErrorOr recv(int sockfd, void*, size_t, int flags); ErrorOr recvmsg(int sockfd, struct msghdr*, int flags); ErrorOr recvfrom(int sockfd, void*, size_t, int flags, struct sockaddr*, socklen_t*); ErrorOr getsockopt(int sockfd, int level, int option, void* value, socklen_t* value_size); ErrorOr setsockopt(int sockfd, int level, int option, void const* value, socklen_t value_size); ErrorOr getsockname(int sockfd, struct sockaddr*, socklen_t*); ErrorOr getpeername(int sockfd, struct sockaddr*, socklen_t*); ErrorOr socketpair(int domain, int type, int protocol, int sv[2]); ErrorOr> getgroups(); ErrorOr mknod(StringView pathname, mode_t mode, dev_t dev); ErrorOr mkfifo(StringView pathname, mode_t mode); ErrorOr setenv(StringView, StringView, bool); ErrorOr posix_openpt(int flags); ErrorOr grantpt(int fildes); ErrorOr unlockpt(int fildes); ErrorOr access(StringView pathname, int mode); }