coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] stat read crtime from ext4


From: Andre "Osku" Schmidt
Subject: Re: [coreutils] stat read crtime from ext4
Date: Sat, 21 Aug 2010 12:58:23 +0200

On Fri, 2010-08-20 at 23:15 +0200, Andre "Osku" Schmidt wrote:
> On Fri, 2010-08-20 at 14:54 -0600, Eric Blake wrote:
> > On 08/20/2010 02:51 PM, Andre "Osku" Schmidt wrote:
> > > Hello,
> > > 
> > > are there any "problems" for `stat` to read crtime from ext4 ?
> > 
> > Gnulib already supports the code for reading Btime (aka ext4's crtime,
> > aka birth-time) from all file systems that support it (at least ext4 and
> > NTFS).  It's just that no one has yet written the code to make stat(1)
> > take advantage of this code in the stat-times module.
> 
> Oh, that was a fast answer, thank you. And as it's even the second best
> answer i was hoping for, i'm now really curious and just go grab the
> source and see if i can get any code hacked together :P

hmm,

either im doing this wrong (probably, i only did compare and trial and
error;) or reading crtime from ext4 doesn't work here.

heres a test file:
sudo debugfs -R 'stat /home/osku/foo/foo' /dev/sda7
debugfs 1.41.12 (17-May-2010)
Inode: 541166   Type: regular    Mode:  0644   Flags: 0x80000
Generation: 2131279737    Version: 0x00000000:00000001
User:  1000   Group:  1000   Size: 20
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 8
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x4c6e76a1:7997ee24 -- Fri Aug 20 14:35:45 2010
 atime: 0x4c6e73f3:aadddcc4 -- Fri Aug 20 14:24:19 2010
 mtime: 0x4c6e76a1:7997ee24 -- Fri Aug 20 14:35:45 2010
crtime: 0x4c6e7366:7f281570 -- Fri Aug 20 14:21:58 2010
Size of extra inode fields: 28
EXTENTS:
(0): 2487011

and i added this (for test) to src/stat.c ~ 720:
case 'k':
  out_string (pformat, prefix_len, human_time (get_stat_birthtime
(statbuf)));
  break;

and tested:
./src/stat --format=%k ~/foo/foo 
1970-01-01 00:59:59.-00000001 +0100

so it seems this lands in get_stat_birthtime (stat-time.h) to:
#else
  /* Birth time is not supported.  Set tv_sec to avoid undefined
behavior.  */
  t.tv_sec = -1;
  t.tv_nsec = -1;
  /* Avoid a "parameter unused" warning.  */
  (void) st;
#endif

as said, i'm probably doing this wrong and i dont really have any
experience with c nor this code nor the subject... but it irritates me
that (ext2/3/4?) atime, mtime and ctime are "read" with st->st_atime,
st->st_mtime and st->st_atime. but in get_stat_birthtime theres nothing
reading (nor does it exist) st->st_crtime...

well, i think this is the end for me. i really should not dig where i
have no real idea and my poor grep searches didnt enlighten me where
things like st->st_atime really come from. but it was still fun to
play :)

cheers
.andre

ps. this is on archlinux and coreutils-8.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]