Skip to content

Remove usage of legacy scheme paths on RedoxOS #138457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,6 @@ where
}
}

// Detect scheme on Redox
pub(crate) fn has_redox_scheme(s: &[u8]) -> bool {
cfg!(target_os = "redox") && s.contains(&b':')
}

////////////////////////////////////////////////////////////////////////////////
// Cross-platform, iterator-independent parsing
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2834,8 +2829,7 @@ impl Path {
Components {
path: self.as_u8_slice(),
prefix,
has_physical_root: has_physical_root(self.as_u8_slice(), prefix)
|| has_redox_scheme(self.as_u8_slice()),
has_physical_root: has_physical_root(self.as_u8_slice(), prefix),
front: State::Prefix,
back: State::Body,
}
Expand Down
7 changes: 6 additions & 1 deletion library/std/src/sys/pal/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,12 @@ pub fn current_exe() -> io::Result<PathBuf> {
}
}

#[cfg(any(target_os = "redox", target_os = "rtems"))]
#[cfg(target_os = "redox")]
pub fn current_exe() -> io::Result<PathBuf> {
crate::fs::read_to_string("/scheme/sys/exe").map(PathBuf::from)
}

#[cfg(target_os = "rtems")]
pub fn current_exe() -> io::Result<PathBuf> {
crate::fs::read_to_string("sys:exe").map(PathBuf::from)
}
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/sys/pal/unix/process/process_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ use crate::{fmt, io, ptr};
cfg_if::cfg_if! {
if #[cfg(target_os = "fuchsia")] {
// fuchsia doesn't have /dev/null
} else if #[cfg(target_os = "redox")] {
const DEV_NULL: &CStr = c"null:";
} else if #[cfg(target_os = "vxworks")] {
const DEV_NULL: &CStr = c"/null";
} else {
Expand Down
5 changes: 1 addition & 4 deletions library/std/src/sys/path/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ pub(crate) fn absolute(path: &Path) -> io::Result<PathBuf> {
}

pub(crate) fn is_absolute(path: &Path) -> bool {
if cfg!(target_os = "redox") {
// FIXME: Allow Redox prefixes
path.has_root() || crate::path::has_redox_scheme(path.as_u8_slice())
} else if cfg!(any(unix, target_os = "hermit", target_os = "wasi")) {
if cfg!(any(unix, target_os = "hermit", target_os = "wasi")) {
path.has_root()
} else {
path.has_root() && path.prefix().is_some()
Expand Down
Loading