uutils / uutils/coreutils

Haiku, incorrect pointer type on statvfs

Open
#14,607 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

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

    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:

    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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the statvfs implementation containing the free_blocks and total_blocks methods, then trace why the target_pointer_width branches exist. Verify the chosen conversion handles Haiku's i64 fields as well as the existing u64 and narrower-pointer cases, and confirm the project compiles for Haiku.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.