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
bdc0a15a
Unverified
Commit
bdc0a15a
authored
Feb 20, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: split out unified cgroup helpers
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
91fae3ab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
13 deletions
+35
-13
cgfsng.c
src/lxc/cgroups/cgfsng.c
+35
-13
No files found.
src/lxc/cgroups/cgfsng.c
View file @
bdc0a15a
...
...
@@ -3416,6 +3416,34 @@ static int cg_hybrid_init(struct cgroup_ops *ops, bool relative, bool unprivileg
return
0
;
}
static
inline
bool
__current_cgroup_unified_line
(
const
char
*
line
)
{
return
*
line
==
'0'
;
}
static
inline
char
*
__current_cgroup_unified
(
bool
relative
,
char
*
line
)
{
char
*
current_cgroup
;
line
+=
STRLITERALLEN
(
"0::"
);
if
(
!
abspath
(
line
))
return
ERR_PTR
(
-
EINVAL
);
/* remove init.scope */
if
(
!
relative
)
line
=
prune_init_scope
(
line
);
/* create a relative path */
line
=
deabs
(
line
);
current_cgroup
=
strdup
(
line
);
if
(
!
current_cgroup
)
return
ERR_PTR
(
-
ENOMEM
);
return
current_cgroup
;
}
/* Get current cgroup from /proc/self/cgroup for the cgroupfs v2 hierarchy. */
static
char
*
current_cgroup_unified
(
bool
relative
)
{
...
...
@@ -3430,22 +3458,16 @@ static char *current_cgroup_unified(bool relative)
return
NULL
;
lxc_iterate_parts
(
it
,
cgroup_info
,
"
\n
"
)
{
if
(
*
it
!=
'0'
)
continue
;
char
*
current_cgroup
;
it
+=
STRLITERALLEN
(
"0::"
);
if
(
!
abspath
(
it
))
return
log_error
(
NULL
,
"Corrupt cgroup info for %s process"
,
relative
?
"current"
:
"init"
);
/* remove init.scope */
if
(
!
relative
)
it
=
prune_init_scope
(
it
);
if
(
!
__current_cgroup_unified_line
(
it
))
continue
;
/* create a relative path */
it
=
deabs
(
it
);
current_cgroup
=
__current_cgroup_unified
(
relative
,
it
);
if
(
IS_ERR
(
current_cgroup
))
return
NULL
;
return
strdup
(
it
)
;
return
current_cgroup
;
}
return
log_error
(
NULL
,
"Failed to retrieve current cgroup for %s process"
,
...
...
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