Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vmlemon opened this issue Jan 18, 2025 · 0 comments
Open

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

vmlemon opened this issue Jan 18, 2025 · 0 comments

Comments

@vmlemon
Copy link

vmlemon commented Jan 18, 2025

Whilst trying to build https://github.com/rustic-rs/rustic, under Haiku (as part of rustic-rs/rustic#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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant