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
5c7dbbbe
Unverified
Commit
5c7dbbbe
authored
Feb 09, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroup_utils: use __do_free
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
49cc76a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
25 deletions
+9
-25
cgroup_utils.c
src/lxc/cgroups/cgroup_utils.c
+9
-25
No files found.
src/lxc/cgroups/cgroup_utils.c
View file @
5c7dbbbe
...
...
@@ -33,6 +33,7 @@
#include "cgroup_utils.h"
#include "config.h"
#include "macro.h"
#include "memory_utils.h"
#include "utils.h"
int
get_cgroup_version
(
char
*
line
)
...
...
@@ -65,12 +66,8 @@ bool is_cgroupfs_v2(char *line)
bool
test_writeable_v1
(
char
*
mountpoint
,
char
*
path
)
{
char
*
fullpath
=
must_make_path
(
mountpoint
,
path
,
NULL
);
int
ret
;
ret
=
access
(
fullpath
,
W_OK
);
free
(
fullpath
);
return
ret
==
0
;
__do_free
char
*
fullpath
=
must_make_path
(
mountpoint
,
path
,
NULL
);
return
(
access
(
fullpath
,
W_OK
)
==
0
);
}
bool
test_writeable_v2
(
char
*
mountpoint
,
char
*
path
)
...
...
@@ -81,39 +78,26 @@ bool test_writeable_v2(char *mountpoint, char *path)
* file.
*/
int
ret
;
char
*
cgroup_path
,
*
cgroup_procs_file
,
*
cgroup_threads_file
;
__do_free
char
*
cgroup_path
=
NULL
,
*
cgroup_procs_file
=
NULL
,
*
cgroup_threads_file
=
NULL
;
cgroup_path
=
must_make_path
(
mountpoint
,
path
,
NULL
);
cgroup_procs_file
=
must_make_path
(
cgroup_path
,
"cgroup.procs"
,
NULL
);
ret
=
access
(
cgroup_path
,
W_OK
);
if
(
ret
<
0
)
{
free
(
cgroup_path
);
free
(
cgroup_procs_file
);
if
(
ret
<
0
)
return
false
;
}
ret
=
access
(
cgroup_procs_file
,
W_OK
);
free
(
cgroup_procs_file
);
if
(
ret
<
0
)
{
free
(
cgroup_path
);
if
(
ret
<
0
)
return
false
;
}
/* Newer versions of cgroup2 now also require write access to the
* "cgroup.threads" file.
*/
cgroup_threads_file
=
must_make_path
(
cgroup_path
,
"cgroup.threads"
,
NULL
);
free
(
cgroup_path
);
if
(
!
file_exists
(
cgroup_threads_file
))
{
free
(
cgroup_threads_file
);
if
(
!
file_exists
(
cgroup_threads_file
))
return
true
;
}
ret
=
access
(
cgroup_threads_file
,
W_OK
);
free
(
cgroup_threads_file
);
if
(
ret
<
0
)
return
false
;
return
ret
==
0
;
return
(
access
(
cgroup_threads_file
,
W_OK
)
==
0
)
;
}
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