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
42067d18
Commit
42067d18
authored
Jul 07, 2018
by
2xsec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
namespace: add api to convert namespaces to standard identifiers
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
7cb6d1b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
namespace.c
src/lxc/namespace.c
+34
-0
namespace.h
src/lxc/namespace.h
+1
-0
No files found.
src/lxc/namespace.c
View file @
42067d18
...
@@ -193,6 +193,40 @@ int lxc_namespace_2_ns_idx(const char *namespace)
...
@@ -193,6 +193,40 @@ int lxc_namespace_2_ns_idx(const char *namespace)
return
-
EINVAL
;
return
-
EINVAL
;
}
}
extern
int
lxc_namespace_2_std_identifiers
(
char
*
namespaces
)
{
char
**
it
;
char
*
del
;
/* The identifiers for namespaces used with lxc-attach and lxc-unshare
* as given on the manpage do not align with the standard identifiers.
* This affects network, mount, and uts namespaces. The standard identifiers
* are: "mnt", "uts", and "net" whereas lxc-attach and lxc-unshare uses
* "MOUNT", "UTSNAME", and "NETWORK". So let's use some cheap memmove()s
* to replace them by their standard identifiers.
* Let's illustrate this with an example:
* Assume the string:
*
* "IPC|MOUNT|PID"
*
* then we memmove()
*
* dest: del + 1 == OUNT|PID
* src: del + 3 == NT|PID
*/
if
(
!
namespaces
)
return
-
1
;
while
((
del
=
strstr
(
namespaces
,
"MOUNT"
)))
memmove
(
del
+
1
,
del
+
3
,
strlen
(
del
)
-
2
);
for
(
it
=
(
char
*
[]){
"NETWORK"
,
"UTSNAME"
,
NULL
};
it
&&
*
it
;
it
++
)
while
((
del
=
strstr
(
namespaces
,
*
it
)))
memmove
(
del
+
3
,
del
+
7
,
strlen
(
del
)
-
6
);
return
0
;
}
int
lxc_fill_namespace_flags
(
char
*
flaglist
,
int
*
flags
)
int
lxc_fill_namespace_flags
(
char
*
flaglist
,
int
*
flags
)
{
{
char
*
token
,
*
saveptr
=
NULL
;
char
*
token
,
*
saveptr
=
NULL
;
...
...
src/lxc/namespace.h
View file @
42067d18
...
@@ -181,6 +181,7 @@ extern pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args,
...
@@ -181,6 +181,7 @@ extern pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args,
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
);
extern
int
lxc_namespace_2_std_identifiers
(
char
*
namespaces
);
extern
int
lxc_fill_namespace_flags
(
char
*
flaglist
,
int
*
flags
);
extern
int
lxc_fill_namespace_flags
(
char
*
flaglist
,
int
*
flags
);
/**
/**
...
...
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