Skip to content

Commit 25fa7db

Browse files
committed
Change some OpebBSD cfg attributes to whitelists.
As discussed in #1000 .
1 parent 6bdd9f2 commit 25fa7db

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

src/sys/stat.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,12 @@ pub fn utimes<P: ?Sized + NixPath>(path: &P, atime: &TimeVal, mtime: &TimeVal) -
209209
/// # References
210210
///
211211
/// [lutimes(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/lutimes.html).
212-
#[cfg(not(any(target_os = "android",
213-
target_os = "openbsd")))]
212+
#[cfg(any(target_os = "linux",
213+
target_os = "haiku",
214+
target_os = "ios",
215+
target_os = "macos",
216+
target_os = "freebsd",
217+
target_os = "netbsd"))]
214218
pub fn lutimes<P: ?Sized + NixPath>(path: &P, atime: &TimeVal, mtime: &TimeVal) -> Result<()> {
215219
let times: [libc::timeval; 2] = [*atime.as_ref(), *mtime.as_ref()];
216220
let res = path.with_nix_path(|cstr| unsafe {

src/unistd.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,13 @@ pub fn execvpe(filename: &CString, args: &[CString], env: &[CString]) -> Result<
760760
///
761761
/// This function is similar to `execve`, except that the program to be executed
762762
/// is referenced as a file descriptor instead of a path.
763+
///
764+
/// Note for NetBSD and OpenBSD: although rust-lang/libc includes it (under
765+
/// unix/bsd/netbsdlike/) fexecve is not currently implemented on NetBSD nor on
766+
/// OpenBSD.
763767
#[cfg(any(target_os = "android",
764-
target_os = "freebsd",
765768
target_os = "linux",
766-
target_os = "netbsd"))]
769+
target_os = "freebsd"))]
767770
#[inline]
768771
pub fn fexecve(fd: RawFd, args: &[CString], env: &[CString]) -> Result<Void> {
769772
let args_p = to_exec_array(args);

test/test_stat.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ use std::time::{Duration, UNIX_EPOCH};
77
use libc::{S_IFMT, S_IFLNK};
88

99
use nix::fcntl;
10-
#[cfg(not(any(target_os = "openbsd")))]
11-
use nix::sys::stat::{self, fchmod, fchmodat, futimens, lutimes, stat, utimes, utimensat};
12-
#[cfg(any(target_os = "openbsd"))]
1310
use nix::sys::stat::{self, fchmod, fchmodat, futimens, stat, utimes, utimensat};
11+
#[cfg(any(target_os = "linux",
12+
target_os = "haiku",
13+
target_os = "ios",
14+
target_os = "macos",
15+
target_os = "freebsd",
16+
target_os = "netbsd"))]
17+
use nix::sys::stat::{lutimes};
1418
use nix::sys::stat::{Mode, FchmodatFlags, UtimensatFlags};
1519

1620
#[cfg(not(any(target_os = "netbsd")))]
@@ -199,7 +203,12 @@ fn test_utimes() {
199203
}
200204

201205
#[test]
202-
#[cfg(not(any(target_os = "openbsd")))]
206+
#[cfg(any(target_os = "linux",
207+
target_os = "haiku",
208+
target_os = "ios",
209+
target_os = "macos",
210+
target_os = "freebsd",
211+
target_os = "netbsd"))]
203212
fn test_lutimes() {
204213
let tempdir = tempfile::tempdir().unwrap();
205214
let target = tempdir.path().join("target");

test/test_unistd.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ cfg_if!{
240240
target_os = "openbsd"))] {
241241
execve_test_factory!(test_execve, execve, &CString::new("/bin/sh").unwrap());
242242
// No fexecve() on DragonFly, ios, macos, NetBSD, OpenBSD.
243+
//
244+
// Note for NetBSD and OpenBSD: although rust-lang/libc includes it
245+
// (under unix/bsd/netbsdlike/) fexecve is not currently implemented on
246+
// NetBSD nor on OpenBSD.
243247
}
244248
}
245249

0 commit comments

Comments
 (0)