Skip to content

glibc: Add f_type to statvfs and statvfs64 - #5434

Draft
valentynkit wants to merge 3 commits into
rust-lang:mainfrom
valentynkit:statvfs-f-type
Draft

glibc: Add f_type to statvfs and statvfs64#5434
valentynkit wants to merge 3 commits into
rust-lang:mainfrom
valentynkit:statvfs-f-type

Conversation

@valentynkit

@valentynkit valentynkit commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

glibc 2.39 allocated one of the six reserved __f_spare ints to f_type for statvfs and statvfs64, which mirrors statfs.
sailfishos-mirror/glibc@92861d9

Adding f_type to statvfs and statvfs64 for linux/gnu, using c_uint.
Also deduplicated statvfs64 for 32-bit arch, it was declared byte-for-byte identical on six of the eight platforms, so it was moved to the shared b32/mod.rs (m68k and riscv32 differ, so they are excluded by cfg, and keep their own declaration). And deduplicated statvfs and statvfs64 for 64-bit arch, keeping only riscv64 excluded by cfg, and keeping its own declaration.

There is also musl that is missing f_type. It wasn't addressed in this PR, should I address musl also, or any other not just glibc?

Also riscv32 and riscv64 declare their __f_spare field as pub, it feels inconsistent with the other declarations, and for riscv64 it is the reason it keeps its own declaration (riscv32 differs in also lacking __f_unused). Is there a specific reason to have it pub __f_spare, or should this be addressed and fixed?

Closes #4121

Checklist

  • Relevant tests in libc-test/semver have been updated, no change needed.
  • Commit messages permalink to headers for added or changed API
  • No placeholder or unstable values like *LAST or *MAX.
  • Tested locally (cargo test -p libc-test --target mytarget); especially relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

Almost every glibc 32-bit arch declared an identical `statvfs64`. Six of
the eight were fully the same, so they move to the shared `b32/mod.rs`.

`m68k` and `riscv32` differ, so they are excluded by cfg, and keep their own declarations.

No functional change: shared declaration is byte-for-byte identical to
the six it replaces.
No functional changes: shared declaration is byte for byte identical to
architecture specifics it replaces, only `riscv64` differs, and guarded
by cfg, to use it own declaration.
@valentynkit

Copy link
Copy Markdown
Contributor Author

Is it okay to have it as one PR, or should dedup in gnu/b32 and gnu/b64 be separate PR?
When I started adding f_type noticed that there were a lot of duplication of identical statvfs and statvfs64, so addressed it in separate commits before adding f_type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

statvfs and statvfs64 got a new field f_type

2 participants