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

Use statx on Linux #61386

Draft
wants to merge 1 commit into
base: master
from

Conversation

@ariasuni
Copy link
Contributor

commented May 31, 2019

Fix #59743

Using statx on Linux notably gives us access to stx_btime so we can return a value for Metadata::created().

I implemented the feature but need time to improve the code:

  • Update the
  • Find how to fallback in an efficient way when glibc version < 2.28
    • stat64 and statx returns different structs, and it seems that right now it’s not possible to know the glibc version at compile-time. I can make FileAttr an enum which can be either one.
    • Should I use sys::os::glibc_version() or something like
      if !__cxa_thread_atexit_impl.is_null() {
  • I added st_{r,}dev_{major,minor}, but I’m not sure it’s the proper way to do it.
  • Being able to access all fields of statx as functions like the other information is probably something that you’d like to have.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented May 31, 2019

r? @KodrAus

(rust_highfive has picked a reviewer for you, use r? to override)

@xen0n

This comment has been minimized.

Copy link
Contributor

commented Jun 5, 2019

If you get -ENOSYS when calling statx(2) first, that means the syscall is not implemented so you can fallback to stat(2). You probably don't want to detect for this every time stat is called, though.

@bors

This comment has been minimized.

Copy link
Contributor

commented Jun 7, 2019

☔️ The latest upstream changes (presumably #61408) made this pull request unmergeable. Please resolve the merge conflicts.

@ariasuni

This comment has been minimized.

Copy link
Contributor Author

commented Jun 13, 2019

@xen0n Do you suggest using the syscall instead of the glibc wrapper?

You probably don't want to detect for this every time stat is called, though.

But I don’t see how to “save” the fact that statx is available or not. I would prefer being able to detect that at compile-time but it doesn’t seem possible as far as I know (which is not that much since I am new at contributing to Rust).

@uHOOCCOOHu

This comment has been minimized.

Copy link

commented Jun 17, 2019

For syscall to statx, I have already made a wrapper statx-sys which may helps. So we can keep dependency to the old version of glibc.

@ariasuni I think this can be simply achieved by setting an atomic static flag for the first ENOSYS.

But I don’t see how to “save” the fact that statx is available or not. I would prefer being able to detect that at compile-time but it doesn’t seem possible as far as I know (which is not that much since I am new at contributing to Rust).

@cuviper

This comment has been minimized.

Copy link
Member

commented Aug 2, 2019

For tracking ENOSYS, look at how copy_file_range is handled. Note that it also calls manually through libc::syscall, avoiding the problem of libc not having the new symbol at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.