0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <assert.h>
0017 #include <unistd.h>
0018 #include <stdlib.h>
0019 #include <errno.h>
0020 #include <linux/mount.h>
0021 #include <linux/unistd.h>
0022
0023 static inline int fsopen(const char *fsname, unsigned int flags)
0024 {
0025 return syscall(__NR_fsopen, fsname, flags);
0026 }
0027
0028 static inline int fsconfig(int fd, unsigned int cmd, const char *key, const void *val, int aux)
0029 {
0030 return syscall(__NR_fsconfig, fd, cmd, key, val, aux);
0031 }
0032
0033 int main(void)
0034 {
0035 int fsfd, ret;
0036 int hidepid = 2;
0037
0038 assert((fsfd = fsopen("proc", 0)) != -1);
0039
0040 ret = fsconfig(fsfd, FSCONFIG_SET_BINARY, "hidepid", &hidepid, 0);
0041 assert(ret == -1);
0042 assert(errno == EINVAL);
0043
0044 assert(!fsconfig(fsfd, FSCONFIG_SET_STRING, "hidepid", "2", 0));
0045 assert(!fsconfig(fsfd, FSCONFIG_SET_STRING, "hidepid", "invisible", 0));
0046
0047 assert(!close(fsfd));
0048
0049 return 0;
0050 }