meh / rust-tun

TUN device creation and handling.
340 stars 133 forks source link

ioctl is marked as "deprecated", should be replaced with nix #86

Open zonyitoo opened 5 months ago

zonyitoo commented 5 months ago

https://crates.io/crates/ioctl

https://github.com/meh/rust-tun/blob/e762c419d71438e67379f9b2fed89b5cb835cc6a/Cargo.toml#L23-L24

The ioctl-sys package also seems to be abandoned.

zonyitoo commented 5 months ago

The reason I want to replace this deprecate crate is that my Project build was failed on snapcraft with architecture ppc64el,

   Compiling ioctl-sys v0.8.0
:: error[E0432]: unresolved import `self::consts`
::   --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ioctl-sys-0.8.0/src/platform/linux.rs:61:15
::    |
:: 61 | pub use self::consts::*;
::    |               ^^^^^^ could not find `consts` in `self`
::
:: error[E0432]: unresolved import `this_arch_not_supported`
::   --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ioctl-sys-0.8.0/src/platform/linux.rs:37:5
::    |
:: 37 | use this_arch_not_supported;
::    |     ^^^^^^^^^^^^^^^^^^^^^^^ no `this_arch_not_supported` in the root
::
:: error[E0425]: cannot find value `SIZEBITS` in this scope
::   --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ioctl-sys-0.8.0/src/platform/mod.rs:28:39
::    |
:: 28 | pub const DIRSHIFT: u32 = SIZESHIFT + SIZEBITS as u32;
::    |                                       ^^^^^^^^ not found in this scope
::
:: error[E0425]: cannot find value `SIZEBITS` in this scope
::   --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ioctl-sys-0.8.0/src/platform/mod.rs:35:33
::    |
:: 35 | pub const SIZEMASK: u32 = (1 << SIZEBITS) - 1;
::    |                                 ^^^^^^^^ not found in this scope
::
:: error[E0425]: cannot find value `DIRBITS` in this scope
::   --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ioctl-sys-0.8.0/src/platform/mod.rs:37:32
::    |
:: 2  | pub const NRBITS: u32 = 8;
::    | -------------------------- similarly named constant `NRBITS` defined here
:: ...
:: 37 | pub const DIRMASK: u32 = (1 << DIRBITS) - 1;
::    |                                ^^^^^^^ help: a constant with a similar name exists: `NRBITS`
::
:: error[E0425]: cannot find value `WRITE` in this scope
::    --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ioctl-sys-0.8.0/src/platform/mod.rs:261:22
::     |
:: 261 | pub const IN: u32 = (WRITE as u32) << DIRSHIFT;
::     |                      ^^^^^ not found in this scope
::
:: error[E0425]: cannot find value `READ` in this scope
::    --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ioctl-sys-0.8.0/src/platform/mod.rs:263:23
::     |
:: 263 | pub const OUT: u32 = (READ as u32) << DIRSHIFT;
::     |                       ^^^^ not found in this scope
::
:: error[E0425]: cannot find value `READ` in this scope
::    --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ioctl-sys-0.8.0/src/platform/mod.rs:265:26
::     |
:: 265 | pub const INOUT: u32 = ((READ | WRITE) as u32) << DIRSHIFT;
::     |                          ^^^^ not found in this scope
::
:: error[E0425]: cannot find value `WRITE` in this scope
::    --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ioctl-sys-0.8.0/src/platform/mod.rs:265:33
::     |
:: 265 | pub const INOUT: u32 = ((READ | WRITE) as u32) << DIRSHIFT;
::     |                                 ^^^^^ not found in this scope
::

This is because ioctl-sys doesn't support ppc64el-* targets.