Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
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
zhul
criu
Commits
8ac80915
Commit
8ac80915
authored
Sep 22, 2014
by
Pavel
Committed by
Pavel Emelyanov
Sep 30, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ns: Factor out namespace switching call
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
3bc0936a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
25 deletions
+23
-25
ipc_ns.h
include/ipc_ns.h
+1
-1
net.h
include/net.h
+1
-1
uts_ns.h
include/uts_ns.h
+1
-1
ipc_ns.c
ipc_ns.c
+1
-5
namespaces.c
namespaces.c
+16
-8
net.c
net.c
+2
-4
uts_ns.c
uts_ns.c
+1
-5
No files found.
include/ipc_ns.h
View file @
8ac80915
#ifndef __CR_IPC_NS_H__
#define __CR_IPC_NS_H__
extern
int
dump_ipc_ns
(
int
ns_
pid
,
int
ns_
id
);
extern
int
dump_ipc_ns
(
int
ns_id
);
extern
int
prepare_ipc_ns
(
int
pid
);
extern
struct
ns_desc
ipc_ns_desc
;
...
...
include/net.h
View file @
8ac80915
...
...
@@ -4,7 +4,7 @@
#include "list.h"
struct
cr_imgset
;
extern
int
dump_net_ns
(
int
pid
,
int
ns_id
);
extern
int
dump_net_ns
(
int
ns_id
);
extern
int
prepare_net_ns
(
int
pid
);
extern
int
netns_pre_create
(
void
);
...
...
include/uts_ns.h
View file @
8ac80915
#ifndef __CR_UTS_NS_H__
#define __CR_UTS_NS_H__
extern
int
dump_uts_ns
(
int
ns_
pid
,
int
ns_
id
);
extern
int
dump_uts_ns
(
int
ns_id
);
extern
int
prepare_utsns
(
int
pid
);
extern
struct
ns_desc
uts_ns_desc
;
...
...
ipc_ns.c
View file @
8ac80915
...
...
@@ -456,7 +456,7 @@ static int dump_ipc_data(const struct cr_imgset *imgset)
return
0
;
}
int
dump_ipc_ns
(
int
ns_
pid
,
int
ns_
id
)
int
dump_ipc_ns
(
int
ns_id
)
{
int
ret
;
struct
cr_imgset
*
imgset
;
...
...
@@ -465,10 +465,6 @@ int dump_ipc_ns(int ns_pid, int ns_id)
if
(
imgset
==
NULL
)
return
-
1
;
ret
=
switch_ns
(
ns_pid
,
&
ipc_ns_desc
,
NULL
);
if
(
ret
<
0
)
goto
err
;
ret
=
dump_ipc_data
(
imgset
);
if
(
ret
<
0
)
{
pr_err
(
"Failed to write IPC namespace data
\n
"
);
...
...
namespaces.c
View file @
8ac80915
...
...
@@ -424,27 +424,27 @@ int gen_predump_ns_mask(void)
static
int
do_dump_namespaces
(
struct
ns_id
*
ns
)
{
int
ret
=
-
1
;
int
ret
;
ret
=
switch_ns
(
ns
->
pid
,
ns
->
nd
,
NULL
);
if
(
ret
)
return
ret
;
switch
(
ns
->
nd
->
cflag
)
{
case
CLONE_NEWPID
:
case
CLONE_NEWNS
:
ret
=
0
;
break
;
case
CLONE_NEWUTS
:
pr_info
(
"Dump UTS namespace %d via %d
\n
"
,
ns
->
id
,
ns
->
pid
);
ret
=
dump_uts_ns
(
ns
->
pid
,
ns
->
id
);
ret
=
dump_uts_ns
(
ns
->
id
);
break
;
case
CLONE_NEWIPC
:
pr_info
(
"Dump IPC namespace %d via %d
\n
"
,
ns
->
id
,
ns
->
pid
);
ret
=
dump_ipc_ns
(
ns
->
pid
,
ns
->
id
);
ret
=
dump_ipc_ns
(
ns
->
id
);
break
;
case
CLONE_NEWNET
:
pr_info
(
"Dump NET namespace info %d via %d
\n
"
,
ns
->
id
,
ns
->
pid
);
ret
=
dump_net_ns
(
ns
->
pid
,
ns
->
id
);
ret
=
dump_net_ns
(
ns
->
id
);
break
;
default:
pr_err
(
"Unknown namespace flag %x"
,
ns
->
nd
->
cflag
);
...
...
@@ -485,6 +485,14 @@ int dump_namespaces(struct pstree_item *item, unsigned int ns_flags)
if
(
ns
->
pid
==
getpid
())
continue
;
switch
(
ns
->
nd
->
cflag
)
{
/* No data for pid namespaces to dump */
case
CLONE_NEWPID
:
/* Dumped explicitly with dump_mnt_namespaces() */
case
CLONE_NEWNS
:
continue
;
}
pid
=
fork
();
if
(
pid
<
0
)
{
pr_perror
(
"Can't fork ns dumper"
);
...
...
net.c
View file @
8ac80915
...
...
@@ -533,7 +533,7 @@ static int mount_ns_sysfs(void)
return
ns_sysfs_fd
>=
0
?
0
:
-
1
;
}
int
dump_net_ns
(
int
pid
,
int
ns_id
)
int
dump_net_ns
(
int
ns_id
)
{
struct
cr_imgset
*
fds
;
int
ret
;
...
...
@@ -542,9 +542,7 @@ int dump_net_ns(int pid, int ns_id)
if
(
fds
==
NULL
)
return
-
1
;
ret
=
switch_ns
(
pid
,
&
net_ns_desc
,
NULL
);
if
(
!
ret
)
ret
=
mount_ns_sysfs
();
ret
=
mount_ns_sysfs
();
if
(
!
ret
)
ret
=
dump_links
(
fds
);
if
(
!
ret
)
...
...
uts_ns.c
View file @
8ac80915
...
...
@@ -12,7 +12,7 @@
#include "protobuf.h"
#include "protobuf/utsns.pb-c.h"
int
dump_uts_ns
(
int
ns_
pid
,
int
ns_
id
)
int
dump_uts_ns
(
int
ns_id
)
{
int
ret
;
struct
cr_img
*
img
;
...
...
@@ -23,10 +23,6 @@ int dump_uts_ns(int ns_pid, int ns_id)
if
(
!
img
)
return
-
1
;
ret
=
switch_ns
(
ns_pid
,
&
uts_ns_desc
,
NULL
);
if
(
ret
<
0
)
goto
err
;
ret
=
uname
(
&
ubuf
);
if
(
ret
<
0
)
{
pr_perror
(
"Error calling uname"
);
...
...
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