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
ea0e06dd
Unverified
Commit
ea0e06dd
authored
Jul 22, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start: coding style fixes
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
6b741397
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
start.c
src/lxc/start.c
+21
-16
No files found.
src/lxc/start.c
View file @
ea0e06dd
...
@@ -1529,30 +1529,33 @@ static inline int do_share_ns(void *arg)
...
@@ -1529,30 +1529,33 @@ static inline int do_share_ns(void *arg)
return
0
;
return
0
;
}
}
static
int
lxc_setup_shmount
(
struct
lxc_conf
*
conf
)
{
static
int
lxc_setup_shmount
(
struct
lxc_conf
*
conf
)
{
size_t
len_cont
;
size_t
len_cont
;
char
*
full_cont_path
;
char
*
full_cont_path
;
int
ret
=
-
1
;
int
ret
=
-
1
;
/* Construct the shmount path under the container root */
/* Construct the shmount path under the container root. */
/* +1 for slash */
len_cont
=
strlen
(
conf
->
rootfs
.
mount
)
+
1
+
strlen
(
conf
->
shmount
.
path_cont
);
len_cont
=
strlen
(
conf
->
rootfs
.
mount
)
+
1
+
strlen
(
conf
->
shmount
.
path_cont
);
/* +1 for the terminating '\0' */
/* +1 for the terminating '\0' */
full_cont_path
=
malloc
(
len_cont
+
1
);
full_cont_path
=
malloc
(
len_cont
+
1
);
if
(
!
full_cont_path
)
{
if
(
!
full_cont_path
)
{
SYSERROR
(
"Not enough memory"
);
SYSERROR
(
"Not enough memory"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
ret
=
snprintf
(
full_cont_path
,
len_cont
+
1
,
"%s/%s"
,
conf
->
rootfs
.
mount
,
conf
->
shmount
.
path_cont
);
ret
=
snprintf
(
full_cont_path
,
len_cont
+
1
,
"%s/%s"
,
conf
->
rootfs
.
mount
,
conf
->
shmount
.
path_cont
);
if
(
ret
<
0
||
ret
>=
len_cont
+
1
)
{
if
(
ret
<
0
||
ret
>=
len_cont
+
1
)
{
SYSERROR
(
"Failed to create filename"
);
SYSERROR
(
"Failed to create filename"
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
-
1
;
return
-
1
;
}
}
/* Check if shmount point is already set up */
/* Check if shmount point is already set up
.
*/
if
(
is_shared_mountpoint
(
conf
->
shmount
.
path_host
))
{
if
(
is_shared_mountpoint
(
conf
->
shmount
.
path_host
))
{
INFO
(
"Path
\"
%s
\"
is already MS_SHARED. Reusing"
,
conf
->
shmount
.
path_host
);
INFO
(
"Path
\"
%s
\"
is already MS_SHARED. Reusing"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
0
;
return
0
;
}
}
...
@@ -1560,7 +1563,8 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
...
@@ -1560,7 +1563,8 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
/* Create host and cont mount paths */
/* Create host and cont mount paths */
ret
=
mkdir_p
(
conf
->
shmount
.
path_host
,
0711
);
ret
=
mkdir_p
(
conf
->
shmount
.
path_host
,
0711
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
ret
;
return
ret
;
}
}
...
@@ -1573,22 +1577,23 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
...
@@ -1573,22 +1577,23 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
}
}
/* Prepare host mountpoint */
/* Prepare host mountpoint */
ret
=
mount
(
"tmpfs"
,
conf
->
shmount
.
path_host
,
"tmpfs"
,
ret
=
mount
(
"tmpfs"
,
conf
->
shmount
.
path_host
,
"tmpfs"
,
0
,
0
,
"size=100k,mode=0711"
);
"size=100k,mode=0711"
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to mount
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
SYSERROR
(
"Failed to mount
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
ret
;
return
ret
;
}
}
ret
=
mount
(
conf
->
shmount
.
path_host
,
conf
->
shmount
.
path_host
,
"none"
,
ret
=
mount
(
conf
->
shmount
.
path_host
,
conf
->
shmount
.
path_host
,
"none"
,
MS_REC
|
MS_SHARED
,
""
);
MS_REC
|
MS_SHARED
,
""
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to make shared
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
SYSERROR
(
"Failed to make shared
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
ret
;
return
ret
;
}
}
INFO
(
"
Made
shared mount point
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
INFO
(
"
Setup
shared mount point
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
0
;
return
0
;
}
}
...
@@ -1670,12 +1675,12 @@ static int lxc_spawn(struct lxc_handler *handler)
...
@@ -1670,12 +1675,12 @@ static int lxc_spawn(struct lxc_handler *handler)
}
}
}
}
if
(
conf
->
shmount
.
path_host
&&
!
conf
->
shmount
.
path_cont
)
{
if
(
conf
->
shmount
.
path_host
)
{
ERROR
(
"Missing the container side path to the shared mount point"
);
if
(
!
conf
->
shmount
.
path_cont
)
{
lxc_sync_fini
(
handler
);
lxc_sync_fini
(
handler
);
return
-
1
;
return
-
1
;
}
}
if
(
conf
->
shmount
.
path_host
)
{
ret
=
lxc_setup_shmount
(
conf
);
ret
=
lxc_setup_shmount
(
conf
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed to setup shared mount point"
);
ERROR
(
"Failed to setup shared mount point"
);
...
...
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