]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/namespace.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 #ifndef __LXC_NAMESPACE_H
4 #define __LXC_NAMESPACE_H
8 #include <sys/syscall.h>
10 #ifndef CLONE_PARENT_SETTID
11 #define CLONE_PARENT_SETTID 0x00100000
14 #ifndef CLONE_CHILD_CLEARTID
15 #define CLONE_CHILD_CLEARTID 0x00200000
18 #ifndef CLONE_CHILD_SETTID
19 #define CLONE_CHILD_SETTID 0x01000000
23 #define CLONE_VFORK 0x00004000
27 #define CLONE_THREAD 0x00010000
31 #define CLONE_SETTLS 0x00080000
35 #define CLONE_VM 0x00000100
39 #define CLONE_FILES 0x00000400
43 # define CLONE_FS 0x00000200
46 # define CLONE_NEWNS 0x00020000
48 #ifndef CLONE_NEWCGROUP
49 # define CLONE_NEWCGROUP 0x02000000
52 # define CLONE_NEWUTS 0x04000000
55 # define CLONE_NEWIPC 0x08000000
58 # define CLONE_NEWUSER 0x10000000
61 # define CLONE_NEWPID 0x20000000
64 # define CLONE_NEWNET 0x40000000
78 extern const struct ns_info
{
79 const char *proc_name
;
81 const char *flag_name
;
83 } ns_info
[LXC_NS_MAX
];
86 int __clone2(int (*__fn
) (void *__arg
), void *__child_stack_base
,
87 size_t __child_stack_size
, int __flags
, void *__arg
, ...);
89 int clone(int (*fn
)(void *), void *child_stack
,
90 int flags
, void *arg
, ...
91 /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ );
95 * lxc_clone() - create a new process
98 * This function allocates a new stack the size of page and passes it to the
101 * - support all CLONE_*flags:
102 * This function supports all CLONE_* flags. If in doubt or not sufficiently
103 * familiar with process creation in the kernel and interactions with libcs
104 * this function should be used.
106 * - pthread_atfork() handlers depending on libc:
107 * Whether this function runs pthread_atfork() handlers depends on the
108 * corresponding libc wrapper. glibc currently does not run pthread_atfork()
109 * handlers but does not guarantee that they are not. Other libcs might or
110 * might not run pthread_atfork() handlers. If you require guarantees please
111 * refer to the lxc_raw_clone*() functions in raw_syscalls.{c,h}.
113 * - should call lxc_raw_getpid():
114 * The child should use lxc_raw_getpid() to retrieve its pid.
116 extern pid_t
lxc_clone(int (*fn
)(void *), void *arg
, int flags
, int *pidfd
);
118 extern int lxc_namespace_2_cloneflag(const char *namespace);
119 extern int lxc_namespace_2_ns_idx(const char *namespace);
120 extern int lxc_namespace_2_std_identifiers(char *namespaces
);
121 extern int lxc_fill_namespace_flags(char *flaglist
, int *flags
);