-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
75 lines (62 loc) · 1.95 KB
/
Copy pathcommon.h
File metadata and controls
75 lines (62 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef SYSCALLS_H
#define SYSCALLS_H
#define _GNU_SOURCE
#include <fcntl.h>
#include <linux/mount.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/syscall.h>
#include <stdarg.h>
#include <libgen.h>
#define FSOPEN_CLOEXEC 0x00000001
static inline int open_tree(int dfd, const char *pathname, unsigned int flags) {
return syscall(__NR_open_tree, dfd, pathname, flags);
}
static inline int fspick(int dfd, const char *pathname, unsigned int flags) {
return syscall(__NR_fspick, dfd, pathname, flags);
}
static inline int fsopen(const char *fsname, unsigned int flags) {
return syscall(__NR_fsopen, fsname, flags);
}
static inline int fsconfig(int fsfd, unsigned int cmd,
const char *key, const char *value,
int aux) {
return syscall(__NR_fsconfig, fsfd, cmd, key, value, aux);
}
static inline int fsmount(int fsfd, unsigned int flags, unsigned int ms_flags) {
return syscall(__NR_fsmount, fsfd, flags, ms_flags);
}
static inline int move_mount(int from_dfd, const char *from_pathname,
int to_dfd, const char *to_pathname,
unsigned int flags) {
return syscall(__NR_move_mount, from_dfd, from_pathname,
to_dfd, to_pathname, flags);
}
void printpid() {
printf("The PID of this process is %u\n", getpid());
}
void wait(const char * s, ...) {
va_list argptr;
va_start(argptr, s);
vfprintf(stderr, s, argptr);
va_end(argptr);
while(getchar() != '\n');
}
void addcurpath(char *s) {
char ret[255];
char exe_path[255];
char *dir_path;
ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1);
if (len == -1) {
perror("readlink failed");
return;
}
exe_path[len] = '\0';
dir_path = dirname(exe_path);
snprintf(ret, sizeof(ret), "%s/%s", dir_path, s);
strcpy(s, ret);
}
#endif