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
c1ff672f
Commit
c1ff672f
authored
Oct 27, 2016
by
Christian Brauner
Committed by
Stéphane Graber
Nov 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add lxc_preserve_ns()
This allows to retrieve a file descriptor referring to a namespace. Signed-off-by:
Christian Brauner
<
christian.brauner@canonical.com
>
parent
d3795ab5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
utils.c
src/lxc/utils.c
+13
-0
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/utils.c
View file @
c1ff672f
...
@@ -1968,3 +1968,16 @@ int lxc_append_string(char ***list, char *entry)
...
@@ -1968,3 +1968,16 @@ int lxc_append_string(char ***list, char *entry)
return
0
;
return
0
;
}
}
int
lxc_preserve_ns
(
const
int
pid
,
const
char
*
ns
)
{
int
ret
;
size_t
len
=
5
/* /proc */
+
21
/* /int_as_str */
+
3
/* /ns */
+
20
/* /NS_NAME */
+
1
/* \0 */
;
char
path
[
len
];
ret
=
snprintf
(
path
,
len
,
"/proc/%d/ns/%s"
,
pid
,
ns
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
return
-
1
;
return
open
(
path
,
O_RDONLY
|
O_CLOEXEC
);
}
src/lxc/utils.h
View file @
c1ff672f
...
@@ -312,6 +312,7 @@ int open_devnull(void);
...
@@ -312,6 +312,7 @@ int open_devnull(void);
int
set_stdfds
(
int
fd
);
int
set_stdfds
(
int
fd
);
int
null_stdfds
(
void
);
int
null_stdfds
(
void
);
int
lxc_count_file_lines
(
const
char
*
fn
);
int
lxc_count_file_lines
(
const
char
*
fn
);
int
lxc_preserve_ns
(
const
int
pid
,
const
char
*
ns
);
/* Check whether a signal is blocked by a process. */
/* Check whether a signal is blocked by a process. */
bool
task_blocking_signal
(
pid_t
pid
,
int
signal
);
bool
task_blocking_signal
(
pid_t
pid
,
int
signal
);
...
...
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