Skip to content

add btime for linux #13

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

Merged
merged 3 commits into from
Oct 3, 2023
Merged

add btime for linux #13

merged 3 commits into from
Oct 3, 2023

Conversation

mateusz834
Copy link
Contributor

@mateusz834 mateusz834 commented Jun 18, 2022

It adds btime support for linux using statx syscall.

@mateusz834 mateusz834 changed the title add btime on linux add btime for linux Jun 18, 2022
@djherbis djherbis self-requested a review June 20, 2022 12:56
times_linux.go Outdated
func Stat(name string) (Timespec, error) {
var statx unix.Statx_t

err := unix.Statx(unix.AT_FDCWD, name, unix.AT_EMPTY_PATH|unix.AT_STATX_SYNC_AS_STAT, unix.STATX_ATIME|unix.STATX_MTIME|unix.STATX_CTIME|unix.STATX_BTIME, &statx)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at AT_EMPTY_PATH does this mimic the behavior of the Stat command by default? Just curious.

@mateusz834 mateusz834 requested a review from djherbis June 21, 2022 17:04
@mateusz834
Copy link
Contributor Author

mateusz834 commented Aug 3, 2022

I replaced the Fd() with SyscallConn(), because the Fd() sets the fd to blocking mode, but It increases the allocation count.
Before:

BenchmarkStatFile-4      1000000              1257 ns/op              97 B/op          2 allocs/op

After:

BenchmarkStatFile-4       805016              1577 ns/op             401 B/op          6 allocs/op

@gildesmarais
Copy link

I came here via the mentioned Navidrome PR. Thank you for maintaining this library and thank you for this PR. 👍🏽

How are chances to see a merge of this PR? :)

@djherbis djherbis merged commit 03d4552 into djherbis:master Oct 3, 2023
@djherbis
Copy link
Owner

djherbis commented Oct 3, 2023

@gildesmarais Merged, I'll do some testing and maybe some minor refactoring before marking it as a release.

@certuna
Copy link

certuna commented Oct 12, 2023

Cool - will that be v1.6.0?

@djherbis
Copy link
Owner

It should be, it still needs testing with Linux with btime available I believe to verify it works.

I haven't had a chance to try it yet.

@djherbis
Copy link
Owner

Released: https://github.com/djherbis/times/releases/tag/v1.6.0

@djherbis
Copy link
Owner

I verified that I did get btime in a linux codespace :)

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 this pull request may close these issues.

4 participants