nix icon indicating copy to clipboard operation
nix copied to clipboard

Feature request: wrap Linux's `statx`

Open vi opened this issue 3 years ago • 8 comments
trafficstars

It has additional fourth "Birth time" for files.

vi avatar Jan 29 '22 23:01 vi

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

asomers avatar Feb 06 '22 16:02 asomers

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?

vi avatar Feb 06 '22 20:02 vi

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.

asomers avatar Feb 06 '22 21:02 asomers

OK, I'll make a try.

vi avatar Feb 06 '22 23:02 vi

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 avatar Feb 09 '22 16:02 vi

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 avatar Feb 09 '22 20:02 vi

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

vi avatar Feb 09 '22 21:02 vi

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.

asomers avatar Mar 09 '22 03:03 asomers