mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-11-06 12:37:44 +08:00
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.
This commit is contained in:
parent
6412e0cd58
commit
a30fc94a00
@ -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.
|
||||
|
||||
53
recipes/wip/net/onion-routing/arti/redox.patch
Normal file
53
recipes/wip/net/onion-routing/arti/redox.patch
Normal file
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user