X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2Fprocess%2Fpid_fd.rs;h=1caf8f262bd8c381c274db90771a7ba0b98e8734;hb=fe73c2fb92d1c30ff584da906f5ae75bfe9951ab;hp=8306ee9f1ed23e66d465c2f2916c36abde941aab;hpb=c7f2eab1ae1ea5fcc1ececffb9ec0a7c1a3b96f5;p=pve-lxc-syscalld.git diff --git a/src/process/pid_fd.rs b/src/process/pid_fd.rs index 8306ee9..1caf8f2 100644 --- a/src/process/pid_fd.rs +++ b/src/process/pid_fd.rs @@ -6,7 +6,7 @@ use std::os::raw::c_int; use std::os::unix::ffi::OsStringExt; use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; -use failure::{bail, Error}; +use anyhow::{bail, Error}; use libc::pid_t; use crate::capability::Capabilities; @@ -20,14 +20,7 @@ file_descriptor_impl!(PidFd); impl PidFd { pub fn current() -> io::Result { - let fd = c_try!(unsafe { - libc::open( - b"/proc/self\0".as_ptr() as _, - libc::O_DIRECTORY | libc::O_CLOEXEC, - ) - }); - - Ok(Self(fd, unsafe { libc::getpid() })) + Self::open(unsafe { libc::getpid() }) } pub fn open(pid: pid_t) -> io::Result { @@ -229,7 +222,10 @@ impl PidFd { cgroups.v2 = Some(path); } else { for entry in name.split(',') { - cgroups.v1.insert(entry.to_string(), path.clone()); + cgroups + .v1 + .get_or_insert_with(Default::default) + .insert(entry.to_string(), path.clone()); } } }