Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make nix build again on OpenBSD 6.4-current #1000

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Changed
### Fixed
- `lutimes` never worked on OpenBSD as it is not implemented on OpenBSD. It has
been removed. ([#1000](https://github.com/nix-rust/nix/pull/1000))
- `fexecve` never worked on NetBSD or on OpenBSD as it is not implemented on
either OS. It has been removed. ([#1000](https://github.com/nix-rust/nix/pull/1000))

### Removed

## [0.12.0] 2018-11-28
Expand Down
7 changes: 6 additions & 1 deletion src/sys/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ pub fn utimes<P: ?Sized + NixPath>(path: &P, atime: &TimeVal, mtime: &TimeVal) -
/// # References
///
/// [lutimes(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/lutimes.html).
#[cfg(not(target_os = "android"))]
#[cfg(any(target_os = "linux",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd"))]
pub fn lutimes<P: ?Sized + NixPath>(path: &P, atime: &TimeVal, mtime: &TimeVal) -> Result<()> {
let times: [libc::timeval; 2] = [*atime.as_ref(), *mtime.as_ref()];
let res = path.with_nix_path(|cstr| unsafe {
Expand Down
7 changes: 4 additions & 3 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,12 @@ pub fn execvpe(filename: &CString, args: &[CString], env: &[CString]) -> Result<
///
/// This function is similar to `execve`, except that the program to be executed
/// is referenced as a file descriptor instead of a path.
// Note for NetBSD and OpenBSD: although rust-lang/libc includes it (under
thendiscard marked this conversation as resolved.
Show resolved Hide resolved
// unix/bsd/netbsdlike/) fexecve is not currently implemented on NetBSD nor on
// OpenBSD.
#[cfg(any(target_os = "android",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"))]
target_os = "freebsd"))]
#[inline]
pub fn fexecve(fd: RawFd, args: &[CString], env: &[CString]) -> Result<Void> {
let args_p = to_exec_array(args);
Expand Down
17 changes: 11 additions & 6 deletions test/sys/test_aio_drop.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
extern crate nix;
extern crate tempfile;

use nix::sys::aio::*;
use nix::sys::signal::*;
use std::os::unix::io::AsRawFd;
use tempfile::tempfile;

// Test dropping an AioCb that hasn't yet finished.
// This must happen in its own process, because on OSX this test seems to hose
// the AIO subsystem and causes subsequent tests to fail
#[test]
#[should_panic(expected = "Dropped an in-progress AioCb")]
#[cfg(not(target_env = "musl"))]
#[cfg(all(not(target_env = "musl"),
any(target_os = "linux",
target_os = "ios",
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd")))]
fn test_drop() {
use nix::sys::aio::*;
use nix::sys::signal::*;
use std::os::unix::io::AsRawFd;
use tempfile::tempfile;

const WBUF: &[u8] = b"CDEF";

let f = tempfile().unwrap();
Expand Down
15 changes: 14 additions & 1 deletion test/test_stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ use std::time::{Duration, UNIX_EPOCH};
use libc::{S_IFMT, S_IFLNK};

use nix::fcntl;
use nix::sys::stat::{self, fchmod, fchmodat, futimens, lutimes, stat, utimes, utimensat};
use nix::sys::stat::{self, fchmod, fchmodat, futimens, stat, utimes, utimensat};
#[cfg(any(target_os = "linux",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd"))]
use nix::sys::stat::lutimes;
use nix::sys::stat::{Mode, FchmodatFlags, UtimensatFlags};

#[cfg(not(any(target_os = "netbsd")))]
Expand Down Expand Up @@ -196,6 +203,12 @@ fn test_utimes() {
}

#[test]
#[cfg(any(target_os = "linux",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd"))]
fn test_lutimes() {
let tempdir = tempfile::tempdir().unwrap();
let target = tempdir.path().join("target");
Expand Down
12 changes: 8 additions & 4 deletions test/test_unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,20 @@ cfg_if!{
execve_test_factory!(test_execve, execve, &CString::new("/system/bin/sh").unwrap());
execve_test_factory!(test_fexecve, fexecve, File::open("/system/bin/sh").unwrap().into_raw_fd());
} else if #[cfg(any(target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"))] {
target_os = "linux"))] {
execve_test_factory!(test_execve, execve, &CString::new("/bin/sh").unwrap());
execve_test_factory!(test_fexecve, fexecve, File::open("/bin/sh").unwrap().into_raw_fd());
} else if #[cfg(any(target_os = "dragonfly",
target_os = "ios",
target_os = "macos",
target_os = "netbsd"))] {
target_os = "netbsd",
target_os = "openbsd"))] {
execve_test_factory!(test_execve, execve, &CString::new("/bin/sh").unwrap());
// No fexecve() on DragonFly, ios, macos, and NetBSD.
// No fexecve() on DragonFly, ios, macos, NetBSD, OpenBSD.
//
// Note for NetBSD and OpenBSD: although rust-lang/libc includes it
// (under unix/bsd/netbsdlike/) fexecve is not currently implemented on
// NetBSD nor on OpenBSD.
}
}

Expand Down