]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/namespace.h
Merge pull request #1308 from brauner/2016-11-20/use_ns_info_struct
[mirror_lxc.git] / src / lxc / namespace.h
1 /*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2009
5 *
6 * Authors:
7 * Daniel Lezcano <daniel.lezcano at free.fr>
8 *
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.
13 *
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.
18 *
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
22 */
23 #ifndef __LXC_NAMESPACE_H
24 #define __LXC_NAMESPACE_H
25
26 #include <sys/syscall.h>
27 #include <sched.h>
28
29 #include "config.h"
30
31 #ifndef CLONE_FS
32 # define CLONE_FS 0x00000200
33 #endif
34 #ifndef CLONE_NEWNS
35 # define CLONE_NEWNS 0x00020000
36 #endif
37 #ifndef CLONE_NEWCGROUP
38 # define CLONE_NEWCGROUP 0x02000000
39 #endif
40 #ifndef CLONE_NEWUTS
41 # define CLONE_NEWUTS 0x04000000
42 #endif
43 #ifndef CLONE_NEWIPC
44 # define CLONE_NEWIPC 0x08000000
45 #endif
46 #ifndef CLONE_NEWUSER
47 # define CLONE_NEWUSER 0x10000000
48 #endif
49 #ifndef CLONE_NEWPID
50 # define CLONE_NEWPID 0x20000000
51 #endif
52 #ifndef CLONE_NEWNET
53 # define CLONE_NEWNET 0x40000000
54 #endif
55
56 enum {
57 LXC_NS_USER,
58 LXC_NS_MNT,
59 LXC_NS_PID,
60 LXC_NS_UTS,
61 LXC_NS_IPC,
62 LXC_NS_NET,
63 LXC_NS_CGROUP,
64 LXC_NS_MAX
65 };
66
67 extern const struct ns_info {
68 const char *proc_name;
69 int clone_flag;
70 const char *flag_name;
71 } ns_info[LXC_NS_MAX];
72
73 #if defined(__ia64__)
74 int __clone2(int (*__fn) (void *__arg), void *__child_stack_base,
75 size_t __child_stack_size, int __flags, void *__arg, ...);
76 #else
77 int clone(int (*fn)(void *), void *child_stack,
78 int flags, void *arg, ...
79 /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ );
80 #endif
81
82 extern pid_t lxc_clone(int (*fn)(void *), void *arg, int flags);
83
84 extern int lxc_namespace_2_cloneflag(char *namespace);
85 extern int lxc_fill_namespace_flags(char *flaglist, int *flags);
86
87 #endif