From a30fc94a00aa6ed97a02aaf5ab4edbb74865c87a Mon Sep 17 00:00:00 2001 From: Niel Duysters Date: Mon, 26 Oct 2026 01:56:48 +0100 Subject: [PATCH] Add redox.patch for Arti to avoid "try_lock() not supported" Arti creates a state.lock and calls `File::try_lock()`, but Redox returns "try_lock() not supported". This patch makes sure we use Redox libc's `flock`. This is using the same workaround Arti already had for Android. --- .../wip/net/onion-routing/arti/recipe.toml | 1 + .../wip/net/onion-routing/arti/redox.patch | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 recipes/wip/net/onion-routing/arti/redox.patch diff --git a/recipes/wip/net/onion-routing/arti/recipe.toml b/recipes/wip/net/onion-routing/arti/recipe.toml index 375088c65..803062cb1 100644 --- a/recipes/wip/net/onion-routing/arti/recipe.toml +++ b/recipes/wip/net/onion-routing/arti/recipe.toml @@ -1,6 +1,7 @@ [source] git = "https://gitlab.torproject.org/tpo/core/arti" shallow_clone = true +patches = ["redox.patch"] [build] template = "cargo" # TODO: Remove `static-sqlite` feature once Redox' sqlite3-package is fully functional. diff --git a/recipes/wip/net/onion-routing/arti/redox.patch b/recipes/wip/net/onion-routing/arti/redox.patch new file mode 100644 index 000000000..579b62d4f --- /dev/null +++ b/recipes/wip/net/onion-routing/arti/redox.patch @@ -0,0 +1,53 @@ +diff --git a/crates/fslock-guard/Cargo.toml b/crates/fslock-guard/Cargo.toml +index 9cbffb2c..2fd42d35 100644 +--- a/crates/fslock-guard/Cargo.toml ++++ b/crates/fslock-guard/Cargo.toml +@@ -21,7 +21,7 @@ full = [] + [dependencies] + thiserror = "2" + +-[target.'cfg(target_os = "android")'.dependencies] ++[target.'cfg(any(target_os = "android", target_os = "redox"))'.dependencies] + libc = "0.2" + + [target.'cfg(unix)'.dev-dependencies] +diff --git a/crates/fslock-guard/src/lib.rs b/crates/fslock-guard/src/lib.rs +index b5e938bb..7c32168c 100644 +--- a/crates/fslock-guard/src/lib.rs ++++ b/crates/fslock-guard/src/lib.rs +@@ -177,7 +177,7 @@ impl Drop for LockFileGuard { + /// Try to lock `f`, blocking if need be. + /// + /// On non-android, this just calls [`fs::File::lock`]. +-#[cfg(not(target_os = "android"))] ++#[cfg(not(any(target_os = "android", target_os = "redox")))] + fn do_lock(f: &fs::File) -> std::io::Result<()> { + f.lock() + } +@@ -185,7 +185,7 @@ fn do_lock(f: &fs::File) -> std::io::Result<()> { + /// Try to lock `f`, without blocking. + /// + /// On non-android, this just calls [`fs::File::try_lock`]. +-#[cfg(not(target_os = "android"))] ++#[cfg(not(any(target_os = "android", target_os = "redox")))] + fn do_try_lock(f: &fs::File) -> Result<(), std::fs::TryLockError> { + f.try_lock() + } +@@ -204,7 +204,7 @@ fn do_try_lock(f: &fs::File) -> Result<(), std::fs::TryLockError> { + // TODO MSRV ????: we can remove this once Rust supports file locking on Android + // at our MSRV. As of May 2026, https://github.com/rust-lang/rust/pull/157038/ + // seems like the likeliest MR for that, but it has not been merged. +-#[cfg(target_os = "android")] ++#[cfg(any(target_os = "android", target_os = "redox"))] + fn do_lock(f: &fs::File) -> std::io::Result<()> { + use std::os::fd::AsRawFd; + +@@ -231,7 +231,7 @@ fn do_lock(f: &fs::File) -> std::io::Result<()> { + /// on those filesystems. + // + // TODO MSRV ????: See 'TODO MSRV' on do_lock above. +-#[cfg(target_os = "android")] ++#[cfg(any(target_os = "android", target_os = "redox"))] + fn do_try_lock(f: &fs::File) -> Result<(), std::fs::TryLockError> { + use std::os::fd::AsRawFd; +