user: implement mlibc as the libc, finally.
It's finally done.. Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#include <mlibc/debug.hpp>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int capset(void *, void *) {
|
||||
mlibc::infoLogger() << "mlibc: capset is a no-op!" << frg::endlog;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int capget(void *, void *) {
|
||||
mlibc::infoLogger() << "mlibc: capget is a no-op!" << frg::endlog;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
#include <limits.h>
|
||||
#include <sched.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
cpu_set_t *__mlibc_cpu_alloc(int num_cpus) {
|
||||
return reinterpret_cast<cpu_set_t *>(calloc(1, CPU_ALLOC_SIZE(num_cpus)));
|
||||
}
|
||||
|
||||
#define CPU_MASK_BITS (CHAR_BIT * sizeof(__cpu_mask))
|
||||
|
||||
size_t __mlibc_cpu_alloc_size(int num_cpus) {
|
||||
/* calculate the (unaligned) remainder that doesn't neatly fit in one __cpu_mask; 0 or 1 */
|
||||
size_t remainder = ((num_cpus % CPU_MASK_BITS) + CPU_MASK_BITS - 1) / CPU_MASK_BITS;
|
||||
return sizeof(__cpu_mask) * (num_cpus / CPU_MASK_BITS + remainder);
|
||||
}
|
||||
|
||||
void __mlibc_cpu_zero(const size_t setsize, cpu_set_t *set) {
|
||||
memset(set, 0, CPU_ALLOC_SIZE(setsize));
|
||||
}
|
||||
|
||||
void __mlibc_cpu_set(const int cpu, const size_t setsize, cpu_set_t *set) {
|
||||
if(cpu >= static_cast<int>(setsize * CHAR_BIT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *ptr = reinterpret_cast<unsigned char *>(set);
|
||||
size_t off = cpu / CHAR_BIT;
|
||||
size_t mask = 1 << (cpu % CHAR_BIT);
|
||||
|
||||
ptr[off] |= mask;
|
||||
}
|
||||
|
||||
void __mlibc_cpu_clear(const int cpu, const size_t setsize, cpu_set_t *set) {
|
||||
if(cpu >= static_cast<int>(setsize * CHAR_BIT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *ptr = reinterpret_cast<unsigned char *>(set);
|
||||
size_t off = cpu / CHAR_BIT;
|
||||
size_t mask = 1 << (cpu % CHAR_BIT);
|
||||
|
||||
ptr[off] &= ~mask;
|
||||
}
|
||||
|
||||
|
||||
int __mlibc_cpu_isset(const int cpu, const size_t setsize, const cpu_set_t *set) {
|
||||
if(cpu >= static_cast<int>(setsize * CHAR_BIT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const unsigned char *ptr = reinterpret_cast<const unsigned char *>(set);
|
||||
size_t off = cpu / CHAR_BIT;
|
||||
size_t mask = 1 << (cpu % CHAR_BIT);
|
||||
|
||||
return (ptr[off] & mask);
|
||||
}
|
||||
|
||||
int __mlibc_cpu_count(const size_t setsize, const cpu_set_t *set) {
|
||||
size_t count = 0;
|
||||
const unsigned char *ptr = reinterpret_cast<const unsigned char *>(set);
|
||||
|
||||
for(size_t i = 0; i < setsize; i++) {
|
||||
for(size_t bit = 0; bit < CHAR_BIT; bit++) {
|
||||
if((1 << bit) & ptr[i])
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <mlibc/allocator.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
#include <ifaddrs.h>
|
||||
#include <errno.h>
|
||||
|
||||
int getifaddrs(struct ifaddrs **ifap) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_getifaddrs, -1);
|
||||
if(int e = sysdep(ifap); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void freeifaddrs(struct ifaddrs *ifa) {
|
||||
while (ifa != nullptr) {
|
||||
ifaddrs *current = ifa;
|
||||
ifa = ifa->ifa_next;
|
||||
getAllocator().free(current);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#include <bits/linux/linux_unistd.h>
|
||||
#include <bits/ensure.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <mlibc/posix-sysdeps.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
#include <unistd.h>
|
||||
|
||||
int dup3(int oldfd, int newfd, int flags) {
|
||||
if(oldfd == newfd) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_dup2, -1);
|
||||
if(int e = mlibc::sys_dup2(oldfd, flags, newfd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return newfd;
|
||||
}
|
||||
|
||||
int vhangup(void) {
|
||||
__ensure(!"Not implemented");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
int getdtablesize(void){
|
||||
return sysconf(_SC_OPEN_MAX);
|
||||
}
|
||||
|
||||
int syncfs(int fd) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_syncfs, -1);
|
||||
if(int e = mlibc::sys_syncfs(fd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <bits/ensure.h>
|
||||
#include <malloc.h>
|
||||
|
||||
void *memalign(size_t, size_t) {
|
||||
__ensure(!"Not implemented");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <mntent.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <bits/ensure.h>
|
||||
|
||||
namespace {
|
||||
|
||||
char *internal_buf;
|
||||
size_t internal_bufsize;
|
||||
|
||||
} // namespace
|
||||
|
||||
#define SENTINEL (char *)&internal_buf
|
||||
|
||||
FILE *setmntent(const char *name, const char *mode) {
|
||||
return fopen(name, mode);
|
||||
}
|
||||
|
||||
struct mntent *getmntent(FILE *f) {
|
||||
static struct mntent mnt;
|
||||
return getmntent_r(f, &mnt, SENTINEL, 0);
|
||||
}
|
||||
|
||||
int addmntent(FILE *f, const struct mntent *mnt) {
|
||||
if(fseek(f, 0, SEEK_END)) {
|
||||
return 1;
|
||||
}
|
||||
return fprintf(f, "%s\t%s\t%s\t%s\t%d\t%d\n",
|
||||
mnt->mnt_fsname, mnt->mnt_dir, mnt->mnt_type, mnt->mnt_opts,
|
||||
mnt->mnt_freq, mnt->mnt_passno) < 0;
|
||||
}
|
||||
|
||||
int endmntent(FILE *f) {
|
||||
if(f) {
|
||||
fclose(f);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *hasmntopt(const struct mntent *mnt, const char *opt) {
|
||||
return strstr(mnt->mnt_opts, opt);
|
||||
}
|
||||
|
||||
/* Adapted from musl */
|
||||
struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int buflen) {
|
||||
int n[8];
|
||||
bool use_internal = (linebuf == SENTINEL);
|
||||
int len;
|
||||
size_t i;
|
||||
|
||||
mnt->mnt_freq = 0;
|
||||
mnt->mnt_passno = 0;
|
||||
|
||||
do {
|
||||
if(use_internal) {
|
||||
getline(&internal_buf, &internal_bufsize, f);
|
||||
linebuf = internal_buf;
|
||||
} else {
|
||||
fgets(linebuf, buflen, f);
|
||||
}
|
||||
if(feof(f) || ferror(f)) {
|
||||
return nullptr;
|
||||
}
|
||||
if(!strchr(linebuf, '\n')) {
|
||||
fscanf(f, "%*[^\n]%*[\n]");
|
||||
errno = ERANGE;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
len = strlen(linebuf);
|
||||
if(len > INT_MAX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(i = 0; i < sizeof n / sizeof *n; i++) {
|
||||
n[i] = len;
|
||||
}
|
||||
|
||||
sscanf(linebuf, " %n%*s%n %n%*s%n %n%*s%n %n%*s%n %d %d",
|
||||
n, n + 1, n + 2, n + 3, n + 4, n + 5, n + 6, n + 7,
|
||||
&mnt->mnt_freq, &mnt->mnt_passno);
|
||||
} while(linebuf[n[0]] == '#' || n[1] == len);
|
||||
|
||||
linebuf[n[1]] = 0;
|
||||
linebuf[n[3]] = 0;
|
||||
linebuf[n[5]] = 0;
|
||||
linebuf[n[7]] = 0;
|
||||
|
||||
mnt->mnt_fsname = linebuf + n[0];
|
||||
mnt->mnt_dir = linebuf + n[2];
|
||||
mnt->mnt_type = linebuf + n[4];
|
||||
mnt->mnt_opts = linebuf + n[6];
|
||||
|
||||
return mnt;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <errno.h>
|
||||
#include <module.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int init_module(void *module, unsigned long length, const char *args) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_init_module, -1);
|
||||
if(int e = mlibc::sys_init_module(module, length, args); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int delete_module(const char *name, unsigned flags) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_delete_module, -1);
|
||||
if(int e = mlibc::sys_delete_module(name, flags); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <bits/ensure.h>
|
||||
#include <errno.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
#include <mlibc/posix-sysdeps.hpp>
|
||||
|
||||
int sched_getcpu(void) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_getcpu, -1);
|
||||
int cpu;
|
||||
if(int e = mlibc::sys_getcpu(&cpu); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return cpu;
|
||||
}
|
||||
|
||||
int setns(int fd, int nstype) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_setns, -1);
|
||||
if(int e = mlibc::sys_setns(fd, nstype); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sched_getscheduler(pid_t pid) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_getscheduler, -1);
|
||||
int policy;
|
||||
if(int e = mlibc::sys_getscheduler(pid, &policy); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return policy;
|
||||
}
|
||||
|
||||
int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_getaffinity, -1);
|
||||
if(int e = mlibc::sys_getaffinity(pid, cpusetsize, mask); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unshare(int flags) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_unshare, -1);
|
||||
if(int e = mlibc::sys_unshare(flags); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sched_setaffinity(pid_t, size_t, const cpu_set_t *) {
|
||||
__ensure(!"Not implemented");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
int clone(int (*)(void *), void *, int, void *, ...) {
|
||||
__ensure(!"Not implemented");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
#include <stddef.h>
|
||||
|
||||
int epoll_create(int) {
|
||||
int fd;
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_epoll_create, -1);
|
||||
if(int e = mlibc::sys_epoll_create(0, &fd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int epoll_pwait(int epfd, struct epoll_event *evnts, int n, int timeout,
|
||||
const sigset_t *sigmask) {
|
||||
int raised;
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_epoll_pwait, -1);
|
||||
if(int e = mlibc::sys_epoll_pwait(epfd, evnts, n, timeout, sigmask, &raised)) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return raised;
|
||||
}
|
||||
|
||||
int epoll_create1(int flags) {
|
||||
int fd;
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_epoll_create, -1);
|
||||
if(int e = mlibc::sys_epoll_create(flags, &fd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int epoll_ctl(int epfd, int mode, int fd, struct epoll_event *ev) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_epoll_ctl, -1);
|
||||
if(int e = mlibc::sys_epoll_ctl(epfd, mode, fd, ev); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int epoll_wait(int epfd, struct epoll_event *evnts, int n, int timeout) {
|
||||
int raised;
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_epoll_pwait, -1);
|
||||
if(int e = mlibc::sys_epoll_pwait(epfd, evnts, n, timeout, nullptr, &raised)) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return raised;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include <sys/eventfd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int eventfd(unsigned int initval, int flags) {
|
||||
int fd = 0;
|
||||
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_eventfd_create, -1);
|
||||
if (int e = mlibc::sys_eventfd_create(initval, flags, &fd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int eventfd_read(int fd, eventfd_t *value) {
|
||||
ssize_t bytes_read;
|
||||
if (int e = mlibc::sys_read(fd, value, 8, &bytes_read); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bytes_read != 8) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int eventfd_write(int fd, eventfd_t value) {
|
||||
ssize_t bytes_written;
|
||||
if (int e = mlibc::sys_write(fd, &value, 8, &bytes_written); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bytes_written != 8) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <bits/ensure.h>
|
||||
#include <sys/fsuid.h>
|
||||
|
||||
int setfsuid(uid_t) {
|
||||
__ensure(!"Not implemented");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
int setfsgid(gid_t) {
|
||||
__ensure(!"Not implemented");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/inotify.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int inotify_init(void) {
|
||||
int fd;
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_inotify_create, -1);
|
||||
if(int e = mlibc::sys_inotify_create(0, &fd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int inotify_init1(int flags) {
|
||||
int fd;
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_inotify_create, -1);
|
||||
if(int e = mlibc::sys_inotify_create(flags, &fd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int inotify_add_watch(int ifd, const char *path, uint32_t mask) {
|
||||
int wd;
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_inotify_add_watch, -1);
|
||||
if(int e = mlibc::sys_inotify_add_watch(ifd, path, mask, &wd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return wd;
|
||||
}
|
||||
|
||||
int inotify_rm_watch(int ifd, int wd) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_inotify_rm_watch, -1);
|
||||
if(int e = mlibc::sys_inotify_rm_watch(ifd, wd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <errno.h>
|
||||
#include <sys/klog.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int klogctl(int type, char *bufp, int len) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_klogctl, -1);
|
||||
int out;
|
||||
if (int e = mlibc::sys_klogctl(type, bufp, len, &out); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int mount(const char *source, const char *target,
|
||||
const char *fstype, unsigned long flags, const void *data) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_mount, -1);
|
||||
if(int e = mlibc::sys_mount(source, target, fstype, flags, data); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int umount(const char *target) {
|
||||
return umount2(target, 0);
|
||||
}
|
||||
|
||||
int umount2(const char *target, int flags) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_umount2, -1);
|
||||
if(int e = mlibc::sys_umount2(target, flags); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include <bits/ensure.h>
|
||||
#include <errno.h>
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
#include <sys/pidfd.h>
|
||||
|
||||
int pidfd_open(pid_t pid, unsigned int flags) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_pidfd_open, -1);
|
||||
int fd = 0;
|
||||
|
||||
if(int e = sysdep(pid, flags, &fd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
pid_t pidfd_getpid(int fd) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_pidfd_getpid, -1);
|
||||
pid_t pid = 0;
|
||||
|
||||
if(int e = sysdep(fd, &pid); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
int pidfd_send_signal(int pidfd, int sig, siginfo_t *info, unsigned int flags) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_pidfd_send_signal, -1);
|
||||
|
||||
if(int e = sysdep(pidfd, sig, info, flags); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <bits/ensure.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include <mlibc/debug.hpp>
|
||||
|
||||
#include "mlibc/linux-sysdeps.hpp"
|
||||
|
||||
int prctl(int op, ...) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_prctl, -1);
|
||||
|
||||
int val;
|
||||
va_list ap;
|
||||
va_start(ap, op);
|
||||
if(int e = mlibc::sys_prctl(op, ap, &val); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
#include <sys/ptrace.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
long ptrace(int req, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, req);
|
||||
auto pid = va_arg(ap, pid_t);
|
||||
auto addr = va_arg(ap, void *);
|
||||
auto data = va_arg(ap, void *);
|
||||
va_end(ap);
|
||||
|
||||
long ret;
|
||||
if(req > 0 && req < 4) {
|
||||
data = &ret;
|
||||
}
|
||||
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_ptrace, -1);
|
||||
long out;
|
||||
if(int e = mlibc::sys_ptrace(req, pid, addr, data, &out); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
} else if(req > 0 && req < 4) {
|
||||
errno = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <bits/ensure.h>
|
||||
#include <sys/quota.h>
|
||||
|
||||
int quotactl(int, const char *, int, caddr_t) {
|
||||
__ensure(!"Not implemented");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
#include <sys/random.h>
|
||||
#include <bits/ensure.h>
|
||||
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/posix-sysdeps.hpp>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
ssize_t getrandom(void *buffer, size_t max_size, unsigned int flags) {
|
||||
if(flags & ~(GRND_RANDOM | GRND_NONBLOCK)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_getentropy, -1);
|
||||
if(int e = mlibc::sys_getentropy(buffer, max_size); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return max_size;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <errno.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int reboot(int what) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_reboot, -1);
|
||||
if (int e = mlibc::sys_reboot(what); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <errno.h>
|
||||
#include <sys/sendfile.h>
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
ssize_t sendfile(int outfd, int infd, off_t *offset, size_t size) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_sendfile, -1);
|
||||
ssize_t out;
|
||||
if(int e = mlibc::sys_sendfile(outfd, infd, offset, size, &out); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/signalfd.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int signalfd(int fd, const sigset_t *mask, int flags) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_signalfd_create, -1);
|
||||
if(int e = mlibc::sys_signalfd_create(mask, flags, &fd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/statfs.h>
|
||||
#include <bits/ensure.h>
|
||||
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int statfs(const char *path, struct statfs *buf) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_statfs, -1);
|
||||
if(int e = mlibc::sys_statfs(path, buf); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fstatfs(int fd, struct statfs *buf) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_fstatfs, -1);
|
||||
if (int e = mlibc::sys_fstatfs(fd, buf); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
[[gnu::alias("fstatfs")]] int fstatfs64(int, struct statfs64 *);
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <bits/ensure.h>
|
||||
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/posix-sysdeps.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int statx(int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf) {
|
||||
if(!mlibc::sys_statx) {
|
||||
struct stat statbuf;
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_stat, -1);
|
||||
|
||||
if (!(flags & AT_NO_AUTOMOUNT)) {
|
||||
mlibc::infoLogger()
|
||||
<< "mlibc: sys_statx is unavailable, and stat does not support not specifying AT_NO_MOUNTPOINT"
|
||||
<< frg::endlog;
|
||||
}
|
||||
|
||||
// AT_STATX_SYNC_AS_STAT is the default and behaves like good old stat
|
||||
if ((flags & AT_STATX_FORCE_SYNC) || (flags & AT_STATX_DONT_SYNC)) {
|
||||
mlibc::infoLogger()
|
||||
<< "mlibc: sys_statx is unavailable, and stat does not support modes other than AT_STATX_SYNC_AS_STAT"
|
||||
<< frg::endlog;
|
||||
}
|
||||
|
||||
// Mask out flags not appropriate for regular stat
|
||||
flags &= ~(AT_NO_AUTOMOUNT | AT_STATX_SYNC_AS_STAT | AT_STATX_FORCE_SYNC | AT_STATX_DONT_SYNC);
|
||||
|
||||
if(int e = mlibc::sys_stat(mlibc::fsfd_target::fd_path, dirfd, pathname, flags, &statbuf); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(statxbuf, 0, sizeof(struct statx));
|
||||
statxbuf->stx_blksize = statbuf.st_blksize;
|
||||
statxbuf->stx_blocks = statbuf.st_blocks;
|
||||
statxbuf->stx_gid = statbuf.st_gid;
|
||||
statxbuf->stx_ino = statbuf.st_ino;
|
||||
statxbuf->stx_mode = statbuf.st_mode;
|
||||
statxbuf->stx_nlink = statbuf.st_nlink;
|
||||
statxbuf->stx_size = statbuf.st_size;
|
||||
statxbuf->stx_uid = statbuf.st_uid;
|
||||
|
||||
statxbuf->stx_atime.tv_sec = statbuf.st_atim.tv_sec;
|
||||
statxbuf->stx_atime.tv_nsec = statbuf.st_atim.tv_nsec;
|
||||
statxbuf->stx_btime.tv_sec = statbuf.st_mtim.tv_sec;
|
||||
statxbuf->stx_btime.tv_nsec = statbuf.st_mtim.tv_nsec;
|
||||
statxbuf->stx_ctime.tv_sec = statbuf.st_ctim.tv_sec;
|
||||
statxbuf->stx_ctime.tv_nsec = statbuf.st_ctim.tv_nsec;
|
||||
statxbuf->stx_mtime.tv_sec = statbuf.st_mtim.tv_sec;
|
||||
statxbuf->stx_mtime.tv_nsec = statbuf.st_mtim.tv_nsec;
|
||||
|
||||
statxbuf->stx_rdev_major = major(statbuf.st_rdev);
|
||||
statxbuf->stx_rdev_minor = minor(statbuf.st_rdev);
|
||||
statxbuf->stx_dev_major = major(statbuf.st_dev);
|
||||
statxbuf->stx_dev_minor = minor(statbuf.st_dev);
|
||||
statxbuf->stx_mask = STATX_BASIC_STATS | STATX_BTIME;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_statx, -1);
|
||||
if(int e = sysdep(dirfd, pathname, flags, mask, statxbuf); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <errno.h>
|
||||
#include <sys/swap.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int swapon(const char *path, int flags) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_swapon, -1);
|
||||
if(int e = mlibc::sys_swapon(path, flags); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int swapoff(const char *path) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_swapoff, -1);
|
||||
if(int e = mlibc::sys_swapoff(path); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <errno.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
#include <unistd.h>
|
||||
|
||||
int sysinfo(struct sysinfo *info) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_sysinfo, -1);
|
||||
if(int e = mlibc::sys_sysinfo(info); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_nprocs(void) {
|
||||
return sysconf(_SC_NPROCESSORS_ONLN);
|
||||
}
|
||||
|
||||
int get_nprocs_conf(void) {
|
||||
return sysconf(_SC_NPROCESSORS_CONF);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
int timerfd_create(int clockid, int flags) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_timerfd_create, -1);
|
||||
int fd;
|
||||
if(int e = mlibc::sys_timerfd_create(clockid, flags, &fd); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int timerfd_settime(int fd, int flags, const struct itimerspec *value,
|
||||
struct itimerspec *oldvalue) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_timerfd_settime, -1);
|
||||
if(int e = mlibc::sys_timerfd_settime(fd, flags, value, oldvalue); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int timerfd_gettime(int fd, struct itimerspec *its) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_timerfd_gettime, -1);
|
||||
if(int e = sysdep(fd, its); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <errno.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
|
||||
ssize_t process_vm_readv(pid_t pid,
|
||||
const struct iovec *local_iov, unsigned long liovcnt,
|
||||
const struct iovec *remote_iov, unsigned long riovcnt,
|
||||
unsigned long flags) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_process_vm_readv, -1);
|
||||
ssize_t bytes_read;
|
||||
if(int e = mlibc::sys_process_vm_readv(pid, local_iov, liovcnt,
|
||||
remote_iov, riovcnt, flags, &bytes_read); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
ssize_t process_vm_writev(pid_t pid,
|
||||
const struct iovec *local_iov, unsigned long liovcnt,
|
||||
const struct iovec *remote_iov, unsigned long riovcnt,
|
||||
unsigned long flags) {
|
||||
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_process_vm_writev, -1);
|
||||
ssize_t bytes_written;
|
||||
if(int e = mlibc::sys_process_vm_writev(pid, local_iov, liovcnt,
|
||||
remote_iov, riovcnt, flags, &bytes_written); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return bytes_written;
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
#include <errno.h>
|
||||
#include <sys/xattr.h>
|
||||
|
||||
#include <mlibc/linux-sysdeps.hpp>
|
||||
#include <bits/ensure.h>
|
||||
|
||||
int setxattr(const char *path, const char *name, const void *val, size_t size,
|
||||
int flags) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_setxattr, -1);
|
||||
|
||||
if (int e = sysdep(path, name, val, size, flags); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lsetxattr(const char *path, const char *name, const void *val, size_t size,
|
||||
int flags) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_lsetxattr, -1);
|
||||
|
||||
if (int e = sysdep(path, name, val, size, flags); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fsetxattr(int fd, const char *name, const void *val, size_t size,
|
||||
int flags) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_fsetxattr, -1);
|
||||
|
||||
if (int e = sysdep(fd, name, val, size, flags); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t getxattr(const char *path, const char *name, void *val, size_t size) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_getxattr, -1);
|
||||
|
||||
ssize_t nread;
|
||||
if (int e = sysdep(path, name, val, size, &nread); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return nread;
|
||||
}
|
||||
|
||||
ssize_t lgetxattr(const char *path, const char *name, void *val, size_t size) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_lgetxattr, -1);
|
||||
|
||||
ssize_t nread;
|
||||
if (int e = sysdep(path, name, val, size, &nread); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return nread;
|
||||
}
|
||||
|
||||
ssize_t fgetxattr(int fd, const char *name, void *val, size_t size) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_fgetxattr, -1);
|
||||
|
||||
ssize_t nread;
|
||||
if (int e = sysdep(fd, name, val, size, &nread); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return nread;
|
||||
}
|
||||
|
||||
int removexattr(const char *path, const char *name) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_removexattr, -1);
|
||||
return sysdep(path, name);
|
||||
}
|
||||
|
||||
int lremovexattr(const char *path, const char *name) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_lremovexattr, -1);
|
||||
return sysdep(path, name);
|
||||
}
|
||||
|
||||
int fremovexattr(int fd, const char *name) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_fremovexattr, -1);
|
||||
return sysdep(fd, name);
|
||||
}
|
||||
|
||||
ssize_t listxattr(const char *path, char *list, size_t size) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_listxattr, -1);
|
||||
|
||||
ssize_t nread;
|
||||
if (int e = sysdep(path, list, size, &nread); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return nread;
|
||||
}
|
||||
|
||||
ssize_t llistxattr(const char *path, char *list, size_t size) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_llistxattr, -1);
|
||||
|
||||
ssize_t nread;
|
||||
if (int e = sysdep(path, list, size, &nread); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return nread;
|
||||
}
|
||||
|
||||
ssize_t flistxattr(int fd, char *list, size_t size) {
|
||||
auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_flistxattr, -1);
|
||||
|
||||
ssize_t nread;
|
||||
if (int e = sysdep(fd, list, size, &nread); e) {
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
return nread;
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <utmp.h>
|
||||
|
||||
#include <bits/ensure.h>
|
||||
#include <frg/mutex.hpp>
|
||||
#include <frg/spinlock.hpp>
|
||||
#include <mlibc/debug.hpp>
|
||||
#include <mlibc/utmp.hpp>
|
||||
#include <mlibc/posix-sysdeps.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr const char *defaultUtmpPath = UTMP_FILE;
|
||||
|
||||
const char *utmpPath = defaultUtmpPath;
|
||||
frg::ticket_spinlock utmpMutex;
|
||||
|
||||
frg::optional<int> utmpFd = frg::null_opt;
|
||||
|
||||
utmp returned;
|
||||
|
||||
} // namespace
|
||||
|
||||
void setutent(void) {
|
||||
frg::unique_lock lock{utmpMutex};
|
||||
|
||||
if(!utmpFd) {
|
||||
int fd;
|
||||
int err = mlibc::sys_open(utmpPath, O_RDWR | O_CREAT | O_CLOEXEC, 0644, &fd);
|
||||
if(err) {
|
||||
mlibc::infoLogger() << "\e[31mmlibc: setutent() failed to open " << utmpPath << ": "
|
||||
<< strerror(err) << "\e[39m" << frg::endlog;
|
||||
utmpFd = frg::null_opt;
|
||||
} else {
|
||||
utmpFd = fd;
|
||||
}
|
||||
} else {
|
||||
off_t discard;
|
||||
mlibc::sys_seek(utmpFd.value(), 0, SEEK_SET, &discard);
|
||||
}
|
||||
}
|
||||
|
||||
struct utmp *getutent(void) {
|
||||
frg::unique_lock lock{utmpMutex};
|
||||
|
||||
if(!utmpFd)
|
||||
setutent();
|
||||
if(!utmpFd) {
|
||||
errno = ENOENT;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(int e = mlibc::getUtmpEntry(*utmpFd, &returned); e) {
|
||||
errno = e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &returned;
|
||||
}
|
||||
|
||||
int getutent_r(struct utmp *buf, struct utmp **res) {
|
||||
frg::unique_lock lock{utmpMutex};
|
||||
|
||||
if(!utmpFd)
|
||||
setutent();
|
||||
if(!utmpFd) {
|
||||
*res = nullptr;
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(int e = mlibc::getUtmpEntry(*utmpFd, buf); e) {
|
||||
*res = nullptr;
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*res = buf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void endutent(void) {
|
||||
frg::unique_lock lock{utmpMutex};
|
||||
|
||||
if(utmpFd) {
|
||||
mlibc::sys_close(utmpFd.value());
|
||||
utmpFd = frg::null_opt;
|
||||
}
|
||||
}
|
||||
|
||||
struct utmp *pututline(const struct utmp *ut) {
|
||||
frg::unique_lock lock{utmpMutex};
|
||||
|
||||
if(!utmpFd)
|
||||
setutent();
|
||||
if(!utmpFd) {
|
||||
errno = ENOENT;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(int e = mlibc::putUtmpEntry(*utmpFd, ut); e) {
|
||||
errno = e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (utmp *) ut;
|
||||
}
|
||||
|
||||
struct utmp *getutline(const struct utmp *ut) {
|
||||
frg::unique_lock lock{utmpMutex};
|
||||
|
||||
if(!utmpFd)
|
||||
setutent();
|
||||
if(!utmpFd) {
|
||||
errno = ENOENT;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(int e = mlibc::getUtmpEntryByType(*utmpFd, ut, &returned); e) {
|
||||
errno = e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &returned;
|
||||
}
|
||||
|
||||
int utmpname(const char *file) {
|
||||
frg::unique_lock lock{utmpMutex};
|
||||
|
||||
if(strcmp(file, utmpPath)) {
|
||||
if(!strcmp(file, defaultUtmpPath)) {
|
||||
free((void *) utmpPath);
|
||||
utmpPath = defaultUtmpPath;
|
||||
} else {
|
||||
char *name = strdup(file);
|
||||
if(!name)
|
||||
return -1;
|
||||
|
||||
if(utmpPath != defaultUtmpPath)
|
||||
free((void *) utmpPath);
|
||||
|
||||
utmpPath = name;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct utmp *getutid(const struct utmp *ut) {
|
||||
frg::unique_lock lock{utmpMutex};
|
||||
|
||||
if(!utmpFd)
|
||||
setutent();
|
||||
if(!utmpFd) {
|
||||
errno = ENOENT;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(int e = mlibc::getUtmpEntryById(*utmpFd, ut, &returned); e) {
|
||||
errno = e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &returned;
|
||||
}
|
||||
|
||||
void updwtmp(const char *file, const struct utmp *ut) {
|
||||
int fd;
|
||||
int err = mlibc::sys_open(file, O_RDWR | O_CREAT | O_CLOEXEC | O_APPEND, 0644, &fd);
|
||||
if(err) {
|
||||
mlibc::infoLogger() << "\e[31mmlibc: updwtmp() failed to open " << file << ": "
|
||||
<< strerror(err) << "\e[39m" << frg::endlog;
|
||||
return;
|
||||
}
|
||||
|
||||
mlibc::putUtmpEntry(fd, ut);
|
||||
mlibc::sys_close(fd);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#ifndef _BITS_LINUX_CPU_SET_H
|
||||
#define _BITS_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 /* _BITS_LINUX_CPU_SET_H */
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
#ifndef _BITS_LINUX_SCHED_H
|
||||
#define _BITS_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_PIDFD 0x00001000
|
||||
#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
|
||||
|
||||
#define CLONE_CLEAR_SIGHAND 0x100000000ULL
|
||||
#define CLONE_INTO_CGROUP 0x200000000ULL
|
||||
|
||||
#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 /* _BITS_LINUX_SCHED_H */
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef _BITS_LINUX_STAT_H
|
||||
#define _BITS_LINUX_STAT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <abi-bits/statx.h>
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int statx(int __dirfd, const char *__pathname, int __flags, unsigned int __mask, struct statx *__statxbuf);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BITS_LINUX_STAT_H */
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef _BITS_LINUX_UIO_H
|
||||
#define _BITS_LINUX_UIO_H
|
||||
|
||||
#include <abi-bits/pid_t.h>
|
||||
#include <bits/posix/iovec.h>
|
||||
#include <bits/ssize_t.h>
|
||||
#include <mlibc-config.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
ssize_t process_vm_readv(pid_t pid,
|
||||
const struct iovec *local_iov, unsigned long liovcnt,
|
||||
const struct iovec *remote_iov, unsigned long riovcnt,
|
||||
unsigned long flags);
|
||||
ssize_t process_vm_writev(pid_t pid,
|
||||
const struct iovec *local_iov, unsigned long liovcnt,
|
||||
const struct iovec *remote_iov, unsigned long riovcnt,
|
||||
unsigned long flags);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BITS_LINUX_UIO_H */
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef _BITS_LINUX_UNISTD_H
|
||||
#define _BITS_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 /* _BITS_LINUX_UNISTD_H */
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef _BITS_LINUX_UTMP_H
|
||||
#define _BITS_LINUX_UTMP_H
|
||||
|
||||
#include <abi-bits/pid_t.h>
|
||||
#include <abi-bits/utmp-defines.h>
|
||||
#include <bits/posix/timeval.h>
|
||||
#include <bits/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UT_LINESIZE 32
|
||||
#define UT_NAMESIZE 32
|
||||
#define UT_HOSTSIZE 256
|
||||
|
||||
#define UTMP_FILENAME UTMP_FILE
|
||||
#define WTMP_FILENAME WTMP_FILE
|
||||
|
||||
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 *__buf, struct utmp **__res);
|
||||
void endutent(void);
|
||||
struct utmp *pututline(const struct utmp *__line);
|
||||
struct utmp *getutline(const struct utmp *__line);
|
||||
struct utmp *getutid(const struct utmp *__id);
|
||||
int utmpname(const char *__file);
|
||||
void updwtmp(const char *wtmp_file, const struct utmp *ut);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BITS_LINUX_UTMP_H */
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#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;
|
||||
/* the man page (and glibc) place `ifa_broadaddr` and `ifa_dstaddr` in a union */
|
||||
/* TODO: decide whether we should do it, too */
|
||||
struct sockaddr *ifa_broadaddr;
|
||||
struct sockaddr *ifa_dstaddr;
|
||||
void *ifa_data;
|
||||
};
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int getifaddrs(struct ifaddrs **__ifap);
|
||||
void freeifaddrs(struct ifaddrs *__ifa);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _IFADDRS_H */
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Maches glibc */
|
||||
#include <utmp.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 __alignment, size_t __size);
|
||||
|
||||
#if __MLIBC_GLIBC_OPTION
|
||||
#include <bits/glibc/glibc_malloc.h>
|
||||
#endif
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MALLOC_H */
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
#ifndef _MEMORY_H
|
||||
#define _MEMORY_H
|
||||
|
||||
/* This is a linux extension */
|
||||
#include <string.h>
|
||||
|
||||
#endif /* _MEMORY_H */
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
#ifndef MLIBC_LINUX_SYSDEPS
|
||||
#define MLIBC_LINUX_SYSDEPS
|
||||
|
||||
#include <ifaddrs.h>
|
||||
#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 <abi-bits/statx.h>
|
||||
#include <bits/off_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_ppoll(struct pollfd *fds, nfds_t count, const struct timespec *ts,
|
||||
const sigset_t *mask, int *num_events);
|
||||
[[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_timerfd_gettime(int fd, struct itimerspec *its);
|
||||
[[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);
|
||||
|
||||
[[gnu::weak]] int sys_statx(int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf);
|
||||
|
||||
[[gnu::weak]] int sys_getifaddrs(struct ifaddrs **);
|
||||
|
||||
[[gnu::weak]] int sys_sendfile(int outfd, int infd, off_t *offset, size_t count, ssize_t *out);
|
||||
[[gnu::weak]] int sys_syncfs(int fd);
|
||||
[[gnu::weak]] int sys_unshare(int flags);
|
||||
[[gnu::weak]] int sys_setns(int fd, int nstype);
|
||||
|
||||
[[gnu::weak]] int sys_pidfd_open(pid_t pid, unsigned int flags, int *outfd);
|
||||
[[gnu::weak]] int sys_pidfd_getpid(int fd, pid_t *outpid);
|
||||
[[gnu::weak]] int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info, unsigned int flags);
|
||||
|
||||
[[gnu::weak]] int sys_process_vm_readv(pid_t pid,
|
||||
const struct iovec *local_iov, unsigned long liovcnt,
|
||||
const struct iovec *remote_iov, unsigned long riovcnt,
|
||||
unsigned long flags, ssize_t *out);
|
||||
[[gnu::weak]] int sys_process_vm_writev(pid_t pid,
|
||||
const struct iovec *local_iov, unsigned long liovcnt,
|
||||
const struct iovec *remote_iov, unsigned long riovcnt,
|
||||
unsigned long flags, ssize_t *out);
|
||||
|
||||
} // namespace mlibc
|
||||
|
||||
#endif // MLIBX_LINUX_SYSDEPS
|
||||
@@ -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 *__filename, const char *__type);
|
||||
|
||||
struct mntent *getmntent(FILE *__f);
|
||||
|
||||
int addmntent(FILE *__f, const struct mntent *__mnt);
|
||||
|
||||
int endmntent(FILE *__f);
|
||||
|
||||
char *hasmntopt(const struct mntent *__mnt, const char *__opt);
|
||||
|
||||
struct mntent *getmntent_r(FILE *__f, struct mntent *__mnt, char *__linebuf, int __buflen);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MNTENT_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 */
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
#ifndef _LINUX_SCSI_SCSI_IOCTL_H
|
||||
#define _LINUX_SCSI_SCSI_IOCTL_H
|
||||
|
||||
#endif /* _LINUX_SCSI_SCSI_IOCTL_H */
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
|
||||
#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)
|
||||
|
||||
#define SG_INFO_CHECK 0x1
|
||||
|
||||
#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 */
|
||||
|
||||
@@ -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 __flags);
|
||||
int epoll_create1(int __flags);
|
||||
int epoll_ctl(int __epfd, int __mode, int __fd, struct epoll_event *__ev);
|
||||
int epoll_wait(int __epfd, struct epoll_event *__events, int __maxevents, int __timeout);
|
||||
int epoll_pwait(int __epfd, struct epoll_event *__events, int __maxevents, int __timeout, const sigset_t *__sigmask);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_EPOLL_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 __initval, int __flags);
|
||||
int eventfd_read(int __fd, eventfd_t *__value);
|
||||
int eventfd_write(int __fd, eventfd_t __value);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_EVENTFD_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 */
|
||||
@@ -0,0 +1,71 @@
|
||||
#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;
|
||||
|
||||
/*
|
||||
* glibc uses a flexible array member here, but we get a warning and they don't:
|
||||
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117241
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
char name[];
|
||||
#pragma GCC diagnostic pop
|
||||
};
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int inotify_init(void);
|
||||
int inotify_init1(int __flags);
|
||||
int inotify_add_watch(int __ifd, const char *__path, uint32_t __mask);
|
||||
int inotify_rm_watch(int __ifd, int __wd);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_SYS_INOTIFY_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 */
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifndef _SYS_MOUNT_H
|
||||
#define _SYS_MOUNT_H
|
||||
|
||||
#include <sys/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 */
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef _SYS_PIDFD_H
|
||||
#define _SYS_PIDFD_H
|
||||
|
||||
#include <abi-bits/fcntl.h>
|
||||
#include <abi-bits/pid_t.h>
|
||||
#include <abi-bits/signal.h>
|
||||
|
||||
#define PIDFD_NONBLOCK O_NONBLOCK
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int pidfd_open(pid_t __pid, unsigned int __flags);
|
||||
pid_t pidfd_getpid(int __fd);
|
||||
int pidfd_send_signal(int __pidfd, int __sig, siginfo_t *__info, unsigned int __flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#endif /* _SYS_PIDFD_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 __op, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#endif /* _SYS_PRCTL_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 __op, ...);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_PTRACE_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 */
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef _SYS_RANDOM_H
|
||||
#define _SYS_RANDOM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <abi-bits/random.h>
|
||||
#include <bits/ssize_t.h>
|
||||
#include <bits/size_t.h>
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
ssize_t getrandom(void *__buffer, size_t __max_size, unsigned int __flags);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_SYS_RANDOM_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 */
|
||||
@@ -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 __out_fd, int __in_fd, off_t *__offset, size_t __size);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_SENDFILE_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 __fd, const sigset_t *__mask, int __flags);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_SIGNALFD_H */
|
||||
@@ -0,0 +1,23 @@
|
||||
#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 *__path, struct statfs *__buf);
|
||||
int fstatfs(int __fd, struct statfs *__buf);
|
||||
int fstatfs64(int __fd, struct statfs64 *__buf);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_STATFS_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 *__path, int __flags);
|
||||
int swapoff(const char *__path);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_SWAP_H */
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef _SYS_SYSINFO_H
|
||||
#define _SYS_SYSINFO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* TODO: This is from the Linux ABI. Make this an abi-bit. */
|
||||
|
||||
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;
|
||||
|
||||
/* This is how the kernel header defines it, so suppress the warning. */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
char _f[20 - 2 * sizeof(long) - sizeof(int)]; /* Padding to 64 bytes according to my man page */
|
||||
#pragma GCC diagnostic pop
|
||||
};
|
||||
|
||||
#define SI_LOAD_SHIFT 16
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int sysinfo(struct sysinfo *__info);
|
||||
|
||||
int get_nprocs(void);
|
||||
int get_nprocs_conf(void);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_SYSINFO_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 */
|
||||
@@ -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 __clockid, int __flags);
|
||||
int timerfd_settime(int __fd, int __flags, const struct itimerspec *__value, struct itimerspec *__oldvalue);
|
||||
int timerfd_gettime(int __fd, struct itimerspec *__value);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_TIMERFD_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 */
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef _SYS_VT_H
|
||||
#define _SYS_VT_H
|
||||
|
||||
#include <abi-bits/vt.h>
|
||||
|
||||
#endif /* _SYS_VT_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 */
|
||||
@@ -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 */
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
|
||||
if not linux_option
|
||||
subdir_done()
|
||||
endif
|
||||
libc_sources += files(
|
||||
'generic/mntent.cpp',
|
||||
'generic/sys-epoll.cpp',
|
||||
'generic/sys-inotify.cpp',
|
||||
'generic/sys-mount.cpp',
|
||||
'generic/sys-prctl.cpp',
|
||||
'generic/sys-ptrace.cpp',
|
||||
'generic/sys-random.cpp',
|
||||
'generic/sys-sendfile.cpp',
|
||||
'generic/sys-signalfd.cpp',
|
||||
'generic/sys-timerfd.cpp',
|
||||
'generic/sys-uio.cpp',
|
||||
'generic/sys-eventfd.cpp',
|
||||
'generic/sys-reboot.cpp',
|
||||
'generic/sys-xattr.cpp',
|
||||
'generic/utmp.cpp',
|
||||
'generic/linux-unistd.cpp',
|
||||
'generic/malloc.cpp',
|
||||
'generic/sys-fsuid.cpp',
|
||||
'generic/ifaddrs.cpp',
|
||||
'generic/sys-sysinfo.cpp',
|
||||
'generic/module.cpp',
|
||||
'generic/sys-klog.cpp',
|
||||
'generic/sched.cpp',
|
||||
'generic/sys-quota.cpp',
|
||||
'generic/capabilities.cpp',
|
||||
'generic/cpuset.cpp',
|
||||
'generic/sys-swap.cpp',
|
||||
'generic/sys-statfs.cpp',
|
||||
'generic/sys-statx.cpp',
|
||||
'generic/sys-pidfd.cpp',
|
||||
)
|
||||
|
||||
if not no_headers
|
||||
install_headers(
|
||||
'include/ifaddrs.h',
|
||||
'include/malloc.h',
|
||||
'include/memory.h',
|
||||
'include/mntent.h',
|
||||
'include/values.h',
|
||||
'include/lastlog.h',
|
||||
'include/module.h',
|
||||
)
|
||||
install_headers(
|
||||
'include/bits/linux/linux_unistd.h',
|
||||
'include/bits/linux/linux_sched.h',
|
||||
'include/bits/linux/linux_stat.h',
|
||||
'include/bits/linux/linux_uio.h',
|
||||
'include/bits/linux/linux_utmp.h',
|
||||
'include/bits/linux/cpu_set.h',
|
||||
subdir: 'bits/linux'
|
||||
)
|
||||
install_headers(
|
||||
'include/netpacket/packet.h',
|
||||
subdir: 'netpacket'
|
||||
)
|
||||
# libc provides these, not the kernel, so the Linux option shall provide them too.
|
||||
install_headers(
|
||||
'include/scsi/scsi.h',
|
||||
'include/scsi/scsi_ioctl.h',
|
||||
'include/scsi/sg.h',
|
||||
subdir: 'scsi'
|
||||
)
|
||||
install_headers(
|
||||
'include/sys/epoll.h',
|
||||
'include/sys/inotify.h',
|
||||
'include/sys/mount.h',
|
||||
'include/sys/prctl.h',
|
||||
'include/sys/ptrace.h',
|
||||
'include/sys/random.h',
|
||||
'include/sys/sendfile.h',
|
||||
'include/sys/signalfd.h',
|
||||
'include/sys/sysmacros.h',
|
||||
'include/sys/timerfd.h',
|
||||
'include/sys/eventfd.h',
|
||||
'include/sys/reboot.h',
|
||||
'include/sys/fsuid.h',
|
||||
'include/sys/vt.h',
|
||||
'include/sys/sysinfo.h',
|
||||
'include/sys/klog.h',
|
||||
'include/sys/xattr.h',
|
||||
'include/sys/quota.h',
|
||||
'include/sys/swap.h',
|
||||
'include/sys/statfs.h',
|
||||
'include/sys/vfs.h',
|
||||
'include/sys/pidfd.h',
|
||||
subdir: 'sys'
|
||||
)
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user