From e1e05d3a1ce9909da02cd36a0a789f49cc372297 Mon Sep 17 00:00:00 2001 From: Tim Zhang Date: Wed, 16 Dec 2020 21:06:04 +0800 Subject: [PATCH] Make new_with_relative_paths=new and load_with_relative_paths=new in v2 Because the relative_paths is only valid for cgroup v1, the v2 use unified hierarchy. Signed-off-by: Tim Zhang --- src/cgroup.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cgroup.rs b/src/cgroup.rs index 63f413a..5dedab5 100644 --- a/src/cgroup.rs +++ b/src/cgroup.rs @@ -86,6 +86,8 @@ impl Cgroup { /// Create a new control group in the hierarchy `hier`, with name `path` and `relative_paths` /// /// Returns a handle to the control group that can be used to manipulate it. + /// + /// Note that this method is only meaningful for cgroup v1, call it is equivalent to call `new` in the v2 mode pub fn new_with_relative_paths>( hier: Box, path: P, @@ -123,11 +125,18 @@ impl Cgroup { /// /// Returns a handle to the control group (that possibly does not exist until `create()` has /// been called on the cgroup. + /// + /// Note that this method is only meaningful for cgroup v1, call it is equivalent to call `load` in the v2 mode pub fn load_with_relative_paths>( hier: Box, path: P, relative_paths: HashMap, ) -> Cgroup { + // relative_paths only valid for cgroup v1 + if hier.v2() { + return Self::load(hier, path); + } + let path = path.as_ref(); let mut subsystems = hier.subsystems(); if path.as_os_str() != "" {