Skip to content

Commit 85ae87c

Browse files
committed
Fix build on OpenBSD caused by missing lutimes
lutimes doesn't exist on OpenBSD so it needs to be under conditional compilation. The only "reference" that I could find related to this is the discussion here: rust-lang/libc#790
1 parent e1bb80e commit 85ae87c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/sys/stat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ 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(target_os = "android"))]
212+
#[cfg(not(any(target_os = "android",
213+
target_os = "openbsd")))]
213214
pub fn lutimes<P: ?Sized + NixPath>(path: &P, atime: &TimeVal, mtime: &TimeVal) -> Result<()> {
214215
let times: [libc::timeval; 2] = [*atime.as_ref(), *mtime.as_ref()];
215216
let res = path.with_nix_path(|cstr| unsafe {

test/test_stat.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ 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")))]
1011
use nix::sys::stat::{self, fchmod, fchmodat, futimens, lutimes, stat, utimes, utimensat};
12+
#[cfg(any(target_os = "openbsd"))]
13+
use nix::sys::stat::{self, fchmod, fchmodat, futimens, stat, utimes, utimensat};
1114
use nix::sys::stat::{Mode, FchmodatFlags, UtimensatFlags};
1215

1316
#[cfg(not(any(target_os = "netbsd")))]
@@ -196,6 +199,7 @@ fn test_utimes() {
196199
}
197200

198201
#[test]
202+
#[cfg(not(any(target_os = "openbsd")))]
199203
fn test_lutimes() {
200204
let tempdir = tempfile::tempdir().unwrap();
201205
let target = tempdir.path().join("target");

0 commit comments

Comments
 (0)