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
3340f441
Unverified
Commit
3340f441
authored
May 15, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxccontainer: do_lxcapi_mount() coding-style
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
117deb70
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
lxccontainer.c
src/lxc/lxccontainer.c
+13
-17
No files found.
src/lxc/lxccontainer.c
View file @
3340f441
...
@@ -4992,14 +4992,15 @@ static bool do_lxcapi_restore(struct lxc_container *c, char *directory, bool ver
...
@@ -4992,14 +4992,15 @@ static bool do_lxcapi_restore(struct lxc_container *c, char *directory, bool ver
WRAP_API_2
(
bool
,
lxcapi_restore
,
char
*
,
bool
)
WRAP_API_2
(
bool
,
lxcapi_restore
,
char
*
,
bool
)
static
int
do_lxcapi_mount
(
struct
lxc_container
*
c
,
static
int
do_lxcapi_mount
(
struct
lxc_container
*
c
,
const
char
*
source
,
const
char
*
source
,
const
char
*
target
,
const
char
*
target
,
const
char
*
filesystemtype
,
const
char
*
filesystemtype
,
unsigned
long
mountflags
,
unsigned
long
mountflags
,
const
void
*
data
,
const
void
*
data
,
struct
lxc_mount
*
mnt
)
{
struct
lxc_mount
*
mnt
)
{
char
*
suff
,
*
sret
;
char
*
suff
,
*
sret
;
size_t
len
;
char
template
[
MAXPATHLEN
],
path
[
MAXPATHLEN
];
char
template
[
MAXPATHLEN
],
path
[
MAXPATHLEN
];
pid_t
pid
,
init_pid
;
pid_t
pid
,
init_pid
;
size_t
len
;
struct
stat
sb
;
struct
stat
sb
;
int
ret
=
-
1
,
fd
=
-
EBADF
;
int
ret
=
-
1
,
fd
=
-
EBADF
;
...
@@ -5032,28 +5033,18 @@ static int do_lxcapi_mount(struct lxc_container *c,
...
@@ -5032,28 +5033,18 @@ static int do_lxcapi_mount(struct lxc_container *c,
}
}
}
}
if
(
(
sb
.
st_mode
&
S_IFMT
)
==
S_IFDIR
)
{
if
(
S_ISDIR
(
sb
.
st_mode
)
)
{
sret
=
mkdtemp
(
template
);
sret
=
mkdtemp
(
template
);
if
(
!
sret
)
{
if
(
!
sret
)
{
SYSERROR
(
"Could not create shmounts temporary dir"
);
SYSERROR
(
"Could not create shmounts temporary dir"
);
goto
out
;
goto
out
;
}
}
ret
=
chmod
(
template
,
0
);
if
(
ret
<
0
)
{
SYSERROR
(
"Could not chmod shmounts temporary dir
\"
%s
\"
"
,
template
);
goto
out
;
}
}
else
{
}
else
{
fd
=
lxc_make_tmpfile
(
template
,
false
);
fd
=
lxc_make_tmpfile
(
template
,
false
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
SYSERROR
(
"Could not create shmounts temporary file"
);
SYSERROR
(
"Could not create shmounts temporary file"
);
goto
out
;
goto
out
;
}
}
ret
=
fchmod
(
fd
,
0
);
if
(
ret
<
0
)
{
SYSERROR
(
"Could not chmod shmounts temporary file"
);
goto
out
;
}
}
}
/* Do the fork */
/* Do the fork */
...
@@ -5070,6 +5061,7 @@ static int do_lxcapi_mount(struct lxc_container *c,
...
@@ -5070,6 +5061,7 @@ static int do_lxcapi_mount(struct lxc_container *c,
SYSERROR
(
"Failed to mount onto
\"
%s
\"
"
,
template
);
SYSERROR
(
"Failed to mount onto
\"
%s
\"
"
,
template
);
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
}
}
TRACE
(
"Mounted
\"
%s
\"
onto
\"
%s
\"
"
,
source
,
template
);
init_pid
=
do_lxcapi_init_pid
(
c
);
init_pid
=
do_lxcapi_init_pid
(
c
);
if
(
init_pid
<
0
)
{
if
(
init_pid
<
0
)
{
...
@@ -5084,6 +5076,7 @@ static int do_lxcapi_mount(struct lxc_container *c,
...
@@ -5084,6 +5076,7 @@ static int do_lxcapi_mount(struct lxc_container *c,
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
}
}
}
}
if
(
!
switch_to_ns
(
init_pid
,
"mnt"
))
{
if
(
!
switch_to_ns
(
init_pid
,
"mnt"
))
{
ERROR
(
"Failed to enter mount namespace"
);
ERROR
(
"Failed to enter mount namespace"
);
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
...
@@ -5092,6 +5085,7 @@ static int do_lxcapi_mount(struct lxc_container *c,
...
@@ -5092,6 +5085,7 @@ static int do_lxcapi_mount(struct lxc_container *c,
ret
=
create_mount_target
(
sb
.
st_mode
,
target
);
ret
=
create_mount_target
(
sb
.
st_mode
,
target
);
if
(
ret
<
0
)
if
(
ret
<
0
)
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
TRACE
(
"Created mount target
\"
%s
\"
"
,
target
);
suff
=
strrchr
(
template
,
'/'
);
suff
=
strrchr
(
template
,
'/'
);
if
(
!
suff
)
if
(
!
suff
)
...
@@ -5104,11 +5098,12 @@ static int do_lxcapi_mount(struct lxc_container *c,
...
@@ -5104,11 +5098,12 @@ static int do_lxcapi_mount(struct lxc_container *c,
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
}
}
ret
=
mount
(
path
,
target
,
NULL
,
MS_
REC
|
MS_MOVE
,
NULL
);
ret
=
mount
(
path
,
target
,
NULL
,
MS_
MOVE
|
MS_REC
,
NULL
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to move the mount from
\"
%s
\"
to
\"
%s
\"
"
,
path
,
target
);
SYSERROR
(
"Failed to move the mount from
\"
%s
\"
to
\"
%s
\"
"
,
path
,
target
);
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
}
}
TRACE
(
"Moved mount from
\"
%s
\"
to
\"
%s
\"
"
,
path
,
target
);
_exit
(
EXIT_SUCCESS
);
_exit
(
EXIT_SUCCESS
);
}
}
...
@@ -5127,6 +5122,7 @@ static int do_lxcapi_mount(struct lxc_container *c,
...
@@ -5127,6 +5122,7 @@ static int do_lxcapi_mount(struct lxc_container *c,
out
:
out
:
if
(
fd
>=
0
)
if
(
fd
>=
0
)
close
(
fd
);
close
(
fd
);
return
ret
;
return
ret
;
}
}
...
...
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