]> git.proxmox.com Git - pve-lxc-syscalld.git/commitdiff
revert pidfd_open patches
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 29 Jan 2020 13:38:41 +0000 (14:38 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 29 Jan 2020 13:38:42 +0000 (14:38 +0100)
They act like proc fds but aren't opened with O_DIRECTORY,
so we cannot use `openat()` yet. Maybe with a future kernel
extension...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/process/pid_fd.rs

index 41aa3ee84d728f093bf1ceaf1c3493e7506516a9..86871f2e65ebc62f2e5728629c1fb6ad451cc3ff 100644 (file)
@@ -1,6 +1,6 @@
 //! pidfd helper functionality
 
-use std::ffi::{CStr, OsString};
+use std::ffi::{CStr, CString, OsString};
 use std::io::{self, BufRead, BufReader};
 use std::os::raw::c_int;
 use std::os::unix::ffi::OsStringExt;
@@ -18,16 +18,17 @@ use super::{CGroups, IdMap, IdMapEntry, ProcStatus, Uids, UserCaps};
 pub struct PidFd(RawFd, pid_t);
 file_descriptor_impl!(PidFd);
 
-pub const SYS_PIDFD_OPEN: libc::c_long = 434; // asm-generic
-
 impl PidFd {
     pub fn current() -> io::Result<Self> {
         Self::open(unsafe { libc::getpid() })
     }
 
     pub fn open(pid: pid_t) -> io::Result<Self> {
-        let fd = c_try!(unsafe { libc::syscall(SYS_PIDFD_OPEN, pid, 0) });
-        Ok(Self(fd as RawFd, pid))
+        let path = CString::new(format!("/proc/{}", pid)).unwrap();
+
+        let fd = c_try!(unsafe { libc::open(path.as_ptr(), libc::O_DIRECTORY | libc::O_CLOEXEC) });
+
+        Ok(Self(fd, pid))
     }
 
     /// Turn a valid pid file descriptor into a PidFd.