diff --git a/init/src/service.rs b/init/src/service.rs index dfa8b066c5..d4f15baeda 100644 --- a/init/src/service.rs +++ b/init/src/service.rs @@ -37,16 +37,25 @@ pub enum ServiceType { } fn create_pipe() -> io::Result<(File, OwnedFd)> { - let rd = libredox::Fd::open( + let ns_fd = libredox::call::getns() + .map_err(|e| io::Error::from_raw_os_error(e.errno()))?; + + let rd_fd = syscall::openat( + ns_fd, "/scheme/pipe", - libredox::flag::O_RDONLY | libredox::flag::O_CLOEXEC, + syscall::flag::O_RDONLY | syscall::flag::O_CLOEXEC, 0, ) - .map_err(|e| io::Error::from_raw_os_error(e.errno()))?; - let wr_raw = syscall::dup(rd.raw(), b"write") - .map_err(|e| io::Error::from_raw_os_error(e.errno))?; + .map_err(|e| io::Error::from_raw_os_error(e.errno))?; + + let wr_raw = syscall::dup(rd_fd, b"write") + .map_err(|e| { + let _ = syscall::close(rd_fd); + io::Error::from_raw_os_error(e.errno) + })?; + let wr = unsafe { OwnedFd::from_raw_fd(wr_raw as i32) }; - let rd = unsafe { File::from_raw_fd(rd.into_raw() as i32) }; + let rd = unsafe { File::from_raw_fd(rd_fd as i32) }; Ok((rd, wr)) }