MCPcopy Index your code
hub / github.com/FrameworkComputer/framework-system / kenv_get

Function kenv_get

framework_lib/src/smbios.rs:318–342  ·  view source on GitHub ↗
(name: &str)

Source from the content-addressed store, hash-verified

316
317#[cfg(target_os = "freebsd")]
318fn kenv_get(name: &str) -> nix::Result<String> {
319 use libc::{c_int, KENV_GET, KENV_MVALLEN};
320 use nix::errno::Errno;
321 use std::ffi::{CStr, CString};
322
323 let cname = CString::new(name).unwrap();
324 let name_ptr = cname.as_ptr();
325
326 let mut value_buf = [0; 1 + KENV_MVALLEN as usize];
327
328 unsafe {
329 let res: c_int = libc::kenv(
330 KENV_GET,
331 name_ptr,
332 value_buf.as_mut_ptr(),
333 value_buf.len() as c_int,
334 );
335 Errno::result(res)?;
336
337 let cvalue = CStr::from_ptr(value_buf.as_ptr());
338 let value = cvalue.to_string_lossy().into_owned();
339
340 Ok(value)
341 }
342}

Callers 3

is_frameworkFunction · 0.85
get_product_nameFunction · 0.85
get_smbiosFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected