summaryrefslogtreecommitdiff
path: root/lib/mlibc/options/linux/include
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:00 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 17:28:32 -0500
commitbd5969fc876a10b18613302db7087ef3c40f18e1 (patch)
tree7c2b8619afe902abf99570df2873fbdf40a4d1a1 /lib/mlibc/options/linux/include
parenta95b38b1b92b172e6cc4e8e56a88a30cc65907b0 (diff)
lib: Add mlibc
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/options/linux/include')
-rw-r--r--lib/mlibc/options/linux/include/bits/linux/cpu_set.h49
-rw-r--r--lib/mlibc/options/linux/include/bits/linux/linux_sched.h59
-rw-r--r--lib/mlibc/options/linux/include/bits/linux/linux_unistd.h21
-rw-r--r--lib/mlibc/options/linux/include/ifaddrs.h35
-rw-r--r--lib/mlibc/options/linux/include/lastlog.h2
-rw-r--r--lib/mlibc/options/linux/include/linux/libc-compat.h61
-rw-r--r--lib/mlibc/options/linux/include/malloc.h32
-rw-r--r--lib/mlibc/options/linux/include/memory.h9
-rw-r--r--lib/mlibc/options/linux/include/mlibc/linux-sysdeps.hpp82
-rw-r--r--lib/mlibc/options/linux/include/mntent.h50
-rw-r--r--lib/mlibc/options/linux/include/module.h25
-rw-r--r--lib/mlibc/options/linux/include/netpacket/packet.h40
-rw-r--r--lib/mlibc/options/linux/include/pty.h23
-rw-r--r--lib/mlibc/options/linux/include/scsi/scsi.h18
-rw-r--r--lib/mlibc/options/linux/include/scsi/scsi_ioctl.h6
-rw-r--r--lib/mlibc/options/linux/include/scsi/sg.h77
-rw-r--r--lib/mlibc/options/linux/include/sys/epoll.h66
-rw-r--r--lib/mlibc/options/linux/include/sys/eventfd.h29
-rw-r--r--lib/mlibc/options/linux/include/sys/fsuid.h22
-rw-r--r--lib/mlibc/options/linux/include/sys/inotify.h63
-rw-r--r--lib/mlibc/options/linux/include/sys/klog.h18
-rw-r--r--lib/mlibc/options/linux/include/sys/mount.h90
-rw-r--r--lib/mlibc/options/linux/include/sys/prctl.h128
-rw-r--r--lib/mlibc/options/linux/include/sys/ptrace.h55
-rw-r--r--lib/mlibc/options/linux/include/sys/quota.h24
-rw-r--r--lib/mlibc/options/linux/include/sys/random.h26
-rw-r--r--lib/mlibc/options/linux/include/sys/reboot.h20
-rw-r--r--lib/mlibc/options/linux/include/sys/sendfile.h22
-rw-r--r--lib/mlibc/options/linux/include/sys/signalfd.h48
-rw-r--r--lib/mlibc/options/linux/include/sys/statfs.h22
-rw-r--r--lib/mlibc/options/linux/include/sys/swap.h24
-rw-r--r--lib/mlibc/options/linux/include/sys/sysinfo.h34
-rw-r--r--lib/mlibc/options/linux/include/sys/sysmacros.h35
-rw-r--r--lib/mlibc/options/linux/include/sys/timerfd.h32
-rw-r--r--lib/mlibc/options/linux/include/sys/vfs.h16
-rw-r--r--lib/mlibc/options/linux/include/sys/vt.h6
-rw-r--r--lib/mlibc/options/linux/include/sys/xattr.h38
-rw-r--r--lib/mlibc/options/linux/include/utmp.h84
-rw-r--r--lib/mlibc/options/linux/include/utmpx.h68
-rw-r--r--lib/mlibc/options/linux/include/values.h39
40 files changed, 1598 insertions, 0 deletions
diff --git a/lib/mlibc/options/linux/include/bits/linux/cpu_set.h b/lib/mlibc/options/linux/include/bits/linux/cpu_set.h
new file mode 100644
index 0000000..f3c753e
--- /dev/null
+++ b/lib/mlibc/options/linux/include/bits/linux/cpu_set.h
@@ -0,0 +1,49 @@
+#ifndef _LINUX_CPU_SET_H
+#define _LINUX_CPU_SET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bits/cpu_set.h>
+#include <bits/size_t.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#ifndef __MLIBC_ABI_ONLY
+
+cpu_set_t *__mlibc_cpu_alloc(int num_cpus);
+size_t __mlibc_cpu_alloc_size(int num_cpus);
+
+void __mlibc_cpu_zero(const size_t setsize, cpu_set_t *set);
+void __mlibc_cpu_set(const int cpu, const size_t setsize, cpu_set_t *set);
+void __mlibc_cpu_clear(const int cpu, const size_t setsize, cpu_set_t *set);
+int __mlibc_cpu_isset(const int cpu, const size_t setsize, const cpu_set_t *set);
+int __mlibc_cpu_count(const size_t setsize, const cpu_set_t *set);
+
+#define CPU_ALLOC_SIZE(n) __mlibc_cpu_alloc_size((n))
+#define CPU_ALLOC(n) __mlibc_cpu_alloc((n))
+#define CPU_FREE(set) free((set))
+
+#define CPU_ZERO_S(setsize, set) __mlibc_cpu_zero((setsize), (set))
+#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t), set)
+
+#define CPU_SET_S(cpu, setsize, set) __mlibc_cpu_set((cpu), (setsize), (set))
+#define CPU_SET(cpu, set) CPU_SET_S(cpu, sizeof(cpu_set_t), set)
+
+#define CPU_CLR_S(cpu, setsize, set) __mlibc_cpu_clear((cpu), (setsize), (set))
+#define CPU_CLR(cpu, set) CPU_CLR_S(cpu, sizeof(cpu_set_t), set)
+
+#define CPU_ISSET_S(cpu, setsize, set) __mlibc_cpu_isset((cpu), (setsize), (set))
+#define CPU_ISSET(cpu, set) CPU_ISSET_S(cpu, sizeof(cpu_set_t), set)
+
+#define CPU_COUNT_S(setsize, set) __mlibc_cpu_count((setsize), (set))
+#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t), set)
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LINUX_CPU_SET_H */
diff --git a/lib/mlibc/options/linux/include/bits/linux/linux_sched.h b/lib/mlibc/options/linux/include/bits/linux/linux_sched.h
new file mode 100644
index 0000000..6a1209a
--- /dev/null
+++ b/lib/mlibc/options/linux/include/bits/linux/linux_sched.h
@@ -0,0 +1,59 @@
+
+#ifndef _LINUX_SCHED_H
+#define _LINUX_SCHED_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <abi-bits/pid_t.h>
+#include <bits/size_t.h>
+#include <bits/linux/cpu_set.h>
+
+#define CLONE_VM 0x00000100
+#define CLONE_FS 0x00000200
+#define CLONE_FILES 0x00000400
+#define CLONE_SIGHAND 0x00000800
+#define CLONE_PTRACE 0x00002000
+#define CLONE_VFORK 0x00004000
+#define CLONE_PARENT 0x00008000
+#define CLONE_THREAD 0x00010000
+#define CLONE_NEWNS 0x00020000
+#define CLONE_SYSVSEM 0x00040000
+#define CLONE_SETTLS 0x00080000
+#define CLONE_PARENT_SETTID 0x00100000
+#define CLONE_CHILD_CLEARTID 0x00200000
+#define CLONE_DETACHED 0x00400000
+#define CLONE_UNTRACED 0x00800000
+#define CLONE_CHILD_SETTID 0x01000000
+#define CLONE_NEWCGROUP 0x02000000
+#define CLONE_NEWUTS 0x04000000
+#define CLONE_NEWIPC 0x08000000
+#define CLONE_NEWUSER 0x10000000
+#define CLONE_NEWPID 0x20000000
+#define CLONE_NEWNET 0x40000000
+#define CLONE_IO 0x80000000
+
+#ifndef __MLIBC_ABI_ONLY
+
+int sched_getscheduler(pid_t pid);
+int sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *mask);
+int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
+
+int unshare(int flags);
+int clone(int (*)(void *), void *, int, void *, ...);
+
+/* Glibc extension */
+int sched_getcpu(void);
+
+#if defined(_GNU_SOURCE)
+int setns(int fd, int nstype);
+#endif /* _GNU_SOURCE */
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LINUX_SCHED_H */
diff --git a/lib/mlibc/options/linux/include/bits/linux/linux_unistd.h b/lib/mlibc/options/linux/include/bits/linux/linux_unistd.h
new file mode 100644
index 0000000..77534ba
--- /dev/null
+++ b/lib/mlibc/options/linux/include/bits/linux/linux_unistd.h
@@ -0,0 +1,21 @@
+#ifndef _LINUX_UNISTD_H
+#define _LINUX_UNISTD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int dup3(int fd, int newfd, int flags);
+int vhangup(void);
+int getdtablesize(void);
+int syncfs(int fd);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LINUX_UNISTD_H
diff --git a/lib/mlibc/options/linux/include/ifaddrs.h b/lib/mlibc/options/linux/include/ifaddrs.h
new file mode 100644
index 0000000..2604e3e
--- /dev/null
+++ b/lib/mlibc/options/linux/include/ifaddrs.h
@@ -0,0 +1,35 @@
+
+#ifndef _IFADDRS_H
+#define _IFADDRS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+// Struct definitions taken from musl
+struct ifaddrs {
+ struct ifaddrs *ifa_next;
+ char *ifa_name;
+ unsigned ifa_flags;
+ struct sockaddr *ifa_addr;
+ struct sockaddr *ifa_netmask;
+ struct sockaddr *ifa_broadaddr;
+ struct sockaddr *ifa_dstaddr;
+ void *ifa_data;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+int getifaddrs(struct ifaddrs **);
+void freeifaddrs(struct ifaddrs *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _IFADDRS_H
diff --git a/lib/mlibc/options/linux/include/lastlog.h b/lib/mlibc/options/linux/include/lastlog.h
new file mode 100644
index 0000000..0930aaf
--- /dev/null
+++ b/lib/mlibc/options/linux/include/lastlog.h
@@ -0,0 +1,2 @@
+// Maches glibc
+#include <utmp.h> \ No newline at end of file
diff --git a/lib/mlibc/options/linux/include/linux/libc-compat.h b/lib/mlibc/options/linux/include/linux/libc-compat.h
new file mode 100644
index 0000000..696f4af
--- /dev/null
+++ b/lib/mlibc/options/linux/include/linux/libc-compat.h
@@ -0,0 +1,61 @@
+#ifndef _LINUX_LIBC_COMPAT_H
+#define _LINUX_LIBC_COMPAT_H
+
+#if defined(_NET_IF_H)
+
+#define __UAPI_DEF_IF_IFCONF 0
+#define __UAPI_DEF_IF_IFMAP 0
+#define __UAPI_DEF_IF_IFNAMSIZ 0
+#define __UAPI_DEF_IF_IFREQ 0
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
+
+#else // _NET_IF_H
+
+#define __UAPI_DEF_IF_IFCONF 1
+#define __UAPI_DEF_IF_IFMAP 1
+#define __UAPI_DEF_IF_IFNAMSIZ 1
+#define __UAPI_DEF_IF_IFREQ 1
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
+
+#endif //_NET_IF_H
+
+#if defined(_NETINET_IN_H)
+
+#define __UAPI_DEF_IN_ADDR 0
+#define __UAPI_DEF_IN_CLASS 0
+#define __UAPI_DEF_IN_IPPROTO 0
+#define __UAPI_DEF_IN_PKTINFO 0
+#define __UAPI_DEF_IP_MREQ 0
+#define __UAPI_DEF_SOCKADDR_IN 0
+
+#define __UAPI_DEF_IN6_ADDR 0
+#define __UAPI_DEF_IN6_ADDR_ALT 1
+#define __UAPI_DEF_IN6_PKTINFO 0
+#define __UAPI_DEF_IP6_MTUINFO 0
+#define __UAPI_DEF_IPPROTO_V6 0
+#define __UAPI_DEF_IPV6_MREQ 0
+#define __UAPI_DEF_IPV6_OPTIONS 0
+#define __UAPI_DEF_SOCKADDR_IN6 0
+
+#else
+
+#define __UAPI_DEF_IN_ADDR 1
+#define __UAPI_DEF_IN_CLASS 1
+#define __UAPI_DEF_IN_IPPROTO 1
+#define __UAPI_DEF_IN_PKTINFO 1
+#define __UAPI_DEF_IP_MREQ 1
+#define __UAPI_DEF_SOCKADDR_IN 1
+
+#define __UAPI_DEF_IN6_ADDR 1
+#define __UAPI_DEF_IN6_ADDR_ALT 1
+#define __UAPI_DEF_IN6_PKTINFO 1
+#define __UAPI_DEF_IP6_MTUINFO 1
+#define __UAPI_DEF_IPPROTO_V6 1
+#define __UAPI_DEF_IPV6_MREQ 1
+#define __UAPI_DEF_IPV6_OPTIONS 1
+#define __UAPI_DEF_SOCKADDR_IN6 1
+
+#endif /* _NETINET_IN_H */
+
+#endif // _LINUX_LIBC_COMPAT_H
diff --git a/lib/mlibc/options/linux/include/malloc.h b/lib/mlibc/options/linux/include/malloc.h
new file mode 100644
index 0000000..b03f9b4
--- /dev/null
+++ b/lib/mlibc/options/linux/include/malloc.h
@@ -0,0 +1,32 @@
+
+#ifndef _MALLOC_H
+#define _MALLOC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bits/size_t.h>
+#include <mlibc-config.h>
+
+#ifndef __MLIBC_ABI_ONLY
+
+// [7.22.3] Memory management functions
+void *calloc(size_t count, size_t size);
+void free(void *pointer);
+void *malloc(size_t size);
+void *realloc(void *pointer, size_t size);
+void *memalign(size_t, size_t);
+
+#if __MLIBC_GLIBC_OPTION
+#include <bits/glibc/glibc_malloc.h>
+#endif
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _MALLOC_H
+
diff --git a/lib/mlibc/options/linux/include/memory.h b/lib/mlibc/options/linux/include/memory.h
new file mode 100644
index 0000000..586822b
--- /dev/null
+++ b/lib/mlibc/options/linux/include/memory.h
@@ -0,0 +1,9 @@
+
+#ifndef _MEMORY_H
+#define _MEMORY_H
+
+// This is a linux extension
+#include <string.h>
+
+#endif // _MEMORY_H
+
diff --git a/lib/mlibc/options/linux/include/mlibc/linux-sysdeps.hpp b/lib/mlibc/options/linux/include/mlibc/linux-sysdeps.hpp
new file mode 100644
index 0000000..b18544a
--- /dev/null
+++ b/lib/mlibc/options/linux/include/mlibc/linux-sysdeps.hpp
@@ -0,0 +1,82 @@
+#ifndef MLIBC_LINUX_SYSDEPS
+#define MLIBC_LINUX_SYSDEPS
+
+#include <sched.h>
+#include <stdarg.h>
+#include <sys/epoll.h>
+#include <sys/sysinfo.h>
+#include <sys/statfs.h>
+#include <poll.h>
+#include <abi-bits/pid_t.h>
+#include <abi-bits/mode_t.h>
+#include <bits/ssize_t.h>
+#include <bits/size_t.h>
+
+namespace [[gnu::visibility("hidden")]] mlibc {
+
+int sys_open(const char *pathname, int flags, mode_t mode, int *fd);
+int sys_close(int fd);
+int sys_read(int fd, void *buf, size_t count, ssize_t *bytes_read);
+int sys_write(int fd, const void *buf, size_t count, ssize_t *bytes_written);
+int sys_ioctl(int fd, unsigned long request, void *arg, int *result);
+
+[[gnu::weak]] int sys_dup2(int fd, int flags, int newfd);
+[[gnu::weak]] int sys_fork(pid_t *child);
+[[gnu::weak]] int sys_inotify_create(int flags, int *fd);
+[[gnu::weak]] int sys_inotify_add_watch(int ifd, const char *path, uint32_t mask, int *wd);
+[[gnu::weak]] int sys_inotify_rm_watch(int ifd, int wd);
+[[gnu::weak]] int sys_epoll_create(int flags, int *fd);
+[[gnu::weak]] int sys_epoll_ctl(int epfd, int mode, int fd, struct epoll_event *ev);
+[[gnu::weak]] int sys_epoll_pwait(int epfd, struct epoll_event *ev, int n,
+ int timeout, const sigset_t *sigmask, int *raised);
+[[gnu::weak]] int sys_mount(const char *source, const char *target,
+ const char *fstype, unsigned long flags, const void *data);
+[[gnu::weak]] int sys_umount2(const char *target, int flags);
+[[gnu::weak]] int sys_eventfd_create(unsigned int initval, int flags, int *fd);
+[[gnu::weak]] int sys_timerfd_create(int clockid, int flags, int *fd);
+[[gnu::weak]] int sys_timerfd_settime(int fd, int flags,
+ const struct itimerspec *value, struct itimerspec *oldvalue);
+[[gnu::weak]] int sys_signalfd_create(const sigset_t *, int flags, int *fd);
+[[gnu::weak]] int sys_reboot(int cmd);
+[[gnu::weak]] int sys_ptrace(long req, pid_t pid, void *addr, void *data, long *out);
+[[gnu::weak]] int sys_prctl(int option, va_list va, int *out);
+[[gnu::weak]] int sys_init_module(void *module, unsigned long length, const char *args);
+[[gnu::weak]] int sys_delete_module(const char *name, unsigned flags);
+[[gnu::weak]] int sys_klogctl(int type, char *bufp, int len, int *out);
+[[gnu::weak]] int sys_getcpu(int *cpu);
+
+[[gnu::weak]] int sys_sysinfo(struct sysinfo *info);
+[[gnu::weak]] int sys_swapon(const char *path, int flags);
+[[gnu::weak]] int sys_swapoff(const char *path);
+
+[[gnu::weak]] int sys_setxattr(const char *path, const char *name,
+ const void *val, size_t size, int flags);
+[[gnu::weak]] int sys_lsetxattr(const char *path, const char *name,
+ const void *val, size_t size, int flags);
+[[gnu::weak]] int sys_fsetxattr(int fd, const char *name, const void *val,
+ size_t size, int flags);
+
+[[gnu::weak]] int sys_getxattr(const char *path, const char *name,
+ void *val, size_t size, ssize_t *nread);
+[[gnu::weak]] int sys_lgetxattr(const char *path, const char *name,
+ void *val, size_t size, ssize_t *nread);
+[[gnu::weak]] int sys_fgetxattr(int fd, const char *name, void *val,
+ size_t size, ssize_t *nread);
+
+[[gnu::weak]] int sys_listxattr(const char *path, char *list, size_t size,
+ ssize_t *nread);
+[[gnu::weak]] int sys_llistxattr(const char *path, char *list, size_t size,
+ ssize_t *nread);
+[[gnu::weak]] int sys_flistxattr(int fd, char *list, size_t size,
+ ssize_t *nread);
+
+[[gnu::weak]] int sys_removexattr(const char *path, const char *name);
+[[gnu::weak]] int sys_lremovexattr(const char *path, const char *name);
+[[gnu::weak]] int sys_fremovexattr(int fd, const char *name);
+
+[[gnu::weak]] int sys_statfs(const char *path, struct statfs *buf);
+[[gnu::weak]] int sys_fstatfs(int fd, struct statfs *buf);
+
+} // namespace mlibc
+
+#endif // MLIBX_LINUX_SYSDEPS
diff --git a/lib/mlibc/options/linux/include/mntent.h b/lib/mlibc/options/linux/include/mntent.h
new file mode 100644
index 0000000..bafd289
--- /dev/null
+++ b/lib/mlibc/options/linux/include/mntent.h
@@ -0,0 +1,50 @@
+#ifndef _MNTENT_H
+#define _MNTENT_H
+
+#include <stdio.h>
+
+// TODO: Refer to _PATH_MOUNTED
+#define MOUNTED "/etc/mtab"
+
+/* Generic mount options */
+#define MNTOPT_DEFAULTS "defaults" /* Use all default options. */
+#define MNTOPT_RO "ro" /* Read only. */
+#define MNTOPT_RW "rw" /* Read/write. */
+#define MNTOPT_SUID "suid" /* Set uid allowed. */
+#define MNTOPT_NOSUID "nosuid" /* No set uid allowed. */
+#define MNTOPT_NOAUTO "noauto" /* Do not auto mount. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct mntent {
+ char *mnt_fsname;
+ char *mnt_dir;
+ char *mnt_type;
+ char *mnt_opts;
+ int mnt_freq;
+ int mnt_passno;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+FILE *setmntent(const char *, const char *);
+
+struct mntent *getmntent(FILE *);
+
+int addmntent(FILE *, const struct mntent *);
+
+int endmntent(FILE *);
+
+char *hasmntopt(const struct mntent *, const char *);
+
+struct mntent *getmntent_r(FILE *, struct mntent *, char *, int);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _MNTENT_H
diff --git a/lib/mlibc/options/linux/include/module.h b/lib/mlibc/options/linux/include/module.h
new file mode 100644
index 0000000..ef715a4
--- /dev/null
+++ b/lib/mlibc/options/linux/include/module.h
@@ -0,0 +1,25 @@
+#ifndef _MODULE_H
+#define _MODULE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+/*
+ * Musl adds these, even though they aren't specified, but doesn't export them.
+ * See https://github.com/bminor/musl/commit/2169265ec6c902cd460bf96a1a0b5103657a4954
+ * for more information and the rationale behind it.
+ * For our infrastructure, we expose them, and make it call into the sysdeps.
+ */
+int init_module(void *module, unsigned long len, const char *args);
+int delete_module(const char *name, unsigned flags);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _MODULE_H
diff --git a/lib/mlibc/options/linux/include/netpacket/packet.h b/lib/mlibc/options/linux/include/netpacket/packet.h
new file mode 100644
index 0000000..1fa0917
--- /dev/null
+++ b/lib/mlibc/options/linux/include/netpacket/packet.h
@@ -0,0 +1,40 @@
+#ifndef _NETPACKET_PACKET_H
+#define _NETPACKET_PACKET_H
+
+#include <abi-bits/packet.h>
+
+/* Packet types */
+#define PACKET_HOST 0
+#define PACKET_BROADCAST 1
+#define PACKET_MULTICAST 2
+#define PACKET_OTHERHOST 3
+#define PACKET_OUTGOING 4
+#define PACKET_LOOPBACK 5
+#define PACKET_FASTROUTE 6
+
+struct sockaddr_ll {
+ unsigned short int sll_family;
+ unsigned short int sll_protocol;
+ int sll_ifindex;
+ unsigned short int sll_hatype;
+ unsigned char sll_pkttype;
+ unsigned char sll_halen;
+ unsigned char sll_addr[8];
+};
+
+struct packet_mreq {
+ int mr_ifindex;
+ unsigned short int mr_type;
+ unsigned short int mr_alen;
+ unsigned char mr_address[8];
+};
+
+#define PACKET_ADD_MEMBERSHIP 1
+#define PACKET_DROP_MEMBERSHIP 2
+
+#define PACKET_MR_MULTICAST 0
+#define PACKET_MR_PROMISC 1
+#define PACKET_MR_ALLMULTI 2
+#define PACKET_MR_UNICAST 3
+
+#endif // _NETPACKET_PACKET_H
diff --git a/lib/mlibc/options/linux/include/pty.h b/lib/mlibc/options/linux/include/pty.h
new file mode 100644
index 0000000..562fbb8
--- /dev/null
+++ b/lib/mlibc/options/linux/include/pty.h
@@ -0,0 +1,23 @@
+
+#ifndef _PTY_H
+#define _PTY_H
+
+#include <termios.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int openpty(int *, int *, char *, const struct termios *, const struct winsize *);
+int forkpty(int *, char *, const struct termios *, const struct winsize *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _PTY_H
+
diff --git a/lib/mlibc/options/linux/include/scsi/scsi.h b/lib/mlibc/options/linux/include/scsi/scsi.h
new file mode 100644
index 0000000..f7f92d8
--- /dev/null
+++ b/lib/mlibc/options/linux/include/scsi/scsi.h
@@ -0,0 +1,18 @@
+
+#ifndef _LINUX_SCSI_SCSI_H
+#define _LINUX_SCSI_SCSI_H
+
+#define RECOVERED_ERROR 0x01
+#define ILLEGAL_REQUEST 0x05
+#define UNIT_ATTENTION 0x06
+#define INQUIRY 0x12
+#define START_STOP 0x1b
+#define ALLOW_MEDIUM_REMOVAL 0x1e
+
+#define SCSI_IOCTL_GET_IDLUN 0x5382
+#define SCSI_IOCTL_TAGGED_ENABLE 0x5383
+#define SCSI_IOCTL_TAGGED_DISABLE 0x5384
+#define SCSI_IOCTL_PROBE_HOST 0x5385
+
+#endif // _LINUX_SCSI_SCSI_H
+
diff --git a/lib/mlibc/options/linux/include/scsi/scsi_ioctl.h b/lib/mlibc/options/linux/include/scsi/scsi_ioctl.h
new file mode 100644
index 0000000..16c7cfa
--- /dev/null
+++ b/lib/mlibc/options/linux/include/scsi/scsi_ioctl.h
@@ -0,0 +1,6 @@
+
+#ifndef _LINUX_SCSI_SCSI_IOCTL_H
+#define _LINUX_SCSI_SCSI_IOCTL_H
+
+#endif // _LINUX_SCSI_SCSI_IOCTL_H
+
diff --git a/lib/mlibc/options/linux/include/scsi/sg.h b/lib/mlibc/options/linux/include/scsi/sg.h
new file mode 100644
index 0000000..a9dfc7a
--- /dev/null
+++ b/lib/mlibc/options/linux/include/scsi/sg.h
@@ -0,0 +1,77 @@
+
+#ifndef _LINUX_SCSI_SG_H
+#define _LINUX_SCSI_SG_H
+
+#define SG_IO 0x2285
+
+#define SG_GET_VERSION_NUM 0x2282
+
+#define SG_FLAG_DIRECT_IO 1
+#define SG_FLAG_LUN_INHIBIT 2
+
+#define SG_INFO_OK 0x0
+#define SG_INFO_OK_MASK 0x1
+
+#define SG_DXFER_NONE (-1)
+#define SG_DXFER_TO_DEV (-2)
+#define SG_DXFER_FROM_DEV (-3)
+#define SG_DXFER_TO_FROM_DEV (-4)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct sg_io_hdr {
+ int interface_id;
+ int dxfer_direction;
+ unsigned char cmd_len;
+ unsigned char mx_sb_len;
+ unsigned short iovec_count;
+ unsigned int dxfer_len;
+ void *dxferp;
+ unsigned char *cmdp;
+ unsigned char *sbp;
+ unsigned int timeout;
+ unsigned int flags;
+ int pack_id;
+ void *usr_ptr;
+ unsigned char status;
+ unsigned char masked_status;
+ unsigned char msg_status;
+ unsigned char sb_len_wr;
+ unsigned short host_status;
+ unsigned short driver_status;
+ int resid;
+ unsigned int duration;
+ unsigned int info;
+} sg_io_hdr_t;
+
+struct sg_scsi_id {
+ int host_no;
+ int channel;
+ int scsi_id;
+ int lun;
+ int scsi_type;
+ short int h_cmd_per_lun;
+ short int d_queue_depth;
+ int unused[2];
+};
+
+typedef struct sg_req_info {
+ char req_state;
+ char orphan;
+ char sg_io_owned;
+ char problem;
+ int pack_id;
+ void *usr_ptr;
+ unsigned int duration;
+
+ int unused;
+} sg_req_info_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LINUX_SCSI_SG_H
+
diff --git a/lib/mlibc/options/linux/include/sys/epoll.h b/lib/mlibc/options/linux/include/sys/epoll.h
new file mode 100644
index 0000000..f84da7a
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/epoll.h
@@ -0,0 +1,66 @@
+#ifndef _SYS_EPOLL_H
+#define _SYS_EPOLL_H
+
+#include <stdint.h>
+#include <abi-bits/signal.h>
+#include <abi-bits/epoll.h>
+#include <abi-bits/fcntl.h>
+
+#define EPOLL_NONBLOCK O_NONBLOCK
+
+// These constants match the Linux definitions.
+#define EPOLLIN 0x001
+#define EPOLLPRI 0x002
+#define EPOLLOUT 0x004
+#define EPOLLRDNORM 0x040
+#define EPOLLRDBAND 0x080
+#define EPOLLWRNORM 0x100
+#define EPOLLWRBAND 0x200
+#define EPOLLMSG 0x400
+#define EPOLLERR 0x008
+#define EPOLLHUP 0x010
+#define EPOLLRDHUP 0x2000
+#define EPOLLEXCLUSIVE (1U << 28)
+#define EPOLLWAKEUP (1U << 29)
+#define EPOLLONESHOT (1U << 30)
+#define EPOLLET (1U << 31)
+
+#define EPOLL_CTL_ADD 1
+#define EPOLL_CTL_DEL 2
+#define EPOLL_CTL_MOD 3
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef union epoll_data {
+ void *ptr;
+ int fd;
+ uint32_t u32;
+ uint64_t u64;
+} epoll_data_t;
+
+struct epoll_event {
+ uint32_t events;
+ epoll_data_t data;
+}
+#ifdef __x86_64__
+__attribute__((__packed__))
+#endif
+;
+
+#ifndef __MLIBC_ABI_ONLY
+
+int epoll_create(int);
+int epoll_create1(int);
+int epoll_ctl(int, int, int, struct epoll_event *);
+int epoll_wait(int, struct epoll_event *, int, int);
+int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_EPOLL_H
diff --git a/lib/mlibc/options/linux/include/sys/eventfd.h b/lib/mlibc/options/linux/include/sys/eventfd.h
new file mode 100644
index 0000000..454a8c1
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/eventfd.h
@@ -0,0 +1,29 @@
+#ifndef _SYS_EVENTFD_H
+#define _SYS_EVENTFD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <fcntl.h>
+
+typedef uint64_t eventfd_t;
+
+#define EFD_SEMAPHORE 1
+#define EFD_CLOEXEC O_CLOEXEC
+#define EFD_NONBLOCK O_NONBLOCK
+
+#ifndef __MLIBC_ABI_ONLY
+
+int eventfd(unsigned int, int);
+int eventfd_read(int, eventfd_t *);
+int eventfd_write(int, eventfd_t);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_EVENTFD_H
diff --git a/lib/mlibc/options/linux/include/sys/fsuid.h b/lib/mlibc/options/linux/include/sys/fsuid.h
new file mode 100644
index 0000000..9df9efc
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/fsuid.h
@@ -0,0 +1,22 @@
+#ifndef _SYS_FSUID_H
+#define _SYS_FSUID_H
+
+#include <abi-bits/uid_t.h>
+#include <abi-bits/gid_t.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int setfsuid(uid_t uid);
+int setfsgid(gid_t gid);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_FSUID_H
diff --git a/lib/mlibc/options/linux/include/sys/inotify.h b/lib/mlibc/options/linux/include/sys/inotify.h
new file mode 100644
index 0000000..3c48403
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/inotify.h
@@ -0,0 +1,63 @@
+#ifndef _SYS_INOTIFY_H
+#define _SYS_INOTIFY_H
+
+#include <stdint.h>
+#include <abi-bits/fcntl.h>
+#include <abi-bits/inotify.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define IN_ACCESS 0x1
+#define IN_ATTRIB 0x4
+#define IN_CLOSE_WRITE 0x8
+#define IN_CLOSE_NOWRITE 0x10
+#define IN_CREATE 0x100
+#define IN_DELETE 0x200
+#define IN_DELETE_SELF 0x400
+#define IN_MODIFY 0x2
+#define IN_MOVE_SELF 0x800
+#define IN_MOVED_FROM 0x40
+#define IN_MOVED_TO 0x80
+#define IN_OPEN 0x20
+#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO)
+#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
+#define IN_DONT_FOLLOW 0x2000000
+#define IN_EXCL_UNLINK 0x4000000
+#define IN_MASK_ADD 0x20000000
+#define IN_ONESHOT 0x80000000
+#define IN_ONLYDIR 0x1000000
+#define IN_IGNORED 0x8000
+#define IN_ISDIR 0x40000000
+#define IN_Q_OVERFLOW 0x4000
+#define IN_UNMOUNT 0x2000
+
+#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
+ IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
+ IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
+ IN_MOVE_SELF)
+
+struct inotify_event {
+ int wd;
+ unsigned int mask;
+ unsigned int cookie;
+ unsigned int len;
+ char name[];
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+int inotify_init(void);
+int inotify_init1(int);
+int inotify_add_watch(int, const char *, uint32_t);
+int inotify_rm_watch(int, int);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_SYS_INOTIFY_H
+
diff --git a/lib/mlibc/options/linux/include/sys/klog.h b/lib/mlibc/options/linux/include/sys/klog.h
new file mode 100644
index 0000000..520bdd1
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/klog.h
@@ -0,0 +1,18 @@
+#ifndef _SYS_KLOG_H
+#define _SYS_KLOG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int klogctl(int type, char *bufp, int len);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_KLOG_H */
diff --git a/lib/mlibc/options/linux/include/sys/mount.h b/lib/mlibc/options/linux/include/sys/mount.h
new file mode 100644
index 0000000..2486128
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/mount.h
@@ -0,0 +1,90 @@
+#ifndef _SYS_MOUNT_H
+#define _SYS_MOUNT_H
+
+#include <asm/ioctl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MS_RDONLY 1
+#define MS_NOSUID 2
+#define MS_NODEV 4
+#define MS_NOEXEC 8
+#define MS_SYNCHRONOUS 16
+#define MS_REMOUNT 32
+#define MS_MANDLOCK 64
+#define MS_DIRSYNC 128
+#define MS_NOSYMFOLLOW 256
+#define MS_NOATIME 1024
+#define MS_NODIRATIME 2048
+#define MS_BIND 4096
+#define MS_MOVE 8192
+#define MS_REC 16384
+#define MS_SILENT 32768
+#define MS_POSIXACL (1 << 16)
+#define MS_UNBINDABLE (1 << 17)
+#define MS_PRIVATE (1 << 18)
+#define MS_SLAVE (1 << 19)
+#define MS_SHARED (1 << 20)
+#define MS_RELATIME (1 << 21)
+#define MS_KERNMOUNT (1 << 22)
+#define MS_I_VERSION (1 << 23)
+#define MS_STRICTATIME (1 << 24)
+#define MS_LAZYTIME (1 << 25)
+#define MS_NOREMOTELOCK (1 << 27)
+#define MS_NOSEC (1 << 28)
+#define MS_BORN (1 << 29)
+#define MS_ACTIVE (1 << 30)
+#define MS_NOUSER (1 << 31)
+
+#define MNT_FORCE 1
+#define MNT_DETACH 2
+#define MNT_EXPIRE 4
+#define UMOUNT_NOFOLLOW 8
+
+#undef BLKROSET
+#define BLKROSET _IO(0x12, 93)
+#undef BLKROGET
+#define BLKROGET _IO(0x12, 94)
+#undef BLKRRPART
+#define BLKRRPART _IO(0x12, 95)
+#undef BLKGETSIZE
+#define BLKGETSIZE _IO(0x12, 96)
+#undef BLKFLSBUF
+#define BLKFLSBUF _IO(0x12, 97)
+#undef BLKRASET
+#define BLKRASET _IO(0x12, 98)
+#undef BLKRAGET
+#define BLKRAGET _IO(0x12, 99)
+#undef BLKFRASET
+#define BLKFRASET _IO(0x12, 100)
+#undef BLKFRAGET
+#define BLKFRAGET _IO(0x12, 101)
+#undef BLKSECTSET
+#define BLKSECTSET _IO(0x12, 102)
+#undef BLKSECTGET
+#define BLKSECTGET _IO(0x12, 103)
+#undef BLKSSZGET
+#define BLKSSZGET _IO(0x12, 104)
+#undef BLKBSZGET
+#define BLKBSZGET _IOR(0x12, 112, size_t)
+#undef BLKBSZSET
+#define BLKBSZSET _IOW(0x12, 113, size_t)
+#undef BLKGETSIZE64
+#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
+
+#ifndef __MLIBC_ABI_ONLY
+
+int mount(const char *source, const char *target,
+ const char *fstype, unsigned long flags, const void *data);
+int umount(const char *target);
+int umount2(const char *target, int flags);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_MOUNT_H
diff --git a/lib/mlibc/options/linux/include/sys/prctl.h b/lib/mlibc/options/linux/include/sys/prctl.h
new file mode 100644
index 0000000..de987c1
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/prctl.h
@@ -0,0 +1,128 @@
+
+#ifndef _SYS_PRCTL_H
+#define _SYS_PRCTL_H
+
+#include <stdint.h>
+
+#define PR_SET_PDEATHSIG 1
+#define PR_GET_PDEATHSIG 2
+#define PR_GET_DUMPABLE 3
+#define PR_SET_DUMPABLE 4
+#define PR_GET_UNALIGN 5
+#define PR_SET_UNALIGN 6
+#define PR_UNALIGN_NOPRINT 1
+#define PR_UNALIGN_SIGBUS 2
+#define PR_GET_KEEPCAPS 7
+#define PR_SET_KEEPCAPS 8
+#define PR_GET_FPEMU 9
+#define PR_SET_FPEMU 10
+#define PR_FPEMU_NOPRINT 1
+#define PR_FPEMU_SIGFPE 2
+#define PR_GET_FPEXC 11
+#define PR_SET_FPEXC 12
+#define PR_FP_EXC_SW_ENABLE 0x80
+#define PR_FP_EXC_DIV 0x010000
+#define PR_FP_EXC_OVF 0x020000
+#define PR_FP_EXC_UND 0x040000
+#define PR_FP_EXC_RES 0x080000
+#define PR_FP_EXC_INV 0x100000
+#define PR_FP_EXC_DISABLED 0
+#define PR_FP_EXC_NONRECOV 1
+#define PR_FP_EXC_ASYNC 2
+#define PR_FP_EXC_PRECISE 3
+#define PR_GET_TIMING 13
+#define PR_SET_TIMING 14
+#define PR_TIMING_STATISTICAL 0
+#define PR_TIMING_TIMESTAMP 1
+#define PR_SET_NAME 15
+#define PR_GET_NAME 16
+#define PR_GET_ENDIAN 19
+#define PR_SET_ENDIAN 20
+#define PR_ENDIAN_BIG 0
+#define PR_ENDIAN_LITTLE 1
+#define PR_ENDIAN_PPC_LITTLE 2
+#define PR_GET_SECCOMP 21
+#define PR_SET_SECCOMP 22
+#define PR_CAPBSET_READ 23
+#define PR_CAPBSET_DROP 24
+#define PR_GET_TSC 25
+#define PR_SET_TSC 26
+#define PR_TSC_ENABLE 1
+#define PR_TSC_SIGSEGV 2
+#define PR_GET_SECUREBITS 27
+#define PR_SET_SECUREBITS 28
+#define PR_SET_TIMERSLACK 29
+#define PR_GET_TIMERSLACK 30
+
+#define PR_TASK_PERF_EVENTS_DISABLE 31
+#define PR_TASK_PERF_EVENTS_ENABLE 32
+
+#define PR_MCE_KILL 33
+#define PR_MCE_KILL_CLEAR 0
+#define PR_MCE_KILL_SET 1
+#define PR_MCE_KILL_LATE 0
+#define PR_MCE_KILL_EARLY 1
+#define PR_MCE_KILL_DEFAULT 2
+#define PR_MCE_KILL_GET 34
+
+#define PR_SET_MM 35
+#define PR_SET_MM_START_CODE 1
+#define PR_SET_MM_END_CODE 2
+#define PR_SET_MM_START_DATA 3
+#define PR_SET_MM_END_DATA 4
+#define PR_SET_MM_START_STACK 5
+#define PR_SET_MM_START_BRK 6
+#define PR_SET_MM_BRK 7
+#define PR_SET_MM_ARG_START 8
+#define PR_SET_MM_ARG_END 9
+#define PR_SET_MM_ENV_START 10
+#define PR_SET_MM_ENV_END 11
+#define PR_SET_MM_AUXV 12
+#define PR_SET_MM_EXE_FILE 13
+#define PR_SET_MM_MAP 14
+#define PR_SET_MM_MAP_SIZE 15
+
+#define PR_SET_PTRACER 0x59616d61
+#define PR_SET_PTRACER_ANY (-1UL)
+
+#define PR_SET_CHILD_SUBREAPER 36
+#define PR_GET_CHILD_SUBREAPER 37
+
+#define PR_SET_NO_NEW_PRIVS 38
+#define PR_GET_NO_NEW_PRIVS 39
+
+#define PR_GET_TID_ADDRESS 40
+
+#define PR_SET_THP_DISABLE 41
+#define PR_GET_THP_DISABLE 42
+
+#define PR_MPX_ENABLE_MANAGEMENT 43
+#define PR_MPX_DISABLE_MANAGEMENT 44
+
+#define PR_SET_FP_MODE 45
+#define PR_GET_FP_MODE 46
+#define PR_FP_MODE_FR (1 << 0)
+#define PR_FP_MODE_FRE (1 << 1)
+
+#define PR_CAP_AMBIENT 47
+#define PR_CAP_AMBIENT_IS_SET 1
+#define PR_CAP_AMBIENT_RAISE 2
+#define PR_CAP_AMBIENT_LOWER 3
+#define PR_CAP_AMBIENT_CLEAR_ALL 4
+
+#ifndef __MLIBC_ABI_ONLY
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int prctl (int, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#endif // _SYS_PRCTL_H
+
diff --git a/lib/mlibc/options/linux/include/sys/ptrace.h b/lib/mlibc/options/linux/include/sys/ptrace.h
new file mode 100644
index 0000000..e98d38a
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/ptrace.h
@@ -0,0 +1,55 @@
+
+#ifndef _SYS_PTRACE_H
+#define _SYS_PTRACE_H
+
+#include <abi-bits/ptrace.h>
+#include <stdint.h>
+
+#define PTRACE_TRACEME 0
+#define PT_TRACE_ME PTRACE_TRACEME
+
+#define PT_READ_I PTRACE_PEEKTEXT
+#define PT_READ_D PTRACE_PEEKDATA
+#define PT_READ_U PTRACE_PEEKUSER
+#define PT_WRITE_I PTRACE_POKETEXT
+#define PT_WRITE_D PTRACE_POKEDATA
+#define PT_WRITE_U PTRACE_POKEUSER
+#define PT_CONTINUE PTRACE_CONT
+#define PT_KILL PTRACE_KILL
+#define PT_STEP PTRACE_SINGLESTEP
+#define PT_GETREGS PTRACE_GETREGS
+#define PT_SETREGS PTRACE_SETREGS
+#define PT_GETFPREGS PTRACE_GETFPREGS
+#define PT_SETFPREGS PTRACE_SETFPREGS
+#define PT_ATTACH PTRACE_ATTACH
+#define PT_DETACH PTRACE_DETACH
+#define PT_GETFPXREGS PTRACE_GETFPXREGS
+#define PT_SETFPXREGS PTRACE_SETFPXREGS
+#define PT_SYSCALL PTRACE_SYSCALL
+#define PT_SETOPTIONS PTRACE_SETOPTIONS
+#define PT_GETEVENTMSG PTRACE_GETEVENTMSG
+#define PT_GETSIGINFO PTRACE_GETSIGINFO
+#define PT_SETSIGINFO PTRACE_SETSIGINFO
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ptrace_peeksiginfo_args {
+ uint64_t offset;
+ uint32_t flags;
+ int32_t nr;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+long ptrace(int, ...);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_PTRACE_H
+
diff --git a/lib/mlibc/options/linux/include/sys/quota.h b/lib/mlibc/options/linux/include/sys/quota.h
new file mode 100644
index 0000000..f668d9b
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/quota.h
@@ -0,0 +1,24 @@
+#ifndef _SYS_QUOTA_H
+#define _SYS_QUOTA_H
+
+#include <sys/types.h>
+
+#define SUBCMDMASK 0x00ff
+#define SUBCMDSHIFT 8
+#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int quotactl(int cmd, const char *special, int id, caddr_t addr);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_QUOTA_H
diff --git a/lib/mlibc/options/linux/include/sys/random.h b/lib/mlibc/options/linux/include/sys/random.h
new file mode 100644
index 0000000..0b24b74
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/random.h
@@ -0,0 +1,26 @@
+
+#ifndef _SYS_RANDOM_H
+#define _SYS_RANDOM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GRND_RANDOM 1
+#define GRND_NONBLOCK 2
+
+#include <bits/ssize_t.h>
+#include <bits/size_t.h>
+
+#ifndef __MLIBC_ABI_ONLY
+
+ssize_t getrandom(void *, size_t, unsigned int);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_SYS_RANDOM_H
+
diff --git a/lib/mlibc/options/linux/include/sys/reboot.h b/lib/mlibc/options/linux/include/sys/reboot.h
new file mode 100644
index 0000000..6c4e495
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/reboot.h
@@ -0,0 +1,20 @@
+#ifndef MLIBC_SYS_REBOOT_H
+#define MLIBC_SYS_REBOOT_H
+
+#include <abi-bits/reboot.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int reboot(int arg);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MLIBC_SYS_REBOOT_H
diff --git a/lib/mlibc/options/linux/include/sys/sendfile.h b/lib/mlibc/options/linux/include/sys/sendfile.h
new file mode 100644
index 0000000..32b17ce
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/sendfile.h
@@ -0,0 +1,22 @@
+
+#ifndef _SYS_SENDFILE_H_
+#define _SYS_SENDFILE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <unistd.h>
+
+#ifndef __MLIBC_ABI_ONLY
+
+ssize_t sendfile(int, int, off_t *, size_t);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_SENDFILE_H_
+
diff --git a/lib/mlibc/options/linux/include/sys/signalfd.h b/lib/mlibc/options/linux/include/sys/signalfd.h
new file mode 100644
index 0000000..adf7c1b
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/signalfd.h
@@ -0,0 +1,48 @@
+#ifndef _SYS_SIGNALFD_H
+#define _SYS_SIGNALFD_H
+
+// TODO: Define sigset separately and remove this include.
+#include <signal.h>
+// musl includes those. Restructure this so we do not need them?
+#include <stdint.h>
+#include <fcntl.h>
+
+#define SFD_CLOEXEC O_CLOEXEC
+#define SFD_NONBLOCK O_NONBLOCK
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct signalfd_siginfo {
+ uint32_t ssi_signo;
+ int32_t ssi_errno;
+ int32_t ssi_code;
+ uint32_t ssi_pid;
+ uint32_t ssi_uid;
+ int32_t ssi_fd;
+ uint32_t ssi_tid;
+ uint32_t ssi_band;
+ uint32_t ssi_overrun;
+ uint32_t ssi_trapno;
+ int32_t ssi_status;
+ int32_t ssi_int;
+ uint64_t ssi_ptr;
+ uint64_t ssi_utime;
+ uint64_t ssi_stime;
+ uint64_t ssi_addr;
+ uint16_t ssi_addr_lsb;
+ uint8_t pad[128-12*4-4*8-2];
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+int signalfd(int, const sigset_t *, int);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_SIGNALFD_H
diff --git a/lib/mlibc/options/linux/include/sys/statfs.h b/lib/mlibc/options/linux/include/sys/statfs.h
new file mode 100644
index 0000000..07ae693
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/statfs.h
@@ -0,0 +1,22 @@
+#ifndef _SYS_STATFS_H
+#define _SYS_STATFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <abi-bits/statfs.h>
+
+#ifndef __MLIBC_ABI_ONLY
+
+int statfs(const char *, struct statfs *);
+int fstatfs(int, struct statfs *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_STATFS_H
+
diff --git a/lib/mlibc/options/linux/include/sys/swap.h b/lib/mlibc/options/linux/include/sys/swap.h
new file mode 100644
index 0000000..79e89c6
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/swap.h
@@ -0,0 +1,24 @@
+#ifndef _SYS_SWAP_H
+#define _SYS_SWAP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SWAP_FLAG_PREFER 0x8000
+#define SWAP_FLAG_PRIO_MASK 0x7fff
+#define SWAP_FLAG_PRIO_SHIFT 0
+#define SWAP_FLAG_DISCARD 0x10000
+
+#ifndef __MLIBC_ABI_ONLY
+
+int swapon(const char *, int);
+int swapoff(const char *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_SWAP_H */
diff --git a/lib/mlibc/options/linux/include/sys/sysinfo.h b/lib/mlibc/options/linux/include/sys/sysinfo.h
new file mode 100644
index 0000000..917f861
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/sysinfo.h
@@ -0,0 +1,34 @@
+#ifndef _SYS_SYSINFO_H
+#define _SYS_SYSINFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct sysinfo {
+ long uptime;
+ unsigned long loads[3];
+ unsigned long totalram;
+ unsigned long freeram;
+ unsigned long sharedram;
+ unsigned long bufferram;
+ unsigned long totalswap;
+ unsigned long freeswap;
+ unsigned short procs;
+ unsigned long totalhigh;
+ unsigned long freehigh;
+ unsigned int mem_unit;
+ char _f[20 - 2 * sizeof(long) - sizeof(int)]; // Padding to 64 bytes according to my man page
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+int sysinfo(struct sysinfo *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_SYSINFO_H
diff --git a/lib/mlibc/options/linux/include/sys/sysmacros.h b/lib/mlibc/options/linux/include/sys/sysmacros.h
new file mode 100644
index 0000000..230858b
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/sysmacros.h
@@ -0,0 +1,35 @@
+#ifndef _SYS_SYSMACROS_H
+#define _SYS_SYSMACROS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bits/inline-definition.h>
+
+__MLIBC_INLINE_DEFINITION unsigned int __mlibc_dev_major(
+ unsigned long long int __dev) {
+ return ((__dev >> 8) & 0xfff) | ((unsigned int)(__dev >> 32) & ~0xfff);
+}
+
+__MLIBC_INLINE_DEFINITION unsigned int __mlibc_dev_minor(
+ unsigned long long int __dev) {
+ return (__dev & 0xff) | ((unsigned int)(__dev >> 12) & ~0xff);
+}
+
+__MLIBC_INLINE_DEFINITION unsigned long long int __mlibc_dev_makedev(
+ unsigned int __major, unsigned int __minor) {
+ return ((__minor & 0xff) | ((__major & 0xfff) << 8)
+ | (((unsigned long long int)(__minor & ~0xff)) << 12)
+ | (((unsigned long long int)(__major & ~0xfff)) << 32));
+}
+
+#define major(dev) __mlibc_dev_major(dev)
+#define minor(dev) __mlibc_dev_minor(dev)
+#define makedev(major, minor) __mlibc_dev_makedev(major, minor)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_SYSMACROS_H
diff --git a/lib/mlibc/options/linux/include/sys/timerfd.h b/lib/mlibc/options/linux/include/sys/timerfd.h
new file mode 100644
index 0000000..b8a2932
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/timerfd.h
@@ -0,0 +1,32 @@
+#ifndef _SYS_TIMERFD_H
+#define _SYS_TIMERFD_H
+
+// musl includes those. Refactor and remove them?
+#include <time.h>
+#include <fcntl.h>
+
+#define TFD_NONBLOCK O_NONBLOCK
+#define TFD_CLOEXEC O_CLOEXEC
+
+#define TFD_TIMER_ABSTIME 1
+#define TFD_TIMER_CANCEL_ON_SET (1 << 1)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct itimerspec;
+
+#ifndef __MLIBC_ABI_ONLY
+
+int timerfd_create(int, int);
+int timerfd_settime(int, int, const struct itimerspec *, struct itimerspec *);
+int timerfd_gettime(int, struct itimerspec *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_TIMERFD_H
diff --git a/lib/mlibc/options/linux/include/sys/vfs.h b/lib/mlibc/options/linux/include/sys/vfs.h
new file mode 100644
index 0000000..61a6aa3
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/vfs.h
@@ -0,0 +1,16 @@
+
+#ifndef _SYS_VFS_H
+#define _SYS_VFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/statfs.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_VFS_H
+
diff --git a/lib/mlibc/options/linux/include/sys/vt.h b/lib/mlibc/options/linux/include/sys/vt.h
new file mode 100644
index 0000000..d9dfbd9
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/vt.h
@@ -0,0 +1,6 @@
+#ifndef _SYS_VT_H
+#define _SYS_VT_H
+
+#include <abi-bits/vt.h>
+
+#endif // _SYS_VT_H
diff --git a/lib/mlibc/options/linux/include/sys/xattr.h b/lib/mlibc/options/linux/include/sys/xattr.h
new file mode 100644
index 0000000..e54c58c
--- /dev/null
+++ b/lib/mlibc/options/linux/include/sys/xattr.h
@@ -0,0 +1,38 @@
+#ifndef _MLIBC_LINUX_SYS_XATTR_H
+#define _MLIBC_LINUX_SYS_XATTR_H
+
+#include <sys/types.h>
+#include <abi-bits/xattr.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int setxattr(const char *path, const char *name, const void *val, size_t size,
+ int flags);
+int lsetxattr(const char *path, const char *name, const void *val, size_t size,
+ int flags);
+int fsetxattr(int fd, const char *name, const void *val, size_t size,
+ int flags);
+
+ssize_t getxattr(const char *path, const char *name, void *val, size_t size);
+ssize_t lgetxattr(const char *path, const char *name, void *val, size_t size);
+ssize_t fgetxattr(int fd, const char *name, void *val, size_t size);
+
+ssize_t listxattr(const char *path, char *list, size_t size);
+ssize_t llistxattr(const char *path, char *list, size_t size);
+ssize_t flistxattr(int fd, char *list, size_t size);
+
+int removexattr(const char *path, const char *name);
+int lremovexattr(const char *path, const char *name);
+int fremovexattr(int fd, const char *name);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _MLIBC_LINUX_SYS_XATTR_H */
diff --git a/lib/mlibc/options/linux/include/utmp.h b/lib/mlibc/options/linux/include/utmp.h
new file mode 100644
index 0000000..e83d7a5
--- /dev/null
+++ b/lib/mlibc/options/linux/include/utmp.h
@@ -0,0 +1,84 @@
+#ifndef _UTMP_H
+#define _UTMP_H
+
+#include <abi-bits/pid_t.h>
+#include <bits/posix/timeval.h>
+#include <bits/types.h>
+#include <paths.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define EMPTY 0
+#define RUN_LVL 1
+#define BOOT_TIME 2
+#define NEW_TIME 3
+#define OLD_TIME 4
+#define INIT_PROCESS 5
+#define LOGIN_PROCESS 6
+#define USER_PROCESS 7
+#define DEAD_PROCESS 8
+#define ACCOUNTING 9
+
+#define UT_LINESIZE 32
+#define UT_NAMESIZE 32
+#define UT_HOSTSIZE 256
+
+#define WTMP_FILE _PATH_WTMP
+#define WTMP_FILENAME _PATH_WTMP
+
+#define UTMP_FILE _PATH_UTMP
+#define UTMP_FILENAME _PATH_UTMP
+
+struct exit_status {
+ short int e_termination;
+ short int e_exit;
+};
+
+struct utmp {
+ short ut_type;
+ pid_t ut_pid;
+ char ut_line[UT_LINESIZE];
+ char ut_id[4];
+ char ut_user[UT_NAMESIZE];
+ char ut_host[UT_HOSTSIZE];
+ struct exit_status ut_exit;
+ long ut_session;
+ struct timeval ut_tv;
+ __mlibc_int32 ut_addr_v6[4];
+ char __unused[20];
+};
+
+struct lastlog {
+ time_t ll_time;
+ char ll_line[UT_LINESIZE];
+ char ll_host[UT_HOSTSIZE];
+};
+
+/* Hacks for compability reasons */
+#define ut_name ut_user
+#ifndef _NO_UT_TIME
+#define ut_time ut_tv.tv_sec
+#endif
+#define ut_xtime ut_tv.tv_sec
+#define ut_addr ut_addr_v6[0]
+
+#ifndef __MLIBC_ABI_ONLY
+
+void setutent(void);
+struct utmp *getutent(void);
+int getutent_r(struct utmp *, struct utmp **);
+void endutent(void);
+struct utmp *pututline(const struct utmp *);
+struct utmp *getutline(const struct utmp *);
+struct utmp *getutid(const struct utmp *);
+int utmpname(const char *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _UTMP_H
diff --git a/lib/mlibc/options/linux/include/utmpx.h b/lib/mlibc/options/linux/include/utmpx.h
new file mode 100644
index 0000000..32629dd
--- /dev/null
+++ b/lib/mlibc/options/linux/include/utmpx.h
@@ -0,0 +1,68 @@
+
+#ifndef _UTMPX_H
+#define _UTMPX_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <abi-bits/pid_t.h>
+#include <bits/posix/timeval.h>
+
+// Struct definition taken from musl
+struct utmpx {
+ short ut_type;
+ short __ut_pad1;
+ pid_t ut_pid;
+ char ut_line[32];
+ char ut_id[4];
+ char ut_user[32];
+ char ut_host[256];
+ struct {
+ short __e_termination;
+ short __e_exit;
+ } ut_exit;
+ int ut_session, __ut_pad2;
+ struct timeval ut_tv;
+ unsigned ut_addr_v6[4];
+ char __unused[20];
+};
+
+#define e_exit __e_exit
+#define e_termination __e_termination
+
+#ifndef __MLIBC_ABI_ONLY
+
+void updwtmpx(const char *, const struct utmpx *);
+int utmpxname(const char *);
+struct utmpx *pututxline(const struct utmpx *);
+struct utmpx *getutxent(void);
+struct utmpx *getutxid(const struct utmpx *id);
+void setutxent(void);
+void endutxent(void);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#define EMPTY 0
+#define RUN_LVL 1
+#define BOOT_TIME 2
+#define NEW_TIME 3
+#define OLD_TIME 4
+#define INIT_PROCESS 5
+#define LOGIN_PROCESS 6
+#define USER_PROCESS 7
+#define DEAD_PROCESS 8
+
+#ifdef _GNU_SOURCE
+#define ACCOUNTING 9
+#endif
+
+#define __UT_HOSTSIZE 256
+#define __UT_NAMESIZE 32
+#define __UT_LINESIZE 32
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _UTMPX_H
diff --git a/lib/mlibc/options/linux/include/values.h b/lib/mlibc/options/linux/include/values.h
new file mode 100644
index 0000000..55a50cd
--- /dev/null
+++ b/lib/mlibc/options/linux/include/values.h
@@ -0,0 +1,39 @@
+
+#ifndef _VALUES_H
+#define _VALUES_H
+
+#include <limits.h>
+#include <float.h>
+
+#define CHARBITS (sizeof(char) * 8)
+#define SHORTBITS (sizeof(short) * 8)
+#define INTBITS (sizeof(int) * 8)
+#define LONGBITS (sizeof(long) * 8)
+#define PTRBITS (sizeof(char *) * 8)
+#define DOUBLEBITS (sizeof(double) * 8)
+#define FLOATBITS (sizeof(float) * 8)
+
+#define MINSHORT SHRT_MIN
+#define MININT INT_MIN
+#define MINLONG LONG_MIN
+
+#define MAXSHORT SHRT_MAX
+#define MAXINT INT_MAX
+#define MAXLONG LONG_MAX
+
+#define HIBITS MINSHORT
+#define HIBITL MINLONG
+
+#define MAXDOUBLE DBL_MAX
+#define MAXFLOAT FLT_MAX
+#define MINDOUBLE DBL_MIN
+#define MINFLOAT FLT_MIN
+#define DMINEXP DBL_MIN_EXP
+#define FMINEXP FLT_MIN_EXP
+#define DMAXEXP DBL_MAX_EXP
+#define FMAXEXP FLT_MAX_EXP
+
+#define BITSPERBYTE CHAR_BIT
+
+#endif // _VALUES_H
+