2019-06-23 21:54:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <mntent.h>
|
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
// Missing libc functions
|
|
|
|
#define getline compat_getline
|
|
|
|
#define getdelim compat_getdelim
|
|
|
|
#define getmntent_r compat_getmntent_r
|
|
|
|
#define setmntent compat_setmntent
|
|
|
|
#define endmntent compat_endmntent
|
|
|
|
#define hasmntopt compat_hasmntopt
|
2019-06-23 21:54:48 +00:00
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
// Missing syscall wrappers
|
|
|
|
#define setns compat_setns
|
|
|
|
#define unshare compat_unshare
|
|
|
|
#define accept4 compat_accept4
|
|
|
|
#define dup3 compat_dup3
|
|
|
|
#define readlinkat compat_readlinkat
|
|
|
|
#define symlinkat compat_symlinkat
|
|
|
|
#define linkat compat_linkat
|
|
|
|
#define inotify_init1 compat_inotify_init1
|
|
|
|
#define faccessat compat_faccessat
|
2019-06-23 21:54:48 +00:00
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream);
|
|
|
|
ssize_t compat_getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
|
|
|
|
struct mntent *compat_getmntent_r(FILE* fp, struct mntent* e, char* buf, int buf_len);
|
|
|
|
FILE *compat_setmntent(const char* path, const char* mode);
|
|
|
|
int compat_endmntent(FILE* fp);
|
|
|
|
char *compat_hasmntopt(const struct mntent* mnt, const char* opt);
|
|
|
|
|
|
|
|
static inline int compat_setns(int fd, int nstype) {
|
2020-12-31 06:11:24 +00:00
|
|
|
return syscall(__NR_setns, fd, nstype);
|
2019-06-23 21:54:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
static inline int compat_unshare(int flags) {
|
2020-12-31 06:11:24 +00:00
|
|
|
return syscall(__NR_unshare, flags);
|
2019-06-23 21:54:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
static inline int compat_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) {
|
2020-12-31 06:11:24 +00:00
|
|
|
return syscall(__NR_accept4, sockfd, addr, addrlen, flags);
|
2019-06-23 21:54:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
static inline int compat_dup3(int oldfd, int newfd, int flags) {
|
2020-12-31 06:11:24 +00:00
|
|
|
return syscall(__NR_dup3, oldfd, newfd, flags);
|
2019-06-24 08:21:33 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
static inline ssize_t compat_readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz) {
|
2020-12-31 06:11:24 +00:00
|
|
|
return syscall(__NR_readlinkat, dirfd, pathname, buf, bufsiz);
|
2019-06-23 21:54:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
static inline int compat_symlinkat(const char *target, int newdirfd, const char *linkpath) {
|
2020-12-31 06:11:24 +00:00
|
|
|
return syscall(__NR_symlinkat, target, newdirfd, linkpath);
|
2019-06-23 21:54:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
static inline int compat_linkat(int olddirfd, const char *oldpath,
|
2020-12-31 06:11:24 +00:00
|
|
|
int newdirfd, const char *newpath, int flags) {
|
|
|
|
return syscall(__NR_linkat, olddirfd, oldpath, newdirfd, newpath, flags);
|
2019-06-23 21:54:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
static inline int compat_inotify_init1(int flags) {
|
2020-12-31 06:11:24 +00:00
|
|
|
return syscall(__NR_inotify_init1, flags);
|
2019-06-23 21:54:48 +00:00
|
|
|
}
|
2020-04-02 09:17:45 +00:00
|
|
|
|
2020-11-03 09:12:33 +00:00
|
|
|
static inline int compat_faccessat(int dirfd, const char *pathname, int mode, int flags) {
|
2020-12-31 06:11:24 +00:00
|
|
|
return syscall(__NR_faccessat, dirfd, pathname, mode, flags);
|
2020-04-02 09:17:45 +00:00
|
|
|
}
|