add get_max_depth

This commit is contained in:
mii443
2024-10-17 07:58:12 +00:00
parent 49b12fd296
commit d88b3ea4da

View File

@ -5,7 +5,7 @@ use std::{
str::FromStr, str::FromStr,
}; };
use super::{cgroup_stat::CGroupStat, controller::Controller}; use super::{cgroup_stat::CGroupStat, controller::Controller, limit_value::CGroupLimitValue};
pub struct CGroup { pub struct CGroup {
pub path: PathBuf, pub path: PathBuf,
@ -98,4 +98,10 @@ impl CGroup {
Ok(CGroupStat::from_str(&stat).unwrap()) Ok(CGroupStat::from_str(&stat).unwrap())
} }
pub fn get_max_depth(&self) -> Result<CGroupLimitValue<u64>, std::io::Error> {
let max = self.read("cgroup.max.depth")?;
Ok(CGroupLimitValue::from_str(&max).unwrap())
}
} }