| /linux/tools/testing/selftests/pidfd/ |
| H A D | pidfd_file_handle_test.c | 28 int pidfd; in FIXTURE() local 47 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 48 ASSERT_GE(self->pidfd, 0); in FIXTURE_SETUP() 119 EXPECT_EQ(close(self->pidfd), 0); in FIXTURE_TEARDOWN() 148 int pidfd = -EBADF; in TEST_F() local 160 pidfd = open_by_handle_at(self->pidfd, fh, 0); in TEST_F() 161 ASSERT_GE(pidfd, 0); in TEST_F() 163 ASSERT_EQ(fstat(pidfd, &st2), 0); in TEST_F() 166 ASSERT_EQ(close(pidfd), 0); in TEST_F() 168 pidfd = open_by_handle_at(self->pidfd, fh, O_CLOEXEC); in TEST_F() [all …]
|
| H A D | pidfd_wait.c | 31 int pidfd = -1; in TEST() local 35 .pidfd = ptr_to_u64(&pidfd), in TEST() 44 pidfd = open("/proc/self", O_DIRECTORY | O_RDONLY | O_CLOEXEC); in TEST() 45 ASSERT_GE(pidfd, 0); in TEST() 47 pid = sys_waitid(P_PIDFD, pidfd, &info, WEXITED); in TEST() 49 EXPECT_EQ(close(pidfd), 0); in TEST() 50 pidfd = -1; in TEST() 52 pidfd = open("/dev/null", O_RDONLY | O_CLOEXEC); in TEST() 53 ASSERT_GE(pidfd, 0); in TEST() 55 pid = sys_waitid(P_PIDFD, pidfd, &info, WEXITED); in TEST() [all …]
|
| H A D | pidfd_test.c | 33 static pid_t pidfd_clone(int flags, int *pidfd, int (*fn)(void *)) in pidfd_clone() argument 39 return __clone2(fn, stack, stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 41 return clone(fn, stack + stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 53 static int send_signal(int pidfd) in send_signal() argument 57 if (sys_pidfd_send_signal(pidfd, SIGUSR1, NULL, 0) < 0) { in send_signal() 74 int pidfd = (int)(intptr_t)arg; in send_signal_worker() local 78 ret = send_signal(pidfd); in send_signal_worker() 88 int pidfd; in test_pidfd_send_signal_simple_success() local 104 pidfd = open("/proc/self", O_DIRECTORY | O_CLOEXEC); in test_pidfd_send_signal_simple_success() 105 if (pidfd < 0) in test_pidfd_send_signal_simple_success() [all …]
|
| H A D | pidfd_bind_mount.c | 23 int pidfd; in FIXTURE() local 39 self->pidfd = sys_pidfd_open(getpid(), 0); in FIXTURE_SETUP() 40 ASSERT_GE(self->pidfd, 0); in FIXTURE_SETUP() 41 ASSERT_GE(fstat(self->pidfd, &self->st1), 0); in FIXTURE_SETUP() 42 ASSERT_EQ(ioctl(self->pidfd, FS_IOC_GETVERSION, &self->gen1), 0); in FIXTURE_SETUP() 61 fd_tree = sys_open_tree(self->pidfd, "", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC | AT_EMPTY_PATH); in TEST_F() 73 int pidfd; in TEST_F() local 76 sprintf(proc_path, "/proc/self/fd/%d", self->pidfd); in TEST_F() 77 pidfd = open(proc_path, O_RDONLY | O_NOCTTY | O_CLOEXEC); in TEST_F() 78 ASSERT_GE(pidfd, 0); in TEST_F() [all …]
|
| H A D | pidfd_open_test.c | 87 static pid_t get_pid_from_fdinfo_file(int pidfd, const char *key, size_t keylen) in get_pid_from_fdinfo_file() argument 96 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", pidfd); in get_pid_from_fdinfo_file() 127 int pidfd = -1, ret = 1; in main() local 132 pidfd = sys_pidfd_open(-1, 0); in main() 133 if (pidfd >= 0) { in main() 141 pidfd = sys_pidfd_open(getpid(), 1); in main() 142 if (pidfd >= 0) { in main() 150 pidfd = sys_pidfd_open(getpid(), 0); in main() 151 if (pidfd < 0) { in main() 157 pid = get_pid_from_fdinfo_file(pidfd, "Pid:", sizeof("Pid:") - 1); in main() [all …]
|
| H A D | pidfd_poll_test.c | 48 int pidfd; in main() local 68 pidfd = sys_pidfd_open(child_pid, 0); in main() 69 if (pidfd < 0) in main() 80 if (sys_pidfd_send_signal(pidfd, SIGKILL, NULL, 0)) in main() 85 fds.fd = pidfd; in main() 106 close(pidfd); in main()
|
| H A D | pidfd_getfd_test.c | 127 int pidfd; in FIXTURE() local 157 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 158 ASSERT_GE(self->pidfd, 0); in FIXTURE_SETUP() 172 EXPECT_EQ(0, close(self->pidfd)); in FIXTURE_TEARDOWN() 198 fd = sys_pidfd_getfd(self->pidfd, self->remote_fd, 0); in TEST_F() 210 fd = sys_pidfd_getfd(self->pidfd, self->remote_fd, 0); in TEST_F() 229 fd = sys_pidfd_getfd(self->pidfd, UNKNOWN_FD, 0); in TEST_F() 250 fds.fd = self->pidfd; in TEST_F() 263 EXPECT_EQ(sys_pidfd_getfd(self->pidfd, self->remote_fd, 0), -1); in TEST_F()
|
| H A D | pidfd.h | 275 static inline int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info, in create_child() 278 return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags); in create_child() 281 static inline int sys_pidfd_getfd(int pidfd, int fd, int flags) in read_nointr() 283 return syscall(__NR_pidfd_getfd, pidfd, fd, flags); in read_nointr() 291 static inline pid_t create_child(int *pidfd, unsigned flags) 296 .pidfd = ptr_to_u64(pidfd), in write_nointr() 254 sys_pidfd_send_signal(int pidfd,int sig,siginfo_t * info,unsigned int flags) sys_pidfd_send_signal() argument 260 sys_pidfd_getfd(int pidfd,int fd,int flags) sys_pidfd_getfd() argument 270 create_child(int * pidfd,unsigned flags) create_child() argument
|
| H A D | pidfd_fdinfo_test.c | 165 static int verify_fdinfo(int pidfd, struct error *err, const char *prefix, in verify_fdinfo() argument 182 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", pidfd); in verify_fdinfo() 186 pidfd); in verify_fdinfo() 212 prefix, pidfd); in verify_fdinfo() 220 int pidfd; in child_fdinfo_nspid_test() local 244 pidfd = *(int *)args; in child_fdinfo_nspid_test() 245 r = verify_fdinfo(pidfd, &err, "NSpid:", 6, "\t0\n"); in child_fdinfo_nspid_test()
|
| H A D | pidfd_info_test.c | 23 #include "pidfd.h" 266 * Opening a PIDFD_THREAD aka thread-specific pidfd based on a in TEST_F() 277 * leader to exit using a thread-specific pidfd. The in TEST_F() 311 * Note that pidfd_leader is a thread-group pidfd, so polling on it in TEST_F() 317 /* Get PIDFD_GET_INFO using the thread-group leader pidfd. */ in TEST_F() 325 * Now retrieve the same info using the thread specific pidfd in TEST_F() 335 /* Now try the thread-specific pidfd. */ in TEST_F() 360 * thread-group leader pidfd. in TEST_F() 372 * thread-specific pidfd. in TEST_F() 443 /* Open a thread-specific pidfd fo in TEST_F() 704 int pidfd; TEST() local 744 int pidfd; TEST() local [all...] |
| H A D | pidfd_setns_test.c | 57 int pidfd; in FIXTURE() local 112 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 113 EXPECT_GT(self->pidfd, 0) { in FIXTURE_SETUP() 127 self->child_pidfd_derived_nsfds[i] = ioctl(self->pidfd, info->pidfd_ioctl, 0); in FIXTURE_SETUP() 150 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 151 EXPECT_GE(self->pidfd, 0) { in FIXTURE_SETUP() 399 ASSERT_NE(setns(self->pidfd, 0), 0); in TEST_F() 402 ASSERT_NE(setns(self->pidfd, -1), 0); in TEST_F() 405 ASSERT_NE(setns(self->pidfd, CLONE_VM), 0); in TEST_F() 408 ASSERT_NE(setns(self->pidfd, CLONE_NEWUSER | CLONE_VM), 0); in TEST_F()
|
| /linux/samples/pidfd/ |
| H A D | pidfd-metadata.c | 34 static pid_t pidfd_clone(int flags, int *pidfd) in pidfd_clone() argument 40 return __clone2(do_child, stack, stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 42 return clone(do_child, stack + stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 46 static inline int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info, in sys_pidfd_send_signal() argument 49 return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags); in sys_pidfd_send_signal() 52 static int pidfd_metadata_fd(pid_t pid, int pidfd) in pidfd_metadata_fd() argument 68 ret = sys_pidfd_send_signal(pidfd, 0, NULL, 0); in pidfd_metadata_fd() 86 int pidfd = -1, ret = EXIT_FAILURE; in main() local 92 pid = pidfd_clone(CLONE_PIDFD, &pidfd); in main() 95 if (pidfd == -1) { in main() [all …]
|
| /linux/tools/testing/selftests/namespaces/ |
| H A D | regression_pidfd_setns_test.c | 35 int pidfd = -1; in TEST() local 46 child_pid = create_child(&pidfd, 0); in TEST() 66 ASSERT_GE(pidfd, 0); in TEST() 74 ret = setns(pidfd, CLONE_NEWUTS | CLONE_NEWIPC); in TEST() 76 close(pidfd); in TEST() 88 int pidfd = -1; in TEST() local 95 child_pid = create_child(&pidfd, CLONE_NEWUSER | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWNET); in TEST() 105 ASSERT_GE(pidfd, 0); in TEST() 108 ret = setns(pidfd, CLONE_NEWUTS | CLONE_NEWIPC); in TEST() 109 close(pidfd); in TEST()
|
| /linux/tools/testing/selftests/mm/ |
| H A D | mrelease_test.c | 51 static void run_negative_tests(int pidfd) in run_negative_tests() argument 54 if (!syscall(__NR_process_mrelease, pidfd, (unsigned int)-1) || in run_negative_tests() 62 if (!syscall(__NR_process_mrelease, pidfd, 0) || errno != EINVAL) in run_negative_tests() 79 int pipefd[2], pidfd; in main() local 89 /* Test a wrong pidfd */ in main() 95 ksft_exit_fail_msg("process_mrelease with wrong pidfd: %s", in main() 137 pidfd = syscall(__NR_pidfd_open, pid, 0); in main() 138 if (pidfd < 0) { in main() 145 run_negative_tests(pidfd); in main() 150 success = (syscall(__NR_process_mrelease, pidfd, in main() [all...] |
| H A D | process_madv.c | 18 #include "../pidfd/pidfd.h" 25 int pidfd; in FIXTURE() local 31 self->pidfd = PIDFD_SELF; in FIXTURE_SETUP() 48 static ssize_t sys_process_madvise(int pidfd, const struct iovec *iovec, in sys_process_madvise() argument 51 return syscall(__NR_process_madvise, pidfd, iovec, vlen, advice, flags); in sys_process_madvise() 65 int pidfd = self->pidfd; in TEST_F() local 94 ret = sys_process_madvise(pidfd, vec, madvise_pages, MADV_DONTNEED, 0); in TEST_F() 211 * Test process_madvise() with a pidfd fo 291 int pidfd = self->pidfd; TEST_F() local 321 int pidfd = self->pidfd; TEST_F() local [all...] |
| /linux/tools/testing/selftests/coredump/ |
| H A D | coredump_socket_test.c | 80 int pidfd, ret, status; in TEST_F() local 192 pidfd = sys_pidfd_open(pid, 0); in TEST_F() 193 ASSERT_GE(pidfd, 0); in TEST_F() 199 ASSERT_TRUE(get_pidfd_info(pidfd, &info)); in TEST_F() 211 int pidfd, ret, status; in TEST_F() local 321 pidfd = sys_pidfd_open(pid, 0); in TEST_F() 322 ASSERT_GE(pidfd, 0); in TEST_F() 324 ASSERT_TRUE(get_pidfd_info(pidfd, &info)); in TEST_F() 330 ASSERT_EQ(sys_pidfd_send_signal(pidfd, SIGKILL, NULL, 0), 0); in TEST_F() 331 ASSERT_EQ(close(pidfd), 0); in TEST_F() [all …]
|
| H A D | coredump_socket_protocol_test.c | 82 int pidfd, ret, status; in TEST_F() local 217 pidfd = sys_pidfd_open(pid, 0); in TEST_F() 218 ASSERT_GE(pidfd, 0); in TEST_F() 224 ASSERT_TRUE(get_pidfd_info(pidfd, &info)); in TEST_F() 237 int pidfd, ret, status; in TEST_F() local 359 pidfd = sys_pidfd_open(pid, 0); in TEST_F() 360 ASSERT_GE(pidfd, 0); in TEST_F() 366 ASSERT_TRUE(get_pidfd_info(pidfd, &info)); in TEST_F() 375 int pidfd, ret, status; in TEST_F() local 497 pidfd = sys_pidfd_open(pid, 0); in TEST_F() [all …]
|
| /linux/tools/testing/selftests/net/af_unix/ |
| H A D | scm_pidfd.c | 110 static pid_t get_pid_from_fdinfo_file(int pidfd, const char *key, size_t keylen) in get_pid_from_fdinfo_file() argument 119 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", pidfd); in get_pid_from_fdinfo_file() 147 int *pidfd; member 163 if (cmsg->cmsg_len < sizeof(*res->pidfd)) { in parse_cmsg() 168 res->pidfd = (void *)CMSG_DATA(cmsg); in parse_cmsg() 182 if (!res->pidfd) { in parse_cmsg() 238 get_pid_from_fdinfo_file(*res.pidfd, "Pid:", sizeof("Pid:") - 1); in cmsg_check() 241 close(*res.pidfd); in cmsg_check() 245 close(*res.pidfd); in cmsg_check() 297 if (ioctl(*res.pidfd, PIDFD_GET_INFO, &info)) { in cmsg_check_dead() [all …]
|
| /linux/tools/testing/selftests/filesystems/overlayfs/ |
| H A D | set_layers_via_fds.c | 16 #include "../../pidfd/pidfd.h" 22 int pidfd; in FIXTURE() local 27 self->pidfd = -EBADF; in FIXTURE_SETUP() 34 if (self->pidfd >= 0) { in FIXTURE_TEARDOWN() 35 EXPECT_EQ(sys_pidfd_send_signal(self->pidfd, SIGKILL, NULL, 0), 0); in FIXTURE_TEARDOWN() 36 EXPECT_EQ(close(self->pidfd), 0); in FIXTURE_TEARDOWN() 236 int pidfd; in TEST_F() local 281 pid = create_child(&pidfd, 0); in TEST_F() 292 ASSERT_GE(close(pidfd), in TEST_F() 455 int pidfd; TEST_F() local [all...] |
| /linux/samples/vfs/ |
| H A D | mountinfo.c | 214 int pidfd, mntns, ret, opt; in main() local 236 pidfd = syscall(__NR_pidfd_open, pid, 0); in main() 237 if (pidfd < 0) { in main() 243 mntns = ioctl(pidfd, PIDFD_GET_MNT_NAMESPACE, NULL); in main() 248 close(pidfd); in main()
|
| /linux/kernel/ |
| H A D | pid.c | 622 struct task_struct *pidfd_get_task(int pidfd, unsigned int *flags) in pidfd_get_task() argument 629 switch (pidfd) { in pidfd_get_task() 639 pid = pidfd_get_pid(pidfd, &f_flags); in pidfd_get_task() 673 int pidfd; in pidfd_create() local 676 pidfd = pidfd_prepare(pid, flags, &pidfd_file); in pidfd_create() 677 if (pidfd < 0) in pidfd_create() 678 return pidfd; in pidfd_create() 680 fd_install(pidfd, pidfd_file); in pidfd_create() 681 return pidfd; in pidfd_create() 927 SYSCALL_DEFINE3(pidfd_getfd, int, pidfd, int, fd, in SYSCALL_DEFINE3() argument [all …]
|
| /linux/tools/testing/selftests/filesystems/mount_cycle/ |
| H A D | unmounted_tree_test.c | 196 static int bind_pidfd(int pidfd, const char *target) in bind_pidfd() argument 200 tfd = sys_open_tree(pidfd, "", AT_EMPTY_PATH | OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC); in bind_pidfd() 212 int pidfd, fd, tfd; in TEST_F() local 219 pidfd = sys_pidfd_open(getpid(), 0); in TEST_F() 220 ASSERT_GE(pidfd, 0); in TEST_F() 221 ASSERT_EQ(bind_pidfd(pidfd, x), 0); in TEST_F() 230 ASSERT_EQ(bind_pidfd(pidfd, y), 0); in TEST_F() 234 close(pidfd); in TEST_F()
|
| H A D | mount_cover_test.c | 246 int to_parent[2], to_child[2], fds[4], pidfd, status; in FIXTURE_SETUP() local 301 pidfd = syscall(__NR_pidfd_open, self->child, 0); in FIXTURE_SETUP() 302 ASSERT_GE(pidfd, 0) in FIXTURE_SETUP() 304 self->dfd = syscall(__NR_pidfd_getfd, pidfd, fds[0], 0); in FIXTURE_SETUP() 305 self->cfd = syscall(__NR_pidfd_getfd, pidfd, fds[1], 0); in FIXTURE_SETUP() 306 self->tfd = syscall(__NR_pidfd_getfd, pidfd, fds[2], 0); in FIXTURE_SETUP() 307 self->ufd = syscall(__NR_pidfd_getfd, pidfd, fds[3], 0); in FIXTURE_SETUP() 308 close(pidfd); in FIXTURE_SETUP()
|
| /linux/tools/testing/selftests/pid_namespace/ |
| H A D | Makefile | 6 LOCAL_HDRS += $(selfdir)/pidfd/pidfd.h
|
| /linux/tools/testing/selftests/cgroup/ |
| H A D | Makefile | 21 LOCAL_HDRS += $(selfdir)/clone3/clone3_selftests.h $(selfdir)/pidfd/pidfd.h
|