[PATCH] namespaces: add nsproxy
[linux-3.10.git] / include / linux / init_task.h
1 #ifndef _LINUX__INIT_TASK_H
2 #define _LINUX__INIT_TASK_H
3
4 #include <linux/file.h>
5 #include <linux/rcupdate.h>
6 #include <linux/irqflags.h>
7 #include <linux/lockdep.h>
8
9 #define INIT_FDTABLE \
10 {                                                       \
11         .max_fds        = NR_OPEN_DEFAULT,              \
12         .max_fdset      = EMBEDDED_FD_SET_SIZE,         \
13         .fd             = &init_files.fd_array[0],      \
14         .close_on_exec  = (fd_set *)&init_files.close_on_exec_init, \
15         .open_fds       = (fd_set *)&init_files.open_fds_init,  \
16         .rcu            = RCU_HEAD_INIT,                \
17         .free_files     = NULL,                         \
18         .next           = NULL,                         \
19 }
20
21 #define INIT_FILES \
22 {                                                       \
23         .count          = ATOMIC_INIT(1),               \
24         .fdt            = &init_files.fdtab,            \
25         .fdtab          = INIT_FDTABLE,                 \
26         .file_lock      = __SPIN_LOCK_UNLOCKED(init_task.file_lock), \
27         .next_fd        = 0,                            \
28         .close_on_exec_init = { { 0, } },               \
29         .open_fds_init  = { { 0, } },                   \
30         .fd_array       = { NULL, }                     \
31 }
32
33 #define INIT_KIOCTX(name, which_mm) \
34 {                                                       \
35         .users          = ATOMIC_INIT(1),               \
36         .dead           = 0,                            \
37         .mm             = &which_mm,                    \
38         .user_id        = 0,                            \
39         .next           = NULL,                         \
40         .wait           = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait), \
41         .ctx_lock       = __SPIN_LOCK_UNLOCKED(name.ctx_lock), \
42         .reqs_active    = 0U,                           \
43         .max_reqs       = ~0U,                          \
44 }
45
46 #define INIT_MM(name) \
47 {                                                               \
48         .mm_rb          = RB_ROOT,                              \
49         .pgd            = swapper_pg_dir,                       \
50         .mm_users       = ATOMIC_INIT(2),                       \
51         .mm_count       = ATOMIC_INIT(1),                       \
52         .mmap_sem       = __RWSEM_INITIALIZER(name.mmap_sem),   \
53         .page_table_lock =  __SPIN_LOCK_UNLOCKED(name.page_table_lock), \
54         .mmlist         = LIST_HEAD_INIT(name.mmlist),          \
55         .cpu_vm_mask    = CPU_MASK_ALL,                         \
56 }
57
58 #define INIT_SIGNALS(sig) {     \
59         .count          = ATOMIC_INIT(1),               \
60         .wait_chldexit  = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
61         .shared_pending = {                             \
62                 .list = LIST_HEAD_INIT(sig.shared_pending.list),        \
63                 .signal =  {{0}}}, \
64         .posix_timers    = LIST_HEAD_INIT(sig.posix_timers),            \
65         .cpu_timers     = INIT_CPU_TIMERS(sig.cpu_timers),              \
66         .rlim           = INIT_RLIMITS,                                 \
67         .pgrp           = 1,                                            \
68         .session        = 1,                                            \
69 }
70
71 extern struct nsproxy init_nsproxy;
72 #define INIT_NSPROXY(nsproxy) {                                         \
73         .count          = ATOMIC_INIT(1),                               \
74         .nslock         = SPIN_LOCK_UNLOCKED,                           \
75 }
76
77 #define INIT_SIGHAND(sighand) {                                         \
78         .count          = ATOMIC_INIT(1),                               \
79         .action         = { { { .sa_handler = NULL, } }, },             \
80         .siglock        = __SPIN_LOCK_UNLOCKED(sighand.siglock),        \
81 }
82
83 extern struct group_info init_groups;
84
85 /*
86  *  INIT_TASK is used to set up the first task table, touch at
87  * your own risk!. Base=0, limit=0x1fffff (=2MB)
88  */
89 #define INIT_TASK(tsk)  \
90 {                                                                       \
91         .state          = 0,                                            \
92         .thread_info    = &init_thread_info,                            \
93         .usage          = ATOMIC_INIT(2),                               \
94         .flags          = 0,                                            \
95         .lock_depth     = -1,                                           \
96         .prio           = MAX_PRIO-20,                                  \
97         .static_prio    = MAX_PRIO-20,                                  \
98         .normal_prio    = MAX_PRIO-20,                                  \
99         .policy         = SCHED_NORMAL,                                 \
100         .cpus_allowed   = CPU_MASK_ALL,                                 \
101         .mm             = NULL,                                         \
102         .active_mm      = &init_mm,                                     \
103         .run_list       = LIST_HEAD_INIT(tsk.run_list),                 \
104         .ioprio         = 0,                                            \
105         .time_slice     = HZ,                                           \
106         .tasks          = LIST_HEAD_INIT(tsk.tasks),                    \
107         .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children),          \
108         .ptrace_list    = LIST_HEAD_INIT(tsk.ptrace_list),              \
109         .real_parent    = &tsk,                                         \
110         .parent         = &tsk,                                         \
111         .children       = LIST_HEAD_INIT(tsk.children),                 \
112         .sibling        = LIST_HEAD_INIT(tsk.sibling),                  \
113         .group_leader   = &tsk,                                         \
114         .group_info     = &init_groups,                                 \
115         .cap_effective  = CAP_INIT_EFF_SET,                             \
116         .cap_inheritable = CAP_INIT_INH_SET,                            \
117         .cap_permitted  = CAP_FULL_SET,                                 \
118         .keep_capabilities = 0,                                         \
119         .user           = INIT_USER,                                    \
120         .comm           = "swapper",                                    \
121         .thread         = INIT_THREAD,                                  \
122         .fs             = &init_fs,                                     \
123         .files          = &init_files,                                  \
124         .signal         = &init_signals,                                \
125         .sighand        = &init_sighand,                                \
126         .nsproxy        = &init_nsproxy,                                \
127         .pending        = {                                             \
128                 .list = LIST_HEAD_INIT(tsk.pending.list),               \
129                 .signal = {{0}}},                                       \
130         .blocked        = {{0}},                                        \
131         .alloc_lock     = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock),         \
132         .journal_info   = NULL,                                         \
133         .cpu_timers     = INIT_CPU_TIMERS(tsk.cpu_timers),              \
134         .fs_excl        = ATOMIC_INIT(0),                               \
135         .pi_lock        = SPIN_LOCK_UNLOCKED,                           \
136         INIT_TRACE_IRQFLAGS                                             \
137         INIT_LOCKDEP                                                    \
138 }
139
140
141 #define INIT_CPU_TIMERS(cpu_timers)                                     \
142 {                                                                       \
143         LIST_HEAD_INIT(cpu_timers[0]),                                  \
144         LIST_HEAD_INIT(cpu_timers[1]),                                  \
145         LIST_HEAD_INIT(cpu_timers[2]),                                  \
146 }
147
148
149 #endif