Repository: wcampbell0x2a/backhand (language: rust)

Issue:
OSX Cargo Output.
Cargo output below. I believe this is due to various types on BSD derivatives such as MacOS/OSX being different sizes to those on Linux.

Not a huge issue for me personally (prefer to use Linux, just had a Mac on hand). 

```
   Compiling backhand v0.12.0
error[E0308]: mismatched types
   --> /Users/lol/.cargo/registry/src/github.com-1ecc6299db9ec823/backhand-0.12.0/src/bin/unsquashfs.rs:324:41
    |
324 |                         Mode::from_bits(u32::from(node.header.permissions)).unwrap(),
    |                         --------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`
    |                         |
    |                         arguments to this function are incorrect
    |
note: associated function defined here
   --> /Users/lol/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.26.2/src/sys/stat.rs:33:1
    |
33  | / libc_bitflags! {
34  | |     /// "File mode / permissions" flags.
35  | |     pub struct Mode: mode_t {
36  | |         /// Read, write and execute for owner.
...   |
65  | |     }
66  | | }
    | |_^
    = note: this error originates in the macro `__impl_bitflags` which comes from the expansion of the macro `libc_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> /Users/lol/.cargo/registry/src/github.com-1ecc6299db9ec823/backhand-0.12.0/src/bin/unsquashfs.rs:325:25
    |
321 |                     match mknod(
    |                           ----- arguments to this function are incorrect
...
325 |                         u64::from(*device_number),
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
    |
note: function defined here
   --> /Users/rlol/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.26.2/src/sys/stat.rs:173:8
    |
173 | pub fn mknod<P: ?Sized + NixPath>(
    |        ^^^^^

error[E0308]: mismatched types
   --> /Users/lol/.cargo/registry/src/github.com-1ecc6299db9ec823/backhand-0.12.0/src/bin/unsquashfs.rs:355:37
    |
355 |                     Mode::from_bits(u32::from(node.header.permissions)).unwrap(),
    |                     --------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`
    |                     |
    |                     arguments to this function are incorrect
    |
note: associated function defined here
   --> /Users/lol/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.26.2/src/sys/stat.rs:33:1
    |
33  | / libc_bitflags! {
34  | |     /// "File mode / permissions" flags.
35  | |     pub struct Mode: mode_t {
36  | |         /// Read, write and execute for owner.
...   |
65  | |     }
66  | | }
    | |_^
    = note: this error originates in the macro `__impl_bitflags` which comes from the expansion of the macro `libc_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> /Users/lol/.cargo/registry/src/github.com-1ecc6299db9ec823/backhand-0.12.0/src/bin/unsquashfs.rs:356:21
    |
352 |                 match mknod(
    |                       ----- arguments to this function are incorrect
...
356 |                     u64::from(*device_number),
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
    |
note: function defined here
   --> /Users/lol/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.26.2/src/sys/stat.rs:173:8
    |
173 | pub fn mknod<P: ?Sized + NixPath>(
    |        ^^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `backhand` due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `backhand v0.12.0`, intermediate artifacts can be found at `/var/folders/f6/gkxjd1g111x5b13kvfzm2db40000gn/T/cargo-installepyyvn`

$ cargo version
cargo 1.69.0 (6e9a83356 2023-04-12)
```

This comment was enlightening about how some types are different: https://github.com/tikv/tikv/issues/4130#issuecomment-457918524




Discussion / hints:

Fix patch:
diff --git a/src/bin/unsquashfs.rs b/src/bin/unsquashfs.rs
index e401fbb0..7f7939e4 100644
--- a/src/bin/unsquashfs.rs
+++ b/src/bin/unsquashfs.rs
@@ -409,7 +409,7 @@ fn extract_all<'a>(
                         &path,
                         SFlag::S_IFCHR,
                         Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(),
-                        dev_t::from(*device_number),
+                        dev_t::try_from(*device_number).unwrap(),
                     ) {
                         Ok(_) => {
                             if args.info {
@@ -440,7 +440,7 @@ fn extract_all<'a>(
                     &path,
                     SFlag::S_IFBLK,
                     Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(),
-                    dev_t::from(*device_number),
+                    dev_t::try_from(*device_number).unwrap(),
                 ) {
                     Ok(_) => {
                         if args.info {


Test patch: