1
0
mirror of https://github.com/containers/youki synced 2024-11-23 17:32:15 +01:00

Merge pull request #562 from Furisto/cg-log-data-value

Log value that is written to cgroup file
This commit is contained in:
utam0k 2021-12-24 21:22:03 +09:00 committed by GitHub
commit 4dc8863320
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23

@ -100,21 +100,22 @@ pub fn write_cgroup_file_str<P: AsRef<Path>>(path: P, data: &str) -> Result<()>
.open(path.as_ref())
.with_context(|| format!("failed to open {:?}", path.as_ref()))?
.write_all(data.as_bytes())
.with_context(|| format!("failed to write to {:?}", path.as_ref()))?;
.with_context(|| format!("failed to write {} to {:?}", data, path.as_ref()))?;
Ok(())
}
#[inline]
pub fn write_cgroup_file<P: AsRef<Path>, T: ToString>(path: P, data: T) -> Result<()> {
let data = data.to_string();
fs::OpenOptions::new()
.create(false)
.write(true)
.truncate(false)
.open(path.as_ref())
.with_context(|| format!("failed to open {:?}", path.as_ref()))?
.write_all(data.to_string().as_bytes())
.with_context(|| format!("failed to write to {:?}", path.as_ref()))?;
.write_all(data.as_bytes())
.with_context(|| format!("failed to write {} to {:?}", data, path.as_ref()))?;
Ok(())
}