3

How can I the function "ioctl" in Rust? Should I find a wrapper for it somewhere? Is there a de-facto wrapper? Or maybe it's already included in the standard Rust library? I've not found it, though.

Or, more generally, I need an interface the Linux "tun" driver.

Diime
  • 33
  • 1
  • 5

1 Answers1

3

You can find ioctl in nix, which contains convenience wrapper of *nix functionalities.

WiSaGaN
  • 46,887
  • 10
  • 54
  • 88
  • yes, and there're iotcl packages out there as well. but popular is that one and how much is it close to de-facto? – Diime Jan 04 '17 at 05:57
  • 1
    @Diime , currently `nix` has 325,649 downloads. I would say it's close to de-factor standard Unix api package in Rust. – WiSaGaN Jan 04 '17 at 06:00
  • ok. but how about this https://github.com/rust-lang/rust/blob/5b3cd3900ceda838f5798c30ab96ceb41f962534/src/libstd/sys/unix/c.rs#L78 ? – Diime Jan 04 '17 at 08:27
  • 1
    @Diime , it is a `unsafe` C declaration internally used by the compiler. We have a `libc` version here: https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu/libc/fn.ioctl.html On the other hand, `ioctl` in `nix` is safe. – WiSaGaN Jan 04 '17 at 08:35