From f095ac2685627d72de7c93420b9584faaf06b8d3 Mon Sep 17 00:00:00 2001 From: reigadegr <2722688642@qq.com> Date: Wed, 23 Sep 2026 08:00:03 +0800 Subject: [PATCH] fix(fs): Enable `sendfile` on Android The `sendfile` function, its module declaration, and its re-export were gated on `target_os = "linux"`, which excludes Android. Since Android uses the Linux kernel and its bionic libc provides `sendfile64`, these should be gated on `linux_kernel` instead. This is consistent with the rest of the codebase (e.g. `copy_file_range`, `raw_dir`, `statx`, `ioctl` all use `linux_kernel`) and with `sendfile.rs` itself, which already uses `#[cfg(linux_kernel)]` on the public function. The mismatch meant the module was never compiled on Android despite the function being correctly gated. --- src/backend/libc/fs/syscalls.rs | 2 +- src/fs/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/libc/fs/syscalls.rs b/src/backend/libc/fs/syscalls.rs index c95eaf561..07000f3dc 100644 --- a/src/backend/libc/fs/syscalls.rs +++ b/src/backend/libc/fs/syscalls.rs @@ -1908,7 +1908,7 @@ const SYS_OPENAT2: i32 = 437; #[cfg(all(linux_kernel, target_pointer_width = "64"))] const SYS_OPENAT2: i64 = 437; -#[cfg(target_os = "linux")] +#[cfg(linux_kernel)] pub(crate) fn sendfile( out_fd: BorrowedFd<'_>, in_fd: BorrowedFd<'_>, diff --git a/src/fs/mod.rs b/src/fs/mod.rs index dfeed87ad..baf9d7e14 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -51,7 +51,7 @@ mod openat2; #[cfg(linux_kernel)] mod raw_dir; mod seek_from; -#[cfg(target_os = "linux")] +#[cfg(linux_kernel)] mod sendfile; #[cfg(not(target_os = "espidf"))] mod special; @@ -117,7 +117,7 @@ pub use openat2::openat2; #[cfg(linux_kernel)] pub use raw_dir::{RawDir, RawDirEntry}; pub use seek_from::SeekFrom; -#[cfg(target_os = "linux")] +#[cfg(linux_kernel)] pub use sendfile::sendfile; #[cfg(not(target_os = "espidf"))] pub use special::*;