Skip to content

Commit

Permalink
Auto merge of #136213 - erickt:fs, r=<try>
Browse files Browse the repository at this point in the history
Allow Rust to use a number of libc filesystem calls

This allows Rust on Fuchsia to use a number of function calls from libc:

* dirfd
* fdatasync
* flock with LOCK_EX, LOCK_SH, LOCK_NB, LOCK_UN
* fstatat

cc #120426

try-job: dist-various-2
  • Loading branch information
bors committed Jan 28, 2025
2 parents fdd1a3b + c3647e6 commit 02d421b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion library/std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use libc::c_char;
#[cfg(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "fuchsia",
target_os = "hurd"
))]
use libc::dirfd;
Expand Down Expand Up @@ -50,6 +51,8 @@ use libc::{
dirent as dirent64, fstat as fstat64, fstatat as fstatat64, ftruncate64, lseek64,
lstat as lstat64, off64_t, open as open64, stat as stat64,
};
#[cfg(target_os = "fuchsia")]
use libc::fstatat as fstatat64;
#[cfg(not(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "l4re",
Expand Down Expand Up @@ -850,7 +853,6 @@ impl Drop for Dir {
target_os = "vita",
target_os = "hurd",
target_os = "espidf",
target_os = "fuchsia",
target_os = "horizon",
target_os = "vxworks",
target_os = "rtems",
Expand Down Expand Up @@ -882,6 +884,7 @@ impl DirEntry {
any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "fuchsia",
target_os = "hurd"
),
not(miri) // no dirfd on Miri
Expand Down Expand Up @@ -910,6 +913,7 @@ impl DirEntry {
not(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "fuchsia",
target_os = "hurd",
)),
miri
Expand Down Expand Up @@ -1213,6 +1217,7 @@ impl File {
}
#[cfg(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "android",
target_os = "netbsd",
Expand All @@ -1225,6 +1230,7 @@ impl File {
}
#[cfg(not(any(
target_os = "android",
target_os = "fuchsia",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
Expand All @@ -1240,6 +1246,7 @@ impl File {

#[cfg(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand All @@ -1251,6 +1258,7 @@ impl File {

#[cfg(not(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand All @@ -1261,6 +1269,7 @@ impl File {

#[cfg(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand All @@ -1272,6 +1281,7 @@ impl File {

#[cfg(not(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand All @@ -1282,6 +1292,7 @@ impl File {

#[cfg(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand All @@ -1299,6 +1310,7 @@ impl File {

#[cfg(not(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand All @@ -1309,6 +1321,7 @@ impl File {

#[cfg(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand All @@ -1326,6 +1339,7 @@ impl File {

#[cfg(not(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand All @@ -1336,6 +1350,7 @@ impl File {

#[cfg(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand All @@ -1347,6 +1362,7 @@ impl File {

#[cfg(not(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
Expand Down

0 comments on commit 02d421b

Please sign in to comment.