Skip to content

Commit

Permalink
Add O_RSYNC + fallocate on solarish, and fadvise on illumos (#1191)
Browse files Browse the repository at this point in the history
These functions were added to libc 0.2.161, and are required by some downstream crates.
  • Loading branch information
sunshowers authored and sunfishcode committed Oct 17, 2024
1 parent f0be3b2 commit 1bc2840
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ once_cell = { version = "1.5.2", optional = true }
[target.'cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", any(target_endian = "little", target_arch = "s390x"), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))'.dependencies]
linux-raw-sys = { version = "0.4.14", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"] }
libc_errno = { package = "errno", version = "0.3.8", default-features = false, optional = true }
libc = { version = "0.2.156", default-features = false, optional = true }
libc = { version = "0.2.161", default-features = false, optional = true }

# Dependencies for platforms where only libc is supported:
#
# On all other Unix-family platforms, and under Miri, we always use the libc
# backend, so enable its dependencies unconditionally.
[target.'cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_endian = "little", target_arch = "s390x"), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))))))'.dependencies]
libc_errno = { package = "errno", version = "0.3.8", default-features = false }
libc = { version = "0.2.156", default-features = false }
libc = { version = "0.2.161", default-features = false }

# Additional dependencies for Linux with the libc backend:
#
Expand Down Expand Up @@ -74,7 +74,7 @@ default-features = false

[dev-dependencies]
tempfile = "3.5.0"
libc = "0.2.156"
libc = "0.2.161"
libc_errno = { package = "errno", version = "0.3.8", default-features = false }
serial_test = "2.0.0"
memoffset = "0.9.0"
Expand Down
6 changes: 2 additions & 4 deletions src/backend/libc/fs/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::fs::Access;
#[cfg(not(any(
apple,
netbsdlike,
solarish,
target_os = "solaris",
target_os = "dragonfly",
target_os = "espidf",
target_os = "haiku",
Expand All @@ -29,7 +29,6 @@ use crate::fs::Advice;
use crate::fs::AtFlags;
#[cfg(not(any(
netbsdlike,
solarish,
target_os = "dragonfly",
target_os = "espidf",
target_os = "nto",
Expand Down Expand Up @@ -1196,7 +1195,7 @@ pub(crate) fn copy_file_range(
#[cfg(not(any(
apple,
netbsdlike,
solarish,
target_os = "solaris",
target_os = "dragonfly",
target_os = "espidf",
target_os = "haiku",
Expand Down Expand Up @@ -1614,7 +1613,6 @@ fn futimens_old(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> {
#[cfg(not(any(
apple,
netbsdlike,
solarish,
target_os = "dragonfly",
target_os = "espidf",
target_os = "nto",
Expand Down
11 changes: 9 additions & 2 deletions src/backend/libc/fs/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ bitflags! {
#[cfg(any(
linux_kernel,
netbsdlike,
solarish,
target_os = "emscripten",
target_os = "wasi",
))]
Expand Down Expand Up @@ -562,7 +563,7 @@ impl FileType {
#[cfg(not(any(
apple,
netbsdlike,
solarish,
target_os = "solaris",
target_os = "dragonfly",
target_os = "espidf",
target_os = "haiku",
Expand Down Expand Up @@ -796,7 +797,6 @@ bitflags! {

#[cfg(not(any(
netbsdlike,
solarish,
target_os = "espidf",
target_os = "nto",
target_os = "redox",
Expand All @@ -812,6 +812,7 @@ bitflags! {
/// `FALLOC_FL_KEEP_SIZE`
#[cfg(not(any(
bsd,
solarish,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
Expand All @@ -821,6 +822,7 @@ bitflags! {
/// `FALLOC_FL_PUNCH_HOLE`
#[cfg(not(any(
bsd,
solarish,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
Expand All @@ -830,6 +832,7 @@ bitflags! {
/// `FALLOC_FL_NO_HIDE_STALE`
#[cfg(not(any(
bsd,
solarish,
target_os = "aix",
target_os = "emscripten",
target_os = "fuchsia",
Expand All @@ -843,6 +846,7 @@ bitflags! {
/// `FALLOC_FL_COLLAPSE_RANGE`
#[cfg(not(any(
bsd,
solarish,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
Expand All @@ -853,6 +857,7 @@ bitflags! {
/// `FALLOC_FL_ZERO_RANGE`
#[cfg(not(any(
bsd,
solarish,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
Expand All @@ -863,6 +868,7 @@ bitflags! {
/// `FALLOC_FL_INSERT_RANGE`
#[cfg(not(any(
bsd,
solarish,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
Expand All @@ -873,6 +879,7 @@ bitflags! {
/// `FALLOC_FL_UNSHARE_RANGE`
#[cfg(not(any(
bsd,
solarish,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
Expand Down
2 changes: 0 additions & 2 deletions src/fs/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::{backend, io};
use backend::fd::{AsFd, BorrowedFd};
#[cfg(not(any(
netbsdlike,
solarish,
target_os = "dragonfly",
target_os = "espidf",
target_os = "nto",
Expand Down Expand Up @@ -241,7 +240,6 @@ pub fn futimens<Fd: AsFd>(fd: Fd, times: &Timestamps) -> io::Result<()> {
/// [Linux `posix_fallocate`]: https://man7.org/linux/man-pages/man3/posix_fallocate.3.html
#[cfg(not(any(
netbsdlike,
solarish,
target_os = "dragonfly",
target_os = "espidf",
target_os = "nto",
Expand Down
4 changes: 2 additions & 2 deletions src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod dir;
#[cfg(not(any(
apple,
netbsdlike,
solarish,
target_os = "solaris",
target_os = "dragonfly",
target_os = "espidf",
target_os = "haiku",
Expand Down Expand Up @@ -84,7 +84,7 @@ pub use dir::{Dir, DirEntry};
#[cfg(not(any(
apple,
netbsdlike,
solarish,
target_os = "solaris",
target_os = "dragonfly",
target_os = "espidf",
target_os = "haiku",
Expand Down
2 changes: 1 addition & 1 deletion tests/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn test_file() {
#[cfg(not(any(
apple,
netbsdlike,
solarish,
target_os = "solaris",
target_os = "dragonfly",
target_os = "espidf",
target_os = "haiku",
Expand Down
3 changes: 1 addition & 2 deletions tests/fs/invalid_offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ fn invalid_offset_seek() {

#[cfg(not(any(
netbsdlike,
solarish,
target_os = "dragonfly",
target_os = "nto",
target_os = "redox"
Expand All @@ -61,7 +60,7 @@ fn invalid_offset_fallocate() {
#[cfg(not(any(
apple,
netbsdlike,
solarish,
target_os = "solaris",
target_os = "dragonfly",
target_os = "haiku",
target_os = "redox",
Expand Down

0 comments on commit 1bc2840

Please sign in to comment.