Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions src/freebsd.rs → src/bsd_arandom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Implementation for FreeBSD
//! Implementation for FreeBSD and NetBSD
use crate::util_libc::{sys_fill_exact, Weak};
use crate::Error;
use core::{mem, ptr};
Expand All @@ -27,7 +27,7 @@ fn kern_arnd(buf: &mut [u8]) -> libc::ssize_t {
)
};
if ret == -1 {
error!("freebsd: kern.arandom syscall failed");
error!("sysctl kern.arandom: syscall failed");
-1
} else {
len as libc::ssize_t
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! | iOS | [`SecRandomCopyBytes`][4]
//! | FreeBSD | [`getrandom()`][21] if available, otherwise [`kern.arandom`][5]
//! | OpenBSD | [`getentropy`][6]
//! | NetBSD | [`/dev/urandom`][7] after successfully polling `/dev/random`
//! | NetBSD | [`kern.arandom`][5]
//! | Dragonfly BSD | [`/dev/random`][8]
//! | Solaris, illumos | [`getrandom`][9] system call if available, otherwise [`/dev/random`][10]
//! | Fuchsia OS | [`cprng_draw`][11]
Expand Down Expand Up @@ -198,7 +198,7 @@ cfg_if! {
} else if #[cfg(target_os = "emscripten")] {
#[path = "use_file.rs"] mod imp;
} else if #[cfg(target_os = "freebsd")] {
#[path = "freebsd.rs"] mod imp;
#[path = "bsd_arandom.rs"] mod imp;
} else if #[cfg(target_os = "fuchsia")] {
#[path = "fuchsia.rs"] mod imp;
} else if #[cfg(target_os = "haiku")] {
Expand All @@ -212,7 +212,7 @@ cfg_if! {
} else if #[cfg(target_os = "macos")] {
#[path = "macos.rs"] mod imp;
} else if #[cfg(target_os = "netbsd")] {
#[path = "use_file.rs"] mod imp;
#[path = "bsd_arandom.rs"] mod imp;
} else if #[cfg(target_os = "openbsd")] {
#[path = "openbsd.rs"] mod imp;
} else if #[cfg(target_os = "redox")] {
Expand Down
2 changes: 1 addition & 1 deletion src/use_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
}

cfg_if! {
if #[cfg(any(target_os = "android", target_os = "linux", target_os = "netbsd"))] {
if #[cfg(any(target_os = "android", target_os = "linux"))] {
fn init_file() -> Option<libc::c_int> {
// Poll /dev/random to make sure it is ok to read from /dev/urandom.
let mut pfd = libc::pollfd {
Expand Down