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
431b95c4
Unverified
Commit
431b95c4
authored
Jul 21, 2018
by
2xsec
Committed by
Christian Brauner
Jul 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attach: move errno handling
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
a71e32ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
attach.c
src/lxc/attach.c
+9
-13
No files found.
src/lxc/attach.c
View file @
431b95c4
...
...
@@ -190,7 +190,7 @@ static void lxc_proc_put_context_info(struct lxc_proc_context_info *ctx)
static
int
in_same_namespace
(
pid_t
pid1
,
pid_t
pid2
,
const
char
*
ns
)
{
int
ns_fd1
=
-
1
,
ns_fd2
=
-
1
,
ret
=
-
1
;
int
saved_errno
=
errno
;
int
saved_errno
;
struct
stat
ns_st1
,
ns_st2
;
ns_fd1
=
lxc_preserve_ns
(
pid1
,
ns
);
...
...
@@ -201,27 +201,20 @@ static int in_same_namespace(pid_t pid1, pid_t pid2, const char *ns)
if
(
errno
==
ENOENT
)
return
-
EINVAL
;
saved_errno
=
errno
;
goto
out
;
}
ns_fd2
=
lxc_preserve_ns
(
pid2
,
ns
);
if
(
ns_fd2
<
0
)
{
saved_errno
=
errno
;
if
(
ns_fd2
<
0
)
goto
out
;
}
ret
=
fstat
(
ns_fd1
,
&
ns_st1
);
if
(
ret
<
0
)
{
saved_errno
=
errno
;
if
(
ret
<
0
)
goto
out
;
}
ret
=
fstat
(
ns_fd2
,
&
ns_st2
);
if
(
ret
<
0
)
{
saved_errno
=
errno
;
if
(
ret
<
0
)
goto
out
;
}
/* processes are in the same namespace */
if
((
ns_st1
.
st_dev
==
ns_st2
.
st_dev
)
&&
(
ns_st1
.
st_ino
==
ns_st2
.
st_ino
))
{
...
...
@@ -234,6 +227,8 @@ static int in_same_namespace(pid_t pid1, pid_t pid2, const char *ns)
ns_fd2
=
-
1
;
out:
saved_errno
=
errno
;
if
(
ns_fd1
>=
0
)
close
(
ns_fd1
);
...
...
@@ -246,13 +241,14 @@ out:
static
int
lxc_attach_to_ns
(
pid_t
pid
,
struct
lxc_proc_context_info
*
ctx
)
{
int
i
;
int
i
,
ret
;
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
if
(
ctx
->
ns_fd
[
i
]
<
0
)
continue
;
if
(
setns
(
ctx
->
ns_fd
[
i
],
ns_info
[
i
].
clone_flag
)
<
0
)
{
ret
=
setns
(
ctx
->
ns_fd
[
i
],
ns_info
[
i
].
clone_flag
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to attach to %s namespace of %d"
,
ns_info
[
i
].
proc_name
,
pid
);
return
-
1
;
...
...
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