nix icon indicating copy to clipboard operation
nix copied to clipboard

Support for 64-bit S_IFBLK, and S_IFCHR, on Haiku?

Open vmlemon opened this issue 10 months ago • 0 comments
trafficstars

Whilst trying to build https://github.com/rustic-rs/rustic, under Haiku (as part of https://github.com/rustic-rs/rustic/issues/1390), I encountered an issue related to nix's wrapper, for mknod(), where definitions for S_IFBLK, and S_IFCHR seem to be oversized, or missing:

error[E0308]: mismatched types
   --> /boot/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustic_core-0.7.3/src/backend/local_destination.rs:663:65
    |
663 |                 mknod(&filename, SFlag::S_IFBLK, Mode::empty(), device)
    |                 ----- arguments to this function are incorrect  ^^^^^^ expected `i32`, found `u64`
    |
note: function defined here
   --> /boot/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.29.0/src/sys/stat.rs:156:8
    |
156 | pub fn mknod<P: ?Sized + NixPath>(
    |        ^^^^^
help: you can convert a `u64` to an `i32` and panic if the converted value doesn't fit
    |
663 |                 mknod(&filename, SFlag::S_IFBLK, Mode::empty(), device.try_into().unwrap())
    |                                                                       ++++++++++++++++++++
 
error[E0308]: mismatched types
   --> /boot/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustic_core-0.7.3/src/backend/local_destination.rs:689:65
    |
689 |                 mknod(&filename, SFlag::S_IFCHR, Mode::empty(), device)
    |                 ----- arguments to this function are incorrect  ^^^^^^ expected `i32`, found `u64`
    |
note: function defined here
   --> /boot/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.29.0/src/sys/stat.rs:156:8
    |
156 | pub fn mknod<P: ?Sized + NixPath>(
    |        ^^^^^
help: you can convert a `u64` to an `i32` and panic if the converted value doesn't fit
    |
689 |                 mknod(&filename, SFlag::S_IFCHR, Mode::empty(), device.try_into().unwrap())
    |                                                                       ++++++++++++++++++++
 

Haiku's system headers seem to define the values to be:

~/rustic> grep -R S_IFBLK /system/develop/headers/
/system/develop/headers/private/fs_shell/fssh_stat.h:#define FSSH_S_IFBLK                       00000060000 /* block special */
/system/develop/headers/private/fs_shell/fssh_stat.h:#define FSSH_S_ISBLK(mode)         (((mode) & FSSH_S_IFMT) == FSSH_S_IFBLK)
/system/develop/headers/private/fs_shell/fssh_api_wrapper.h:#define S_IFBLK             FSSH_S_IFBLK
/system/develop/headers/posix/sys/stat.h:#define S_IFBLK                        00000060000 /* block special */
/system/develop/headers/posix/sys/stat.h:#define S_ISBLK(mode)          (((mode) & S_IFMT) == S_IFBLK)
~/rustic> grep -R S_IFCHR /system/develop/headers/
/system/develop/headers/private/fs_shell/fssh_stat.h:#define FSSH_S_IFCHR                       00000020000 /* character special */
/system/develop/headers/private/fs_shell/fssh_stat.h:#define FSSH_S_ISCHR(mode)         (((mode) & FSSH_S_IFMT) == FSSH_S_IFCHR)
/system/develop/headers/private/fs_shell/fssh_api_wrapper.h:#define S_IFCHR             FSSH_S_IFCHR
/system/develop/headers/posix/sys/stat.h:#define S_IFCHR                        00000020000 /* character special */
/system/develop/headers/posix/sys/stat.h:#define S_ISCHR(mode)          (((mode) & S_IFMT) == S_IFCHR)
/system/develop/headers/python3.10/pyport.h:#define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)

However, I'm unsure of how the modes stuff work, since I'm unfamiliar with the "nix" Crate codebase, so other than probing at a Haiku system, and testing things, I'm short of ideas, for actually fixing this. (I'm also unsure, of if they're always 64-bit wide, on 32-bit Haiku systems).

vmlemon avatar Jan 18 '25 18:01 vmlemon