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
cd5d966f
Unverified
Commit
cd5d966f
authored
Feb 21, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: remove unused helpers
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
588b1d3b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
86 deletions
+0
-86
cgroup_utils.c
src/lxc/cgroups/cgroup_utils.c
+0
-66
cgroup_utils.h
src/lxc/cgroups/cgroup_utils.h
+0
-20
No files found.
src/lxc/cgroups/cgroup_utils.c
View file @
cd5d966f
...
...
@@ -20,72 +20,6 @@
lxc_log_define
(
cgroup_utils
,
lxc
);
int
get_cgroup_version
(
char
*
line
)
{
if
(
is_cgroupfs_v1
(
line
))
return
CGROUP_SUPER_MAGIC
;
if
(
is_cgroupfs_v2
(
line
))
return
CGROUP2_SUPER_MAGIC
;
return
0
;
}
bool
is_cgroupfs_v1
(
char
*
line
)
{
char
*
p
=
strstr
(
line
,
" - "
);
if
(
!
p
)
return
false
;
return
strnequal
(
p
,
" - cgroup "
,
10
);
}
bool
is_cgroupfs_v2
(
char
*
line
)
{
char
*
p
=
strstr
(
line
,
" - "
);
if
(
!
p
)
return
false
;
return
strnequal
(
p
,
" - cgroup2 "
,
11
);
}
bool
test_writeable_v1
(
char
*
mountpoint
,
char
*
path
)
{
__do_free
char
*
fullpath
=
must_make_path
(
mountpoint
,
path
,
NULL
);
return
(
access
(
fullpath
,
W_OK
)
==
0
);
}
bool
test_writeable_v2
(
char
*
mountpoint
,
char
*
path
)
{
/* In order to move ourselves into an appropriate sub-cgroup we need to
* have write access to the parent cgroup's "cgroup.procs" file, i.e. we
* need to have write access to the our current cgroups's "cgroup.procs"
* file.
*/
int
ret
;
__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
)
return
false
;
ret
=
access
(
cgroup_procs_file
,
W_OK
);
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
);
if
(
!
file_exists
(
cgroup_threads_file
))
return
true
;
return
(
access
(
cgroup_threads_file
,
W_OK
)
==
0
);
}
bool
unified_cgroup_fd
(
int
fd
)
{
...
...
src/lxc/cgroups/cgroup_utils.h
View file @
cd5d966f
...
...
@@ -9,26 +9,6 @@
#include "compiler.h"
#include "file_utils.h"
/* Retrieve the cgroup version of a given entry from /proc/<pid>/mountinfo. */
__hidden
extern
int
get_cgroup_version
(
char
*
line
);
/* Check if given entry from /proc/<pid>/mountinfo is a cgroupfs v1 mount. */
__hidden
extern
bool
is_cgroupfs_v1
(
char
*
line
);
/* Check if given entry from /proc/<pid>/mountinfo is a cgroupfs v2 mount. */
__hidden
extern
bool
is_cgroupfs_v2
(
char
*
line
);
/* Given a v1 hierarchy @mountpoint and base @path, verify that we can create
* directories underneath it.
*/
__hidden
extern
bool
test_writeable_v1
(
char
*
mountpoint
,
char
*
path
);
/* Given a v2 hierarchy @mountpoint and base @path, verify that we can create
* directories underneath it and that we have write access to the cgroup's
* "cgroup.procs" file.
*/
__hidden
extern
bool
test_writeable_v2
(
char
*
mountpoint
,
char
*
path
);
__hidden
extern
bool
unified_cgroup_fd
(
int
fd
);
static
inline
bool
cgns_supported
(
void
)
...
...
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