Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/compat/linux/linux_fork.h
39507 views
1
/*-
2
* SPDX-License-Identifier: BSD-2-Clause
3
*
4
* Copyright (c) 2021 Dmitry Chagin <[email protected]>
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
* SUCH DAMAGE.
26
*/
27
28
#ifndef _LINUX_FORK_H_
29
#define _LINUX_FORK_H_
30
31
#define LINUX_CLONE_VM 0x00000100
32
#define LINUX_CLONE_FS 0x00000200
33
#define LINUX_CLONE_FILES 0x00000400
34
#define LINUX_CLONE_SIGHAND 0x00000800
35
#define LINUX_CLONE_PIDFD 0x00001000 /* since Linux 5.2 */
36
#define LINUX_CLONE_PTRACE 0x00002000
37
#define LINUX_CLONE_VFORK 0x00004000
38
#define LINUX_CLONE_PARENT 0x00008000
39
#define LINUX_CLONE_THREAD 0x00010000
40
#define LINUX_CLONE_NEWNS 0x00020000 /* New mount NS */
41
#define LINUX_CLONE_SYSVSEM 0x00040000
42
#define LINUX_CLONE_SETTLS 0x00080000
43
#define LINUX_CLONE_PARENT_SETTID 0x00100000
44
#define LINUX_CLONE_CHILD_CLEARTID 0x00200000
45
#define LINUX_CLONE_DETACHED 0x00400000 /* Unused */
46
#define LINUX_CLONE_UNTRACED 0x00800000
47
#define LINUX_CLONE_CHILD_SETTID 0x01000000
48
#define LINUX_CLONE_NEWCGROUP 0x02000000 /* New cgroup NS */
49
#define LINUX_CLONE_NEWUTS 0x04000000
50
#define LINUX_CLONE_NEWIPC 0x08000000
51
#define LINUX_CLONE_NEWUSER 0x10000000
52
#define LINUX_CLONE_NEWPID 0x20000000
53
#define LINUX_CLONE_NEWNET 0x40000000
54
#define LINUX_CLONE_IO 0x80000000
55
56
/* Flags for the clone3() syscall. */
57
#define LINUX_CLONE_CLEAR_SIGHAND 0x100000000ULL
58
#define LINUX_CLONE_INTO_CGROUP 0x200000000ULL
59
#define LINUX_CLONE_NEWTIME 0x00000080
60
61
#define LINUX_CLONE_LEGACY_FLAGS 0xffffffffULL
62
63
#define LINUX_CSIGNAL 0x000000ff
64
65
#if defined(_KERNEL)
66
/*
67
* User-space clone3 args layout.
68
*/
69
struct l_user_clone_args {
70
uint64_t flags;
71
uint64_t pidfd;
72
uint64_t child_tid;
73
uint64_t parent_tid;
74
uint64_t exit_signal;
75
uint64_t stack;
76
uint64_t stack_size;
77
uint64_t tls;
78
uint64_t set_tid;
79
uint64_t set_tid_size;
80
uint64_t cgroup;
81
};
82
83
/*
84
* Kernel clone3 args layout.
85
*/
86
struct l_clone_args {
87
uint64_t flags;
88
l_int *child_tid;
89
l_int *parent_tid;
90
l_int exit_signal;
91
l_ulong stack;
92
l_ulong stack_size;
93
l_ulong tls;
94
};
95
96
#define LINUX_CLONE_ARGS_SIZE_VER0 64
97
98
int linux_set_upcall(struct thread *, register_t);
99
int linux_set_cloned_tls(struct thread *, void *);
100
void linux_thread_detach(struct thread *);
101
#endif /* defined(_KERNEL) */
102
103
#endif /* _LINUX_FORK_H_ */
104
105