alexcrichton / filetime

Accessing file timestamps in a platform-agnostic fashion in Rust
Apache License 2.0
122 stars 56 forks source link

Add a fallback for utimensat ENOSYS #20

Closed cuviper closed 6 years ago

cuviper commented 6 years ago

Even when libc has utimensat, the kernel may return ENOSYS, and then we'll need to use the utimes fallback instead.

alexcrichton commented 6 years ago

I'm sort of curious, how does C manage this sort of issue? Does every library end up having similar patches along these lines?

In any case looks good, thanks! Would you like a version bump as well?

cuviper commented 6 years ago

The "fun" part is that the symlink lutimes fallback doesn't actually work. On newer systems, lutimes is implemented on top of utimensat anyway. On older systems like RHEL5, which have the lutimes symbol but no utimensat, it's just an ENOSYS stub. 🤷‍♂️

The fallback does work for set_file_times though.

cuviper commented 6 years ago

how does C manage this sort of issue?

You can stick to old syscalls only, implement an ENOSYS fallback like this, or just raise your bar of supported kernels. You'll often see these kind of messes in autoconf'ed #if HAVE_FOO blocks.

A new release would be great, thanks!

alexcrichton commented 6 years ago

Hm ok, fascinating! I'm sort of glad I don't write C, I'd never remember all this...

In any case, 0.1.15 should be published now.