Haiku, incorrect pointer type on statvfs
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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