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
5221c891
Unverified
Commit
5221c891
authored
Jul 03, 2018
by
Christian Brauner
Committed by
GitHub
Jul 03, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2444 from 2xsec/bugfix
utils: move recursive_destroy() from cfgsng to utils.
parents
c5c4d6a3
abbec8b4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
108 deletions
+66
-108
cgfsng.c
src/lxc/cgroups/cgfsng.c
+0
-56
sync.c
src/lxc/sync.c
+1
-1
lxc_ls.c
src/lxc/tools/lxc_ls.c
+4
-51
utils.c
src/lxc/utils.c
+60
-0
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/cgroups/cgfsng.c
View file @
5221c891
...
@@ -1040,62 +1040,6 @@ static void lxc_cgfsng_print_basecg_debuginfo(char *basecginfo, char **klist,
...
@@ -1040,62 +1040,6 @@ static void lxc_cgfsng_print_basecg_debuginfo(char *basecginfo, char **klist,
TRACE
(
"named subsystem %d: %s"
,
k
,
*
it
);
TRACE
(
"named subsystem %d: %s"
,
k
,
*
it
);
}
}
static
int
recursive_destroy
(
char
*
dirname
)
{
int
ret
;
struct
dirent
*
direntp
;
DIR
*
dir
;
int
r
=
0
;
dir
=
opendir
(
dirname
);
if
(
!
dir
)
return
-
1
;
while
((
direntp
=
readdir
(
dir
)))
{
char
*
pathname
;
struct
stat
mystat
;
if
(
!
strcmp
(
direntp
->
d_name
,
"."
)
||
!
strcmp
(
direntp
->
d_name
,
".."
))
continue
;
pathname
=
must_make_path
(
dirname
,
direntp
->
d_name
,
NULL
);
ret
=
lstat
(
pathname
,
&
mystat
);
if
(
ret
<
0
)
{
if
(
!
r
)
WARN
(
"Failed to stat
\"
%s
\"
"
,
pathname
);
r
=
-
1
;
goto
next
;
}
if
(
!
S_ISDIR
(
mystat
.
st_mode
))
goto
next
;
ret
=
recursive_destroy
(
pathname
);
if
(
ret
<
0
)
r
=
-
1
;
next:
free
(
pathname
);
}
ret
=
rmdir
(
dirname
);
if
(
ret
<
0
)
{
if
(
!
r
)
SYSWARN
(
"Failed to delete
\"
%s
\"
"
,
dirname
);
r
=
-
1
;
}
ret
=
closedir
(
dir
);
if
(
ret
<
0
)
{
if
(
!
r
)
SYSWARN
(
"Failed to delete
\"
%s
\"
"
,
dirname
);
r
=
-
1
;
}
return
r
;
}
static
int
cgroup_rmdir
(
struct
hierarchy
**
hierarchies
,
static
int
cgroup_rmdir
(
struct
hierarchy
**
hierarchies
,
const
char
*
container_cgroup
)
const
char
*
container_cgroup
)
{
{
...
...
src/lxc/sync.c
View file @
5221c891
...
@@ -60,7 +60,7 @@ static int __sync_wait(int fd, int sequence)
...
@@ -60,7 +60,7 @@ static int __sync_wait(int fd, int sequence)
}
}
if
(
sync
!=
sequence
)
{
if
(
sync
!=
sequence
)
{
ERROR
(
"Invalid sequence number %d.
expected
%d"
,
ERROR
(
"Invalid sequence number %d.
Expected sequence number
%d"
,
sync
,
sequence
);
sync
,
sequence
);
return
-
1
;
return
-
1
;
}
}
...
...
src/lxc/tools/lxc_ls.c
View file @
5221c891
...
@@ -160,8 +160,6 @@ static int ls_remove_lock(const char *path, const char *name,
...
@@ -160,8 +160,6 @@ static int ls_remove_lock(const char *path, const char *name,
static
int
ls_serialize
(
int
wpipefd
,
struct
ls
*
n
);
static
int
ls_serialize
(
int
wpipefd
,
struct
ls
*
n
);
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
static
int
rm_r
(
char
*
dirname
);
static
const
struct
option
my_longopts
[]
=
{
static
const
struct
option
my_longopts
[]
=
{
{
"line"
,
no_argument
,
0
,
'1'
},
{
"line"
,
no_argument
,
0
,
'1'
},
{
"fancy"
,
no_argument
,
0
,
'f'
},
{
"fancy"
,
no_argument
,
0
,
'f'
},
...
@@ -1088,7 +1086,10 @@ static int ls_remove_lock(const char *path, const char *name,
...
@@ -1088,7 +1086,10 @@ static int ls_remove_lock(const char *path, const char *name,
if
(
check
<
0
||
(
size_t
)
check
>=
*
len_lockpath
)
if
(
check
<
0
||
(
size_t
)
check
>=
*
len_lockpath
)
goto
out
;
goto
out
;
(
void
)
rm_r
(
*
lockpath
);
ret
=
recursive_destroy
(
*
lockpath
);
if
(
ret
<
0
)
WARN
(
"Failed to destroy
\"
%s
\"
"
,
*
lockpath
);
ret
=
0
;
ret
=
0
;
out:
out:
...
@@ -1323,51 +1324,3 @@ static void ls_field_width(const struct ls *l, const size_t size,
...
@@ -1323,51 +1324,3 @@ static void ls_field_width(const struct ls *l, const size_t size,
}
}
}
}
}
}
static
int
rm_r
(
char
*
dirname
)
{
int
ret
;
struct
dirent
*
direntp
;
DIR
*
dir
;
int
r
=
0
;
dir
=
opendir
(
dirname
);
if
(
!
dir
)
return
-
1
;
while
((
direntp
=
readdir
(
dir
)))
{
char
*
pathname
;
struct
stat
mystat
;
if
(
!
strcmp
(
direntp
->
d_name
,
"."
)
||
!
strcmp
(
direntp
->
d_name
,
".."
))
continue
;
pathname
=
must_make_path
(
dirname
,
direntp
->
d_name
,
NULL
);
ret
=
lstat
(
pathname
,
&
mystat
);
if
(
ret
<
0
)
{
r
=
-
1
;
goto
next
;
}
if
(
!
S_ISDIR
(
mystat
.
st_mode
))
goto
next
;
ret
=
rm_r
(
pathname
);
if
(
ret
<
0
)
r
=
-
1
;
next:
free
(
pathname
);
}
ret
=
rmdir
(
dirname
);
if
(
ret
<
0
)
r
=
-
1
;
ret
=
closedir
(
dir
);
if
(
ret
<
0
)
r
=
-
1
;
return
r
;
}
src/lxc/utils.c
View file @
5221c891
...
@@ -2708,3 +2708,63 @@ int fd_cloexec(int fd, bool cloexec)
...
@@ -2708,3 +2708,63 @@ int fd_cloexec(int fd, bool cloexec)
return
0
;
return
0
;
}
}
int
recursive_destroy
(
char
*
dirname
)
{
int
ret
;
struct
dirent
*
direntp
;
DIR
*
dir
;
int
r
=
0
;
dir
=
opendir
(
dirname
);
if
(
!
dir
)
return
-
1
;
while
((
direntp
=
readdir
(
dir
)))
{
char
*
pathname
;
struct
stat
mystat
;
if
(
!
strcmp
(
direntp
->
d_name
,
"."
)
||
!
strcmp
(
direntp
->
d_name
,
".."
))
continue
;
pathname
=
must_make_path
(
dirname
,
direntp
->
d_name
,
NULL
);
ret
=
lstat
(
pathname
,
&
mystat
);
if
(
ret
<
0
)
{
if
(
!
r
)
WARN
(
"Failed to stat
\"
%s
\"
"
,
pathname
);
r
=
-
1
;
goto
next
;
}
if
(
!
S_ISDIR
(
mystat
.
st_mode
))
goto
next
;
ret
=
recursive_destroy
(
pathname
);
if
(
ret
<
0
)
r
=
-
1
;
next
:
free
(
pathname
);
}
ret
=
rmdir
(
dirname
);
if
(
ret
<
0
)
{
if
(
!
r
)
SYSWARN
(
"Failed to delete
\"
%s
\"
"
,
dirname
);
r
=
-
1
;
}
ret
=
closedir
(
dir
);
if
(
ret
<
0
)
{
if
(
!
r
)
SYSWARN
(
"Failed to delete
\"
%s
\"
"
,
dirname
);
r
=
-
1
;
}
return
r
;
}
src/lxc/utils.h
View file @
5221c891
...
@@ -616,5 +616,6 @@ static inline pid_t lxc_raw_gettid(void)
...
@@ -616,5 +616,6 @@ static inline pid_t lxc_raw_gettid(void)
/* Set a signal the child process will receive after the parent has died. */
/* Set a signal the child process will receive after the parent has died. */
extern
int
lxc_set_death_signal
(
int
signal
);
extern
int
lxc_set_death_signal
(
int
signal
);
extern
int
fd_cloexec
(
int
fd
,
bool
cloexec
);
extern
int
fd_cloexec
(
int
fd
,
bool
cloexec
);
extern
int
recursive_destroy
(
char
*
dirname
);
#endif
/* __LXC_UTILS_H */
#endif
/* __LXC_UTILS_H */
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