[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
stat: reading btime on linux via statx
From: |
Martin Bukatovic |
Subject: |
stat: reading btime on linux via statx |
Date: |
Sun, 23 Dec 2018 21:30:39 +0100 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
Dear coreutils list,
I'm interested in seeing btime (birth time) in stat output on GNU Linux
distributions. Since statx syscall is available since Linux 4.11 [1] and
glibc wrapper is available since 2.28 [2], now it's finally possible to
use statx in coreutils tools to display btime.
I checked the source code of stat and related parts in gnulib
(stat-time.h) briefly and it seems to me that the current support for
reporting birth time of a file works on BSD systems and Solaris only.
To add support for reading btime with Linux, it seems that gnulib
functions needs to be generalized to use statx when compiled on recent
Linux kernel. Is anybody already working on this?
In the meantime, I tried to quickly hack the stat code to add support
for reading btime via statx in a similar way how btime is read on
Solaris via getattrat (patch attached). This way, I was able to play
with this feature quickly:
```
$ touch ~/tmp/testfile
$ ./stat ~/tmp/testfile
File: /home/martin/tmp/testfile
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd07h/64775d Inode: 7388546 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ martin) Gid: ( 1000/ martin)
Access: 2018-12-23 21:18:27.717535190 +0100
Modify: 2018-12-23 21:18:27.717535190 +0100
Change: 2018-12-23 21:18:27.717535190 +0100
Birth: 2018-12-23 21:18:27.717535190 +0100
$ touch ~/tmp/testfile
$ ./stat ~/tmp/testfile
File: /home/martin/tmp/testfile
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd07h/64775d Inode: 7388546 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ martin) Gid: ( 1000/ martin)
Access: 2018-12-23 21:18:34.822543416 +0100
Modify: 2018-12-23 21:18:34.822543416 +0100
Change: 2018-12-23 21:18:34.822543416 +0100
Birth: 2018-12-23 21:18:27.717535190 +0100
```
But as I said, this is rather quick hack, I don't expect you to want
to merge this.
[1]
https://kernelnewbies.org/Linux_4.11#statx.282.29.2C_a_modern_stat.282.29_alternative
[2] https://www.sourceware.org/ml/libc-alpha/2018-08/msg00003.html
--
Martin Bukatovič
linux-btime-hack.patch
Description: Text document
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- stat: reading btime on linux via statx,
Martin Bukatovic <=