Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
463334b7
Unverified
Commit
463334b7
authored
May 09, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
namespace: support CLONE_PIDFD with lxc_clone()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ded425a6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8 additions
and
8 deletions
+8
-8
conf.c
src/lxc/conf.c
+1
-1
namespace.c
src/lxc/namespace.c
+3
-3
namespace.h
src/lxc/namespace.h
+1
-1
start.c
src/lxc/start.c
+1
-1
nbd.c
src/lxc/storage/nbd.c
+1
-1
lxc_unshare.c
src/lxc/tools/lxc_unshare.c
+1
-1
No files found.
src/lxc/conf.c
View file @
463334b7
...
@@ -4348,7 +4348,7 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
...
@@ -4348,7 +4348,7 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
d
.
p
[
1
]
=
p
[
1
];
d
.
p
[
1
]
=
p
[
1
];
/* Clone child in new user namespace. */
/* Clone child in new user namespace. */
pid
=
lxc_clone
(
run_userns_fn
,
&
d
,
CLONE_NEWUSER
);
pid
=
lxc_clone
(
run_userns_fn
,
&
d
,
CLONE_NEWUSER
,
NULL
);
if
(
pid
<
0
)
{
if
(
pid
<
0
)
{
ERROR
(
"Failed to clone process in new user namespace"
);
ERROR
(
"Failed to clone process in new user namespace"
);
goto
on_error
;
goto
on_error
;
...
...
src/lxc/namespace.c
View file @
463334b7
...
@@ -54,7 +54,7 @@ static int do_clone(void *arg)
...
@@ -54,7 +54,7 @@ static int do_clone(void *arg)
}
}
#define __LXC_STACK_SIZE 4096
#define __LXC_STACK_SIZE 4096
pid_t
lxc_clone
(
int
(
*
fn
)(
void
*
),
void
*
arg
,
int
flags
)
pid_t
lxc_clone
(
int
(
*
fn
)(
void
*
),
void
*
arg
,
int
flags
,
int
*
pidfd
)
{
{
size_t
stack_size
;
size_t
stack_size
;
pid_t
ret
;
pid_t
ret
;
...
@@ -66,9 +66,9 @@ pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
...
@@ -66,9 +66,9 @@ pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
stack_size
=
__LXC_STACK_SIZE
;
stack_size
=
__LXC_STACK_SIZE
;
#ifdef __ia64__
#ifdef __ia64__
ret
=
__clone2
(
do_clone
,
stack
,
stack_size
,
flags
|
SIGCHLD
,
&
clone_arg
);
ret
=
__clone2
(
do_clone
,
stack
,
stack_size
,
flags
|
SIGCHLD
,
&
clone_arg
,
pidfd
);
#else
#else
ret
=
clone
(
do_clone
,
stack
+
stack_size
,
flags
|
SIGCHLD
,
&
clone_arg
);
ret
=
clone
(
do_clone
,
stack
+
stack_size
,
flags
|
SIGCHLD
,
&
clone_arg
,
pidfd
);
#endif
#endif
if
(
ret
<
0
)
if
(
ret
<
0
)
SYSERROR
(
"Failed to clone (%#x)"
,
flags
);
SYSERROR
(
"Failed to clone (%#x)"
,
flags
);
...
...
src/lxc/namespace.h
View file @
463334b7
...
@@ -133,7 +133,7 @@ int clone(int (*fn)(void *), void *child_stack,
...
@@ -133,7 +133,7 @@ int clone(int (*fn)(void *), void *child_stack,
* - should call lxc_raw_getpid():
* - should call lxc_raw_getpid():
* The child should use lxc_raw_getpid() to retrieve its pid.
* The child should use lxc_raw_getpid() to retrieve its pid.
*/
*/
extern
pid_t
lxc_clone
(
int
(
*
fn
)(
void
*
),
void
*
arg
,
int
flags
);
extern
pid_t
lxc_clone
(
int
(
*
fn
)(
void
*
),
void
*
arg
,
int
flags
,
int
*
pidfd
);
extern
int
lxc_namespace_2_cloneflag
(
const
char
*
namespace
);
extern
int
lxc_namespace_2_cloneflag
(
const
char
*
namespace
);
extern
int
lxc_namespace_2_ns_idx
(
const
char
*
namespace
);
extern
int
lxc_namespace_2_ns_idx
(
const
char
*
namespace
);
...
...
src/lxc/start.c
View file @
463334b7
...
@@ -1705,7 +1705,7 @@ static int lxc_spawn(struct lxc_handler *handler)
...
@@ -1705,7 +1705,7 @@ static int lxc_spawn(struct lxc_handler *handler)
pid_t
attacher_pid
;
pid_t
attacher_pid
;
attacher_pid
=
lxc_clone
(
do_share_ns
,
handler
,
attacher_pid
=
lxc_clone
(
do_share_ns
,
handler
,
CLONE_VFORK
|
CLONE_VM
|
CLONE_FILES
);
CLONE_VFORK
|
CLONE_VM
|
CLONE_FILES
,
NULL
);
if
(
attacher_pid
<
0
)
{
if
(
attacher_pid
<
0
)
{
SYSERROR
(
LXC_CLONE_ERROR
);
SYSERROR
(
LXC_CLONE_ERROR
);
goto
out_delete_net
;
goto
out_delete_net
;
...
...
src/lxc/storage/nbd.c
View file @
463334b7
...
@@ -266,7 +266,7 @@ static bool clone_attach_nbd(const char *nbd, const char *path)
...
@@ -266,7 +266,7 @@ static bool clone_attach_nbd(const char *nbd, const char *path)
data
.
nbd
=
nbd
;
data
.
nbd
=
nbd
;
data
.
path
=
path
;
data
.
path
=
path
;
pid
=
lxc_clone
(
do_attach_nbd
,
&
data
,
CLONE_NEWPID
);
pid
=
lxc_clone
(
do_attach_nbd
,
&
data
,
CLONE_NEWPID
,
NULL
);
if
(
pid
<
0
)
if
(
pid
<
0
)
return
false
;
return
false
;
...
...
src/lxc/tools/lxc_unshare.c
View file @
463334b7
...
@@ -388,7 +388,7 @@ int main(int argc, char *argv[])
...
@@ -388,7 +388,7 @@ int main(int argc, char *argv[])
start_arg
.
want_hostname
=
my_args
.
want_hostname
;
start_arg
.
want_hostname
=
my_args
.
want_hostname
;
start_arg
.
want_default_mounts
=
my_args
.
want_default_mounts
;
start_arg
.
want_default_mounts
=
my_args
.
want_default_mounts
;
pid
=
lxc_clone
(
do_start
,
&
start_arg
,
my_args
.
flags
);
pid
=
lxc_clone
(
do_start
,
&
start_arg
,
my_args
.
flags
,
NULL
);
if
(
pid
<
0
)
{
if
(
pid
<
0
)
{
ERROR
(
"Failed to clone"
);
ERROR
(
"Failed to clone"
);
free_ifname_list
();
free_ifname_list
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment