rustix icon indicating copy to clipboard operation
rustix copied to clipboard

`libc::sysctl` is missing

Open al8n opened this issue 1 year ago • 3 comments

Hi, sysctl is missing. I am using this function to get the MTU of the interface. May I ask to add this function?

al8n avatar Jan 01 '25 03:01 al8n

Are you using Linux? If so, the sysctl function is deprecated, and the Linux maintainers suggest you use the /proc/sys interface instead.

sunfishcode avatar Jan 02 '25 16:01 sunfishcode

Are you using Linux? If so, the sysctl function is deprecated, and the Linux maintainers suggest you use the /proc/sys interface instead.

I am using MacOS, and I need something like

    let mut mib = [CTL_NET, AF_ROUTE, 0, AF_UNSPEC, NET_RT_IFLIST, idx as i32];

    let mut len: size_t = 0;
    if rustix::sysctl(mib.as_mut_ptr(), 6, null_mut(), &mut len, null_mut(), 0) < 0 {
      return Err(io::Error::last_os_error());
    }

al8n avatar Jan 02 '25 17:01 al8n

Now, I am not quite sure whether the sysctl is necessary for rustix or not, currently, the BSD-like platform uses libc as the backend. The crates depend on rustix can use the feature gate to use libc on the BDS-like platform.

al8n avatar Jan 30 '25 17:01 al8n