Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NetBSD: fix getmntinfo for NetBSD #4265

Merged
merged 1 commit into from
Feb 18, 2025
Merged

NetBSD: fix getmntinfo for NetBSD #4265

merged 1 commit into from
Feb 18, 2025

Conversation

0-wiz-0
Copy link
Contributor

@0-wiz-0 0-wiz-0 commented Feb 14, 2025

Description

This patch fixes libc::getmntinfo on NetBSD.

Sources

The problem is that NetBSD provides binary compatibility in a way that was not considered when initially providing the implementation.
Once a symbol name has been used, it stays the same, so the original getmntinfo() in NetBSD, using struct statfs, will always be available as getmntinfo. When getmntinfo was changed to provide struct statvfs (note the 'v') a long time ago, a new symbol was introduced, __getmntinfo13 and the system headers rename access to getmntinfo to call __getmntinfo13 instead.
The rust implementation called the old symbol (providing struct statfs) but parsed the returned information as struct statvfs, leading to wrong data and segfaults.

Checklist

The change has been tested on NetBSD 9, 10, and -current (all supported versions).
No compatibility for NetBSD 8 or older is required, since these versions are not supported any longer; the symbol rename happened before NetBSD 9.

@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2025

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented Feb 14, 2025

This should be pulled up, so
@rustbot label stable-nominated

@rustbot rustbot added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Feb 14, 2025
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented Feb 14, 2025

Exactly. We could switch to the new statvfs with the one additional field, but it's a bigger change and we'd need to differentiate between NetBSD 9 and 10+, so i'd leave that for another time.

@tgross35 tgross35 added this pull request to the merge queue Feb 18, 2025
@tgross35
Copy link
Contributor

tgross35 commented Feb 18, 2025

You should open an issue for changing the struct, that is probably something we could do before 1.0.

Merged via the queue into rust-lang:main with commit e8f1af4 Feb 18, 2025
44 checks passed
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Feb 18, 2025
(backport <rust-lang#4265>)
(cherry picked from commit e1e9d97)
@tgross35 tgross35 mentioned this pull request Feb 18, 2025
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Feb 18, 2025
@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented Feb 21, 2025

You should open an issue for changing the struct, that is probably something we could do before 1.0.

I've filed a pull request for this, which works on NetBSD 10, but I need some guidance on how to best support NetBSD 9. Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
O-unix S-waiting-on-review stable-applied This PR has been cherry-picked to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants