]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _LINUX__INIT_TASK_H |
2 | #define _LINUX__INIT_TASK_H | |
3 | ||
ab2af1f5 | 4 | #include <linux/rcupdate.h> |
de30a2b3 | 5 | #include <linux/irqflags.h> |
4865ecf1 | 6 | #include <linux/utsname.h> |
fbb9ce95 | 7 | #include <linux/lockdep.h> |
5ac9f622 | 8 | #include <linux/ftrace.h> |
73ea4130 | 9 | #include <linux/ipc.h> |
9a575a92 | 10 | #include <linux/pid_namespace.h> |
acce292c | 11 | #include <linux/user_namespace.h> |
3898b1b4 | 12 | #include <linux/securebits.h> |
772698f6 | 13 | #include <net/net_namespace.h> |
1da177e4 | 14 | |
f52111b1 | 15 | extern struct files_struct init_files; |
18d8fda7 | 16 | extern struct fs_struct init_fs; |
1da177e4 | 17 | |
1da177e4 LT |
18 | #define INIT_MM(name) \ |
19 | { \ | |
20 | .mm_rb = RB_ROOT, \ | |
21 | .pgd = swapper_pg_dir, \ | |
22 | .mm_users = ATOMIC_INIT(2), \ | |
23 | .mm_count = ATOMIC_INIT(1), \ | |
24 | .mmap_sem = __RWSEM_INITIALIZER(name.mmap_sem), \ | |
e4d91918 | 25 | .page_table_lock = __SPIN_LOCK_UNLOCKED(name.page_table_lock), \ |
1da177e4 LT |
26 | .mmlist = LIST_HEAD_INIT(name.mmlist), \ |
27 | .cpu_vm_mask = CPU_MASK_ALL, \ | |
1da177e4 LT |
28 | } |
29 | ||
1ec320af CLG |
30 | #define INIT_SIGNALS(sig) { \ |
31 | .count = ATOMIC_INIT(1), \ | |
1da177e4 | 32 | .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\ |
1ec320af | 33 | .shared_pending = { \ |
1da177e4 | 34 | .list = LIST_HEAD_INIT(sig.shared_pending.list), \ |
1ec320af | 35 | .signal = {{0}}}, \ |
1da177e4 LT |
36 | .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ |
37 | .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ | |
38 | .rlim = INIT_RLIMITS, \ | |
4cd4c1b4 PZ |
39 | .cputimer = { \ |
40 | .cputime = INIT_CPUTIME, \ | |
41 | .running = 0, \ | |
42 | .lock = __SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \ | |
43 | }, \ | |
1da177e4 LT |
44 | } |
45 | ||
ab516013 SH |
46 | extern struct nsproxy init_nsproxy; |
47 | #define INIT_NSPROXY(nsproxy) { \ | |
9a575a92 | 48 | .pid_ns = &init_pid_ns, \ |
ab516013 | 49 | .count = ATOMIC_INIT(1), \ |
4865ecf1 | 50 | .uts_ns = &init_uts_ns, \ |
6b3286ed | 51 | .mnt_ns = NULL, \ |
4fabcd71 | 52 | INIT_NET_NS(net_ns) \ |
73ea4130 | 53 | INIT_IPC_NS(ipc_ns) \ |
ab516013 SH |
54 | } |
55 | ||
1da177e4 LT |
56 | #define INIT_SIGHAND(sighand) { \ |
57 | .count = ATOMIC_INIT(1), \ | |
58 | .action = { { { .sa_handler = NULL, } }, }, \ | |
e4d91918 | 59 | .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \ |
b8fceee1 | 60 | .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \ |
1da177e4 LT |
61 | } |
62 | ||
63 | extern struct group_info init_groups; | |
64 | ||
820e45db SB |
65 | #define INIT_STRUCT_PID { \ |
66 | .count = ATOMIC_INIT(1), \ | |
820e45db SB |
67 | .tasks = { \ |
68 | { .first = &init_task.pids[PIDTYPE_PID].node }, \ | |
69 | { .first = &init_task.pids[PIDTYPE_PGID].node }, \ | |
70 | { .first = &init_task.pids[PIDTYPE_SID].node }, \ | |
71 | }, \ | |
72 | .rcu = RCU_HEAD_INIT, \ | |
4c3f2ead SB |
73 | .level = 0, \ |
74 | .numbers = { { \ | |
75 | .nr = 0, \ | |
76 | .ns = &init_pid_ns, \ | |
77 | .pid_chain = { .next = NULL, .pprev = NULL }, \ | |
78 | }, } \ | |
820e45db SB |
79 | } |
80 | ||
81 | #define INIT_PID_LINK(type) \ | |
82 | { \ | |
83 | .node = { \ | |
84 | .next = NULL, \ | |
85 | .pprev = &init_struct_pid.tasks[type].first, \ | |
86 | }, \ | |
87 | .pid = &init_struct_pid, \ | |
88 | } | |
89 | ||
bfef93a5 AV |
90 | #ifdef CONFIG_AUDITSYSCALL |
91 | #define INIT_IDS \ | |
4746ec5b EP |
92 | .loginuid = -1, \ |
93 | .sessionid = -1, | |
bfef93a5 AV |
94 | #else |
95 | #define INIT_IDS | |
96 | #endif | |
3b7391de SH |
97 | |
98 | #ifdef CONFIG_SECURITY_FILE_CAPABILITIES | |
99 | /* | |
100 | * Because of the reduced scope of CAP_SETPCAP when filesystem | |
101 | * capabilities are in effect, it is safe to allow CAP_SETPCAP to | |
102 | * be available in the default configuration. | |
103 | */ | |
104 | # define CAP_INIT_BSET CAP_FULL_SET | |
105 | #else | |
106 | # define CAP_INIT_BSET CAP_INIT_EFF_SET | |
107 | #endif | |
108 | ||
b6dff3ec DH |
109 | extern struct cred init_cred; |
110 | ||
1da177e4 LT |
111 | /* |
112 | * INIT_TASK is used to set up the first task table, touch at | |
113 | * your own risk!. Base=0, limit=0x1fffff (=2MB) | |
114 | */ | |
115 | #define INIT_TASK(tsk) \ | |
116 | { \ | |
117 | .state = 0, \ | |
f7e4217b | 118 | .stack = &init_thread_info, \ |
1da177e4 | 119 | .usage = ATOMIC_INIT(2), \ |
7b34e428 | 120 | .flags = PF_KTHREAD, \ |
1da177e4 LT |
121 | .lock_depth = -1, \ |
122 | .prio = MAX_PRIO-20, \ | |
123 | .static_prio = MAX_PRIO-20, \ | |
b29739f9 | 124 | .normal_prio = MAX_PRIO-20, \ |
1da177e4 LT |
125 | .policy = SCHED_NORMAL, \ |
126 | .cpus_allowed = CPU_MASK_ALL, \ | |
127 | .mm = NULL, \ | |
128 | .active_mm = &init_mm, \ | |
4a55bd5e PZ |
129 | .se = { \ |
130 | .group_node = LIST_HEAD_INIT(tsk.se.group_node), \ | |
131 | }, \ | |
fa717060 PZ |
132 | .rt = { \ |
133 | .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \ | |
6f505b16 PZ |
134 | .time_slice = HZ, \ |
135 | .nr_cpus_allowed = NR_CPUS, \ | |
136 | }, \ | |
1da177e4 | 137 | .tasks = LIST_HEAD_INIT(tsk.tasks), \ |
917b627d | 138 | .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO), \ |
f470021a RM |
139 | .ptraced = LIST_HEAD_INIT(tsk.ptraced), \ |
140 | .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \ | |
1da177e4 LT |
141 | .real_parent = &tsk, \ |
142 | .parent = &tsk, \ | |
143 | .children = LIST_HEAD_INIT(tsk.children), \ | |
144 | .sibling = LIST_HEAD_INIT(tsk.sibling), \ | |
145 | .group_leader = &tsk, \ | |
3b11a1de | 146 | .real_cred = &init_cred, \ |
f1752eec | 147 | .cred = &init_cred, \ |
d84f4f99 DH |
148 | .cred_exec_mutex = \ |
149 | __MUTEX_INITIALIZER(tsk.cred_exec_mutex), \ | |
1da177e4 LT |
150 | .comm = "swapper", \ |
151 | .thread = INIT_THREAD, \ | |
152 | .fs = &init_fs, \ | |
153 | .files = &init_files, \ | |
154 | .signal = &init_signals, \ | |
155 | .sighand = &init_sighand, \ | |
ab516013 | 156 | .nsproxy = &init_nsproxy, \ |
1da177e4 LT |
157 | .pending = { \ |
158 | .list = LIST_HEAD_INIT(tsk.pending.list), \ | |
159 | .signal = {{0}}}, \ | |
160 | .blocked = {{0}}, \ | |
e4d91918 | 161 | .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ |
1da177e4 LT |
162 | .journal_info = NULL, \ |
163 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ | |
22e2c507 | 164 | .fs_excl = ATOMIC_INIT(0), \ |
b32e41bb | 165 | .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ |
6976675d | 166 | .timer_slack_ns = 50000, /* 50 usec default slack */ \ |
820e45db SB |
167 | .pids = { \ |
168 | [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \ | |
169 | [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \ | |
170 | [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \ | |
171 | }, \ | |
3e26c149 | 172 | .dirties = INIT_PROP_LOCAL_SINGLE(dirties), \ |
bfef93a5 | 173 | INIT_IDS \ |
de30a2b3 | 174 | INIT_TRACE_IRQFLAGS \ |
fbb9ce95 | 175 | INIT_LOCKDEP \ |
5ac9f622 | 176 | INIT_FTRACE_GRAPH \ |
1da177e4 LT |
177 | } |
178 | ||
179 | ||
180 | #define INIT_CPU_TIMERS(cpu_timers) \ | |
181 | { \ | |
182 | LIST_HEAD_INIT(cpu_timers[0]), \ | |
183 | LIST_HEAD_INIT(cpu_timers[1]), \ | |
184 | LIST_HEAD_INIT(cpu_timers[2]), \ | |
185 | } | |
186 | ||
187 | ||
188 | #endif |