diff --git a/library/std/src/os/yggdrasil/process.rs b/library/std/src/os/yggdrasil/process.rs index a801411c6bd..483a4b919ac 100644 --- a/library/std/src/os/yggdrasil/process.rs +++ b/library/std/src/os/yggdrasil/process.rs @@ -7,6 +7,7 @@ use yggdrasil_rt::process::{ProcessId, Signal, SpawnFlags}; use yggdrasil_rt::sys as syscall; use crate::io; +use crate::path::Path; use crate::process::{Child, Command, ExitStatus}; use crate::sealed::Sealed; use crate::sys_common::{AsInner, AsInnerMut}; @@ -28,7 +29,11 @@ pub trait CommandExt: Sealed { #[unstable(feature = "yggdrasil_os", issue = "none")] unsafe fn attach_tracing(&mut self) -> &mut Command; + #[unstable(feature = "yggdrasil_os", issue = "none")] fn disable_aslr(&mut self) -> &mut Command; + + #[unstable(feature = "yggdrasil_os", issue = "none")] + fn change_root>(&mut self, new: P) -> &mut Command; } #[unstable(feature = "yggdrasil_os", issue = "none")] @@ -58,6 +63,11 @@ impl CommandExt for Command { self.as_inner_mut().flags |= SpawnFlags::DISABLE_ASLR; self } + + fn change_root>(&mut self, new: P) -> &mut Command { + self.as_inner_mut().change_root(new); + self + } } #[unstable(feature = "yggdrasil_os", issue = "none")] diff --git a/library/std/src/sys/pal/yggdrasil/process/command.rs b/library/std/src/sys/pal/yggdrasil/process/command.rs index d30e16025ec..32d466ea531 100644 --- a/library/std/src/sys/pal/yggdrasil/process/command.rs +++ b/library/std/src/sys/pal/yggdrasil/process/command.rs @@ -17,6 +17,7 @@ pub struct Command { args: Vec, env: CommandEnv, cwd: Option, + pub(crate) root: Option, pub(crate) pgroup: Option, pub(crate) gain_terminal: Option, @@ -39,6 +40,7 @@ impl Command { args: vec![], env: Default::default(), cwd: None, + root: None, pgroup: None, gain_terminal: None, attach_trace: false, @@ -164,6 +166,7 @@ impl Command { })); let directory = self.cwd.as_ref().map(|cwd| cwd.to_str().unwrap()); + let root = self.root.as_ref().map(|root| root.to_str().unwrap()); let environment = &Vec::from_iter(envs.iter().map(|x| x.as_str())); @@ -172,6 +175,7 @@ impl Command { arguments, environment, directory, + root, optional: &optional, flags: self.flags, }; @@ -180,6 +184,10 @@ impl Command { Ok(Process { pid }) } + + pub(crate) fn change_root>(&mut self, root: P) { + self.root = Some(root.as_ref().into()); + } } impl<'a> Iterator for CommandArgs<'a> {