1 /*
2 * Test PID namespace translation
3 *
4 * Copyright (c) 2020 Ákos Uzonyi <uzonyi.akos@gmail.com>
5 * Copyright (c) 2020-2022 The strace developers.
6 * All rights reserved.
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10 #ifndef STRACE_PIDNS_H
11 # define STRACE_PIDNS_H
12
13 # ifdef PIDNS_TRANSLATION
14 # define PIDNS_TEST_INIT pidns_test_init()
15 # else
16 # define PIDNS_TEST_INIT
17 # endif
18
19 # include <sys/types.h>
20
21 enum pid_type {
22 PT_TID,
23 PT_TGID,
24 PT_PGID,
25 PT_SID,
26
27 PT_COUNT,
28 PT_NONE = -1
29 };
30
31 /* Prints leader (process tid) if pidns_test_init was called */
32 void pidns_print_leader(void);
33
34 /*
35 * Returns a static buffer containing the translation string of our PID.
36 */
37 const char *pidns_pid2str(enum pid_type type);
38
39 /**
40 * Skips the test if NS_* ioctl commands are not supported by the kernel.
41 */
42 void check_ns_ioctl(void);
43
44 /**
45 * Init pidns testing.
46 *
47 * Should be called at the beginning of the test's main function
48 *
49 * This function calls fork a couple of times, and returns in the child
50 * processes. These child processes are in a new PID namespace with different
51 * PID configurations (group leader, session leader, ...). If any child
52 * terminates with nonzero exit status the test is failed. Otherwise the test is
53 * successful, and the parent process exits with 0.
54 */
55 void pidns_test_init(void);
56
57 #endif