#14607·coreutils

Haiku, incorrect pointer type on statvfs

Author: kallisti5Created Sep 16, 2026Updated Sep 16, 2026

Haiku uses a i64 for pointers within statvfs. I was working on patches to support Haiku and ran across this:

rust
    fn free_blocks(&self) -> u64 {
        #[cfg(target_pointer_width = "64")]
        return self.f_bfree;
        #[cfg(not(target_pointer_width = "64"))]
        return self.f_bfree.into();
    }

This works for u64 vs not u64, however haiku uses i64 which means this code fails to compile.

I worked up a fix to address this... however it is pretty ugly:

rust
    fn total_blocks(&self) -> u64 {
        #[cfg(all(
            target_pointer_width = "64",
            not(target_os = "haiku")
        ))]
        return self.f_blocks;
        #[cfg(any(
            not(target_pointer_width = "64"),
            target_os = "haiku",
        ))]
        return self.f_blocks.into();
    }

I feel like these could all be condensed into just return self.f_blocks.into(); which would cover all cases, but i'm also assuming the width check is for a reason?