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
5ad5ab82
Unverified
Commit
5ad5ab82
authored
Feb 19, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: fix prune_init_scope()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
71e50d54
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
14 deletions
+36
-14
cgroup.c
src/lxc/cgroups/cgroup.c
+0
-12
cgroup.h
src/lxc/cgroups/cgroup.h
+0
-2
cgroup_utils.c
src/lxc/cgroups/cgroup_utils.c
+29
-0
cgroup_utils.h
src/lxc/cgroups/cgroup_utils.h
+7
-0
No files found.
src/lxc/cgroups/cgroup.c
View file @
5ad5ab82
...
@@ -106,15 +106,3 @@ void cgroup_exit(struct cgroup_ops *ops)
...
@@ -106,15 +106,3 @@ void cgroup_exit(struct cgroup_ops *ops)
return
;
return
;
}
}
#define INIT_SCOPE "/init.scope"
char
*
prune_init_scope
(
char
*
cg
)
{
if
(
is_empty_string
(
cg
))
return
NULL
;
if
(
strnequal
(
cg
,
INIT_SCOPE
,
STRLITERALLEN
(
INIT_SCOPE
)))
return
cg
+
STRLITERALLEN
(
INIT_SCOPE
);
return
cg
;
}
src/lxc/cgroups/cgroup.h
View file @
5ad5ab82
...
@@ -207,8 +207,6 @@ __hidden extern struct cgroup_ops *cgroup_init(struct lxc_conf *conf);
...
@@ -207,8 +207,6 @@ __hidden extern struct cgroup_ops *cgroup_init(struct lxc_conf *conf);
__hidden
extern
void
cgroup_exit
(
struct
cgroup_ops
*
ops
);
__hidden
extern
void
cgroup_exit
(
struct
cgroup_ops
*
ops
);
define_cleanup_function
(
struct
cgroup_ops
*
,
cgroup_exit
);
define_cleanup_function
(
struct
cgroup_ops
*
,
cgroup_exit
);
__hidden
extern
char
*
prune_init_scope
(
char
*
cg
);
__hidden
extern
int
cgroup_attach
(
const
struct
lxc_conf
*
conf
,
const
char
*
name
,
__hidden
extern
int
cgroup_attach
(
const
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
,
pid_t
pid
);
const
char
*
lxcpath
,
pid_t
pid
);
__hidden
extern
int
cgroup_get
(
const
char
*
name
,
const
char
*
lxcpath
,
__hidden
extern
int
cgroup_get
(
const
char
*
name
,
const
char
*
lxcpath
,
...
...
src/lxc/cgroups/cgroup_utils.c
View file @
5ad5ab82
...
@@ -159,3 +159,32 @@ int cgroup_tree_prune(int dfd, const char *path)
...
@@ -159,3 +159,32 @@ int cgroup_tree_prune(int dfd, const char *path)
return
0
;
return
0
;
}
}
#define INIT_SCOPE "/init.scope"
char
*
prune_init_scope
(
char
*
path
)
{
char
*
slash
=
path
;
size_t
len
;
/*
* This function can only be called on information parsed from
* /proc/<pid>/cgroup. The file displays the current cgroup of the
* process as absolute paths. So if we are passed a non-absolute path
* things are way wrong.
*/
if
(
!
abspath
(
path
))
return
ret_set_errno
(
NULL
,
EINVAL
);
len
=
strlen
(
path
);
if
(
len
<
STRLITERALLEN
(
INIT_SCOPE
))
return
path
;
slash
+=
(
len
-
STRLITERALLEN
(
INIT_SCOPE
));
if
(
strequal
(
slash
,
INIT_SCOPE
))
{
if
(
slash
==
path
)
slash
++
;
*
slash
=
'\0'
;
}
return
path
;
}
src/lxc/cgroups/cgroup_utils.h
View file @
5ad5ab82
...
@@ -43,4 +43,11 @@ static inline bool cgns_supported(void)
...
@@ -43,4 +43,11 @@ static inline bool cgns_supported(void)
__hidden
extern
int
cgroup_tree_prune
(
int
dfd
,
const
char
*
path
);
__hidden
extern
int
cgroup_tree_prune
(
int
dfd
,
const
char
*
path
);
/*
* This function can only be called on information parsed from
* /proc/<pid>/cgroup or on absolute paths and it will verify the latter and
* return NULL if a relative path is passed.
*/
__hidden
extern
char
*
prune_init_scope
(
char
*
path
);
#endif
/* __LXC_CGROUP_UTILS_H */
#endif
/* __LXC_CGROUP_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