From 5600cc40d5e558a6cd722b43fb708d9bd36e29a9 Mon Sep 17 00:00:00 2001 From: Greg V Date: Thu, 4 Jan 2018 02:48:39 +0300 Subject: [PATCH 1/3] Add missing kqueue event filters on FreeBSD --- CHANGELOG.md | 2 ++ src/sys/event.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11d7774b17..f3b03799dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ([#853](https://github.com/nix-rust/nix/pull/853)) - Added `statvfs` module to all MacOS and Linux architectures. ([#832](https://github.com/nix-rust/nix/pull/832)) +- Added `EVFILT_EMPTY`, `EVFILT_PROCDESC` and `EVFILT_SENDFILE` on FreeBSD. + ([#825](https://github.com/nix-rust/nix/pull/825)) ### Changed - Display and Debug for SysControlAddr now includes all fields. diff --git a/src/sys/event.rs b/src/sys/event.rs index 3a6c528d85..e2a4eaa16e 100644 --- a/src/sys/event.rs +++ b/src/sys/event.rs @@ -40,6 +40,9 @@ libc_enum! { #[cfg_attr(not(target_os = "netbsd"), repr(i16))] pub enum EventFilter { EVFILT_AIO, + /// Returns whenever there is no remaining data in the write buffer + #[cfg(target_os = "freebsd")] + EVFILT_EMPTY, #[cfg(target_os = "dragonfly")] EVFILT_EXCEPT, #[cfg(any(target_os = "dragonfly", @@ -52,7 +55,16 @@ libc_enum! { #[cfg(any(target_os = "ios", target_os = "macos"))] EVFILT_MACHPORT, EVFILT_PROC, + /// Returns events associated with the process referenced by a given + /// process descriptor, created by `pdfork()`. The events to monitor are: + /// + /// - NOTE_EXIT: the process has exited. The exit status will be stored in data. + #[cfg(target_os = "freebsd")] + EVFILT_PROCDESC, EVFILT_READ, + /// Returns whenever an asynchronous `sendfile()` call completes. + #[cfg(target_os = "freebsd")] + EVFILT_SENDFILE, EVFILT_SIGNAL, EVFILT_TIMER, #[cfg(any(target_os = "dragonfly", From d1f49bf38f3aad0171db306a1e23884b3102a539 Mon Sep 17 00:00:00 2001 From: Greg V Date: Thu, 4 Jan 2018 02:54:31 +0300 Subject: [PATCH 2/3] Add cfmakesane() on FreeBSD --- CHANGELOG.md | 2 ++ src/sys/termios.rs | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3b03799dd..b819b9fb2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ([#832](https://github.com/nix-rust/nix/pull/832)) - Added `EVFILT_EMPTY`, `EVFILT_PROCDESC` and `EVFILT_SENDFILE` on FreeBSD. ([#825](https://github.com/nix-rust/nix/pull/825)) +- Exposed `termios::cfmakesane` on FreeBSD. + ([#825](https://github.com/nix-rust/nix/pull/825)) ### Changed - Display and Debug for SysControlAddr now includes all fields. diff --git a/src/sys/termios.rs b/src/sys/termios.rs index 356c7769bb..11cacd7c57 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -1023,6 +1023,19 @@ pub fn cfmakeraw(termios: &mut Termios) { termios.update_wrapper(); } +/// Configures the port to "sane" mode (like the configuration of a newly created terminal) (see +/// [tcsetattr(3)](https://www.freebsd.org/cgi/man.cgi?query=tcsetattr)). +/// +/// Note that this is a non-standard function, available on FreeBSD. +#[cfg(target_os = "freebsd")] +pub fn cfmakesane(termios: &mut Termios) { + let inner_termios = unsafe { termios.get_libc_termios_mut() }; + unsafe { + libc::cfmakesane(inner_termios); + } + termios.update_wrapper(); +} + /// Return the configuration of a port /// [tcgetattr(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetattr.html)). /// From 647bac767036e68c8cc0a69a25547e6ee50994a0 Mon Sep 17 00:00:00 2001 From: Greg V Date: Fri, 5 Jan 2018 01:11:11 +0300 Subject: [PATCH 3/3] Expose MSG_CMSG_CLOEXEC on *BSD --- CHANGELOG.md | 2 ++ src/sys/socket/mod.rs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b819b9fb2a..058384f8c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ([#825](https://github.com/nix-rust/nix/pull/825)) - Exposed `termios::cfmakesane` on FreeBSD. ([#825](https://github.com/nix-rust/nix/pull/825)) +- Exposed `MSG_CMSG_CLOEXEC` on *BSD. + ([#825](https://github.com/nix-rust/nix/pull/825)) ### Changed - Display and Debug for SysControlAddr now includes all fields. diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index beef3db804..af66bc4715 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -163,7 +163,12 @@ libc_bitflags!{ /// [open(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html). /// /// Only used in [`recvmsg`](fn.recvmsg.html) function. - #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] MSG_CMSG_CLOEXEC; } }