]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/namespace.h
be2bf8b7133281abd58cb6dd486152ec96b11c2a
2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2009
7 * Daniel Lezcano <daniel.lezcano at free.fr>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef __LXC_NAMESPACE_H
24 #define __LXC_NAMESPACE_H
28 #include <sys/syscall.h>
30 #ifndef CLONE_PARENT_SETTID
31 #define CLONE_PARENT_SETTID 0x00100000
34 #ifndef CLONE_CHILD_CLEARTID
35 #define CLONE_CHILD_CLEARTID 0x00200000
38 #ifndef CLONE_CHILD_SETTID
39 #define CLONE_CHILD_SETTID 0x01000000
43 #define CLONE_VFORK 0x00004000
47 #define CLONE_THREAD 0x00010000
51 #define CLONE_SETTLS 0x00080000
55 #define CLONE_VM 0x00000100
59 #define CLONE_FILES 0x00000400
63 # define CLONE_FS 0x00000200
66 # define CLONE_NEWNS 0x00020000
68 #ifndef CLONE_NEWCGROUP
69 # define CLONE_NEWCGROUP 0x02000000
72 # define CLONE_NEWUTS 0x04000000
75 # define CLONE_NEWIPC 0x08000000
78 # define CLONE_NEWUSER 0x10000000
81 # define CLONE_NEWPID 0x20000000
84 # define CLONE_NEWNET 0x40000000
98 extern const struct ns_info
{
99 const char *proc_name
;
101 const char *flag_name
;
102 const char *env_name
;
103 } ns_info
[LXC_NS_MAX
];
105 #if defined(__ia64__)
106 int __clone2(int (*__fn
) (void *__arg
), void *__child_stack_base
,
107 size_t __child_stack_size
, int __flags
, void *__arg
, ...);
109 int clone(int (*fn
)(void *), void *child_stack
,
110 int flags
, void *arg
, ...
111 /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ );
115 * lxc_clone() - create a new process
118 * This function allocates a new stack the size of page and passes it to the
121 * - support all CLONE_*flags:
122 * This function supports all CLONE_* flags. If in doubt or not sufficiently
123 * familiar with process creation in the kernel and interactions with libcs
124 * this function should be used.
126 * - pthread_atfork() handlers depending on libc:
127 * Whether this function runs pthread_atfork() handlers depends on the
128 * corresponding libc wrapper. glibc currently does not run pthread_atfork()
129 * handlers but does not guarantee that they are not. Other libcs might or
130 * might not run pthread_atfork() handlers. If you require guarantees please
131 * refer to the lxc_raw_clone*() functions in raw_syscalls.{c,h}.
133 * - should call lxc_raw_getpid():
134 * The child should use lxc_raw_getpid() to retrieve its pid.
136 extern pid_t
lxc_clone(int (*fn
)(void *), void *arg
, int flags
);
138 extern int lxc_namespace_2_cloneflag(const char *namespace);
139 extern int lxc_namespace_2_ns_idx(const char *namespace);
140 extern int lxc_namespace_2_std_identifiers(char *namespaces
);
141 extern int lxc_fill_namespace_flags(char *flaglist
, int *flags
);
144 * Because of older glibc's pid cache (up to 2.25) whenever clone() is called
145 * the child must must retrieve it's own pid via lxc_raw_getpid().
147 static inline pid_t
lxc_raw_getpid(void)
149 return (pid_t
) syscall(SYS_getpid
);