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

Feature request: wrap Linux's statx #1649

Open
vi opened this issue Jan 29, 2022 · 8 comments · May be fixed by #1660
Open

Feature request: wrap Linux's statx #1649

vi opened this issue Jan 29, 2022 · 8 comments · May be fixed by #1660

Comments

@vi
Copy link
Contributor

vi commented Jan 29, 2022

It has additional fourth "Birth time" for files.

@asomers
Copy link
Member

asomers commented Feb 6, 2022

This sounds like a reasonable addition. Would you care to submit a patch?

@vi
Copy link
Contributor Author

vi commented Feb 6, 2022

I can try, but I'm not sure it would be conformant to nix's standards.
How nix handles features available only in some (recent enough) Linux kernel versions?

@asomers
Copy link
Member

asomers commented Feb 6, 2022

We don't try to gate features based on kernel version. Rust links with --as-needed. That means if a binary crate that depends on nix doesn't use statx, then the resulting binary won't try to link that symbol at all. And if a binary crate does try to use statx, then it will either get a link error or get ENOSYS (if statx is a bare syscall, not wrapped by glibc). So from your perspective, there's little special care needed.

@vi
Copy link
Contributor Author

vi commented Feb 6, 2022

OK, I'll make a try.

@vi
Copy link
Contributor Author

vi commented Feb 9, 2022

How constants absent from libc should be handled (e.g. STATX_ATTR_DAX)?

Options:

  1. Omit from nix until libc adds them (maybe also file a pull request to libc, but not wait for it to be merged);
  2. Make a nix pull request dependent on libc pull request which adds additional values;
  3. Hard code specific values within nix, without using libc.

@vi
Copy link
Contributor Author

vi commented Feb 9, 2022

Also all statx-related things seem to be missing for musl target. Shall it be gated in nix as well or shall it be made independent instead?

vi added a commit to vi/nix that referenced this issue Feb 9, 2022
@vi vi linked a pull request Feb 9, 2022 that will close this issue
@vi
Copy link
Contributor Author

vi commented Feb 9, 2022

My first attempt: #1660.
Is it going in the correct direction or requires some substantial re-design?

@asomers
Copy link
Member

asomers commented Mar 9, 2022

The best way to handle constants that are missing in libc is to open a PR to add them to libc, and wait for that to merge before adding the functionality to Nix. And if musl lacks statx functionality, then simply disable it in Nix for musl targets. There should be plenty of examples of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants