Skip to content

musl: Move statfs.h and statvfs.h definitions to src/new - #5529

Open
valentynkit wants to merge 2 commits into
rust-lang:mainfrom
valentynkit:musl/statfs-migration
Open

valentynkit wants to merge 2 commits into
rust-lang:mainfrom
valentynkit:musl/statfs-migration

Conversation

@valentynkit

Copy link
Copy Markdown
Contributor

This follows the ongoing migration into src/new, which reduces
duplication and models musl's source tree.

Arch specific definitions are kept for mips, mips64 and s390x,
mirroring musl's arch/*/bits/statfs.h.

statfs64 is now a type alias for statfs, as it already was on
s390x. musl has no second struct: sys/statfs.h #defines
statfs64 to statfs, and the lfs types fsblkcnt64_t and
fsfilcnt64_t to fsblkcnt_t and fsfilcnt_t. This crate declares
both spellings as c_ulonglong on every musl target, so the duplicated
structs had identical layout.

statvfs64 is now also a type alias for statvfs following the same reasons as before.

Let me know if I should revert the changes for using type alias, and just do the migration without it, but from my findings it looks safe to do.
https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/include/sys/statfs.h#L21-L26

pub type fsblkcnt_t = c_ulonglong;
pub type fsfilcnt_t = c_ulonglong;
pub type rlim_t = c_ulonglong;
// FIXME(1.0,deprecate): lfs binding to be removed
pub type fsblkcnt64_t = c_ulonglong;
// FIXME(1.0,deprecate): lfs binding to be removed
pub type fsfilcnt64_t = c_ulonglong;

Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/include/sys/statfs.h
Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/include/sys/statvfs.h
Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/arch/s390x/bits/statfs.h
Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/arch/mips/bits/statfs.h
Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/arch/mips64/bits/statfs.h

This follows the ongoing migration into `src/new`, which reduces
duplication and models musl's source tree.

Arch specific definitions are kept for `mips`, `mips64` and `s390x`,
mirroring musl's `arch/*/bits/statfs.h`.

`statfs64` is now a type alias for `statfs`, as it already was on
`s390x`. musl has no second struct: `sys/statfs.h` `#define`s
`statfs64` to `statfs`, and the lfs types `fsblkcnt64_t` and
`fsfilcnt64_t` to `fsblkcnt_t` and `fsfilcnt_t`. This crate declares
both spellings as `c_ulonglong` on every musl target, so the duplicated
structs had identical layout.

Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/include/sys/statfs.h
Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/arch/s390x/bits/statfs.h
Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/arch/mips/bits/statfs.h
Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/arch/mips64/bits/statfs.h
This follows the ongoing migration into `src/new`, which reduces
duplication and models musl's source tree.

`statvfs64` is now a type alias for `statvfs`. As with `statfs`, musl
has no second struct: `sys/statvfs.h` `#define`s `statvfs64` to
`statvfs`, and the lfs types `fsblkcnt64_t` and `fsfilcnt64_t` to
`fsblkcnt_t` and `fsfilcnt_t`. This crate declares both spellings as
`c_ulonglong` on every musl target, so the duplicated structs had
identical layout.

Link: https://github.com/kraj/musl/blob/1c82569f4cc53f5bb25c820051c2a02463f46cab/include/sys/statvfs.h
@valentynkit

Copy link
Copy Markdown
Contributor Author

These changes follow from previous work in this repo, the ongoing migration to src/new suggests contributions like this are useful, but let me know if this isn't wanted

Two things worth attention:

  • making statfs64/ statvfs64 type aliases instead of duplicate structs (but some fields use lfs bindings like fsblkcnt64_t)
  • musl statvfs has f_type, so it was not added in this PR (glibc side glibc: Add f_type to statvfs and statvfs64 #5434), to keep the move PR separate as it already contains the move of 2 definitions.

@valentynkit
valentynkit marked this pull request as ready for review September 15, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants