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
7a48a41f
Commit
7a48a41f
authored
Sep 08, 2015
by
Christian Brauner
Committed by
Stéphane Graber
Sep 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Destroy bdevs using bdev_destroy() from bdev.h
Signed-off-by:
Christian Brauner
<
christianvanbrauner@gmail.com
>
Acked-by:
Serge E. Hallyn
<
serge.hallyn@ubuntu.com
>
parent
3563f361
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
43 deletions
+19
-43
lxccontainer.c
src/lxc/lxccontainer.c
+19
-43
No files found.
src/lxc/lxccontainer.c
View file @
7a48a41f
...
@@ -2119,48 +2119,25 @@ static bool has_snapshots(struct lxc_container *c)
...
@@ -2119,48 +2119,25 @@ static bool has_snapshots(struct lxc_container *c)
return
count
>
0
;
return
count
>
0
;
}
}
static
bool
do_destroy_container
(
struct
lxc_conf
*
conf
)
{
if
(
am_unpriv
())
{
if
(
userns_exec_1
(
conf
,
bdev_destroy_wrapper
,
conf
)
<
0
)
return
false
;
return
true
;
}
return
bdev_destroy
(
conf
);
}
static
int
lxc_rmdir_onedev_wrapper
(
void
*
data
)
static
int
lxc_rmdir_onedev_wrapper
(
void
*
data
)
{
{
char
*
arg
=
(
char
*
)
data
;
char
*
arg
=
(
char
*
)
data
;
return
lxc_rmdir_onedev
(
arg
,
"snaps"
);
return
lxc_rmdir_onedev
(
arg
,
"snaps"
);
}
}
static
int
do_bdev_destroy
(
struct
lxc_conf
*
conf
)
{
struct
bdev
*
r
;
int
ret
=
0
;
r
=
bdev_init
(
conf
,
conf
->
rootfs
.
path
,
conf
->
rootfs
.
mount
,
NULL
);
if
(
!
r
)
return
-
1
;
if
(
r
->
ops
->
destroy
(
r
)
<
0
)
ret
=
-
1
;
bdev_put
(
r
);
return
ret
;
}
static
int
bdev_destroy_wrapper
(
void
*
data
)
{
struct
lxc_conf
*
conf
=
data
;
if
(
setgid
(
0
)
<
0
)
{
ERROR
(
"Failed to setgid to 0"
);
return
-
1
;
}
if
(
setgroups
(
0
,
NULL
)
<
0
)
WARN
(
"Failed to clear groups"
);
if
(
setuid
(
0
)
<
0
)
{
ERROR
(
"Failed to setuid to 0"
);
return
-
1
;
}
return
do_bdev_destroy
(
conf
);
}
static
bool
container_destroy
(
struct
lxc_container
*
c
)
static
bool
container_destroy
(
struct
lxc_container
*
c
)
{
{
bool
bret
=
false
;
bool
bret
=
false
;
int
ret
;
int
ret
=
0
;
if
(
!
c
||
!
do_lxcapi_is_defined
(
c
))
if
(
!
c
||
!
do_lxcapi_is_defined
(
c
))
return
false
;
return
false
;
...
@@ -2182,16 +2159,13 @@ static bool container_destroy(struct lxc_container *c)
...
@@ -2182,16 +2159,13 @@ static bool container_destroy(struct lxc_container *c)
}
}
}
}
if
(
c
->
lxc_conf
&&
c
->
lxc_conf
->
rootfs
.
path
&&
c
->
lxc_conf
->
rootfs
.
mount
)
{
if
(
c
->
lxc_conf
&&
c
->
lxc_conf
->
rootfs
.
path
&&
c
->
lxc_conf
->
rootfs
.
mount
)
{
if
(
am_unpriv
())
if
(
!
do_destroy_container
(
c
->
lxc_conf
))
{
ret
=
userns_exec_1
(
c
->
lxc_conf
,
bdev_destroy_wrapper
,
c
->
lxc_conf
);
ERROR
(
"Error destroying rootfs for %s"
,
c
->
name
);
else
goto
out
;
ret
=
do_bdev_destroy
(
c
->
lxc_conf
);
}
if
(
ret
<
0
)
{
INFO
(
"Destroyed rootfs for %s"
,
c
->
name
);
ERROR
(
"Error destroying rootfs for %s"
,
c
->
name
);
}
goto
out
;
}
}
mod_all_rdeps
(
c
,
false
);
mod_all_rdeps
(
c
,
false
);
...
@@ -2206,6 +2180,8 @@ static bool container_destroy(struct lxc_container *c)
...
@@ -2206,6 +2180,8 @@ static bool container_destroy(struct lxc_container *c)
ERROR
(
"Error destroying container directory for %s"
,
c
->
name
);
ERROR
(
"Error destroying container directory for %s"
,
c
->
name
);
goto
out
;
goto
out
;
}
}
INFO
(
"Destroyed directory for %s"
,
c
->
name
);
bret
=
true
;
bret
=
true
;
out
:
out
:
...
...
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