Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NetBSD: fix getmntinfo for NetBSD #4265

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-unix S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants