• Home
  • Raw
  • Download

Lines Matching +full:include +full:- +full:pid

1 // SPDX-License-Identifier: GPL-2.0-or-later
15 * NOTE: FAN_REPORT_PIDFD support was added in v5.15-rc1 in af579beb666a
20 #include <stdio.h>
21 #include <ctype.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include "tst_test.h"
25 #include "tst_safe_stdio.h"
26 #include "lapi/pidfd_open.h"
29 #include "fanotify.h"
39 int pid; member
72 SAFE_FILE_LINES_SCANF(fdinfo_path, "pos: %d", &pidfd_fdinfo->pos); in read_pidfd_fdinfo()
73 SAFE_FILE_LINES_SCANF(fdinfo_path, "flags: %d", &pidfd_fdinfo->flags); in read_pidfd_fdinfo()
74 SAFE_FILE_LINES_SCANF(fdinfo_path, "mnt_id: %d", &pidfd_fdinfo->mnt_id); in read_pidfd_fdinfo()
75 SAFE_FILE_LINES_SCANF(fdinfo_path, "Pid: %d", &pidfd_fdinfo->pid); in read_pidfd_fdinfo()
76 SAFE_FILE_LINES_SCANF(fdinfo_path, "NSpid: %d", &pidfd_fdinfo->ns_pid); in read_pidfd_fdinfo()
147 tst_res(TINFO, "Test #%d: %s", num, tc->name); in do_test()
154 if (tc->fork) in do_test()
176 if (info->hdr.info_type != FAN_EVENT_INFO_TYPE_PIDFD) { in do_test()
181 info->hdr.info_type); in do_test()
184 } else if (info->hdr.len != in do_test()
190 info->hdr.len); in do_test()
199 if (info->pidfd < 0 && !tc->want_pidfd_err) { in do_test()
201 "pidfd creation failed for pid: %u with pidfd error value " in do_test()
203 (unsigned int)event->pid, in do_test()
204 info->pidfd); in do_test()
206 } else if (tc->want_pidfd_err && in do_test()
207 info->pidfd != tc->want_pidfd_err) { in do_test()
209 "pidfd set to an unexpected error: %d for pid: %u", in do_test()
210 info->pidfd, in do_test()
211 (unsigned int)event->pid); in do_test()
213 } else if (tc->want_pidfd_err && in do_test()
214 info->pidfd == tc->want_pidfd_err) { in do_test()
216 "pid: %u terminated before pidfd was created, " in do_test()
218 (unsigned int)event->pid, in do_test()
227 event_pidfd_fdinfo = read_pidfd_fdinfo(info->pidfd); in do_test()
231 "describing pid: %u failed", in do_test()
232 info->pidfd, in do_test()
233 (unsigned int)event->pid); in do_test()
235 } else if (event_pidfd_fdinfo->pid != event->pid) { in do_test()
237 "pidfd provided for incorrect pid " in do_test()
238 "(expected pidfd for pid: %u, got pidfd for " in do_test()
239 "pid: %u)", in do_test()
240 (unsigned int)event->pid, in do_test()
241 (unsigned int)event_pidfd_fdinfo->pid); in do_test()
248 "pid: %d, ns_pid: %d, got pos: %d, " in do_test()
249 "flags: %x, mnt_id: %d, pid: %d, ns_pid: %d", in do_test()
250 self_pidfd_fdinfo->pos, in do_test()
251 self_pidfd_fdinfo->flags, in do_test()
252 self_pidfd_fdinfo->mnt_id, in do_test()
253 self_pidfd_fdinfo->pid, in do_test()
254 self_pidfd_fdinfo->ns_pid, in do_test()
255 event_pidfd_fdinfo->pos, in do_test()
256 event_pidfd_fdinfo->flags, in do_test()
257 event_pidfd_fdinfo->mnt_id, in do_test()
258 event_pidfd_fdinfo->pid, in do_test()
259 event_pidfd_fdinfo->ns_pid); in do_test()
264 "mask: %lld, pid: %u, fd: %d, " in do_test()
266 (unsigned long long)event->mask, in do_test()
267 (unsigned int)event->pid, in do_test()
268 event->fd, in do_test()
269 info->pidfd, in do_test()
270 info->hdr.info_type, in do_test()
271 info->hdr.len); in do_test()
275 i += event->event_len; in do_test()
276 if (event->fd >= 0) in do_test()
277 SAFE_CLOSE(event->fd); in do_test()
279 if (info && info->pidfd >= 0) in do_test()
280 SAFE_CLOSE(info->pidfd); in do_test()