diff --git a/src/libstd/sys/unix/c.rs b/src/libstd/sys/unix/c.rs index 50a8e6b73e386..22194145252ee 100644 --- a/src/libstd/sys/unix/c.rs +++ b/src/libstd/sys/unix/c.rs @@ -74,6 +74,8 @@ pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 70; #[cfg(any(target_os = "macos", target_os = "freebsd"))] pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 71; +#[cfg(target_os = "openbsd")] +pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 101; #[cfg(target_os = "android")] pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 0x0048; @@ -91,7 +93,8 @@ pub struct passwd { #[repr(C)] #[cfg(any(target_os = "macos", - target_os = "freebsd"))] + target_os = "freebsd", + target_os = "openbsd"))] pub struct passwd { pub pw_name: *mut libc::c_char, pub pw_passwd: *mut libc::c_char, diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 5004ff713c45f..be52c7dc69290 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -197,23 +197,23 @@ pub fn current_exe() -> IoResult { } #[cfg(target_os = "openbsd")] -pub fn load_self() -> Option> { +pub fn current_exe() -> IoResult { use sync::{StaticMutex, MUTEX_INIT}; static LOCK: StaticMutex = MUTEX_INIT; extern { - fn rust_load_self() -> *const c_char; + fn rust_current_exe() -> *const c_char; } let _guard = LOCK.lock(); unsafe { - let v = rust_load_self(); + let v = rust_current_exe(); if v.is_null() { - None + Err(IoError::last_error()) } else { - Some(ffi::c_str_to_bytes(&v).to_vec()) + Ok(Path::new(ffi::c_str_to_bytes(&v).to_vec())) } } } @@ -333,7 +333,8 @@ pub fn args() -> Args { #[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "dragonfly"))] + target_os = "dragonfly", + target_os = "openbsd"))] pub fn args() -> Args { use rt; let bytes = rt::args::clone().unwrap_or(Vec::new()); diff --git a/src/rt/rust_builtin.c b/src/rt/rust_builtin.c index 382cbf0d5d129..255fbdcbfcf5e 100644 --- a/src/rt/rust_builtin.c +++ b/src/rt/rust_builtin.c @@ -204,7 +204,7 @@ int *__dfly_error(void) { return __error(); } #include #include -const char * rust_load_self() { +const char * rust_current_exe() { static char *self = NULL; if (self == NULL) {