[Top][All Lists]

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

Re: [coreutils] [PATCH 1/2] stat: support printing birthtime

From: Eric Blake
Subject: Re: [coreutils] [PATCH 1/2] stat: support printing birthtime
Date: Fri, 01 Oct 2010 09:13:12 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100921 Fedora/3.1.4-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.4

On 10/01/2010 09:11 AM, Jim Meyering wrote:
Eric Blake wrote:
+# Whether birthtime is supported or not, it better not change even when
+# [acm]time are modified.  :)
+touch a || fail=1
+btime=$(stat --format %W a) || fail=1
+atime=$(stat --format %X a) || fail=1
+mtime=$(stat --format %Y a) || fail=1
+ctime=$(stat --format %Z a) || fail=1
+case $(stat --format %x a) in
+  *.000000000*) sleep 2;; # worst case file system is FAT
+  *) # FIXME: sleep .1 would be sufficient if %X showed nanoseconds
+ sleep 1;; # should be adequate for any system with subsecond resolution

We try hard to avoid sleeping in the common case.
Any reason not to do what the FIXME suggests?

     case $(stat --format %X a) in
       *.000000000) sleep 1;;

You need two seconds for FAT.

       *) sleep .1;;

Done in patch 2/2 (see my other email) - you HAVE to sleep longer than the minimum resolution of %X...


+touch a || fail=1
+test "x$btime" = x$(stat --format %W a) || fail=1
+test "x$atime" != x$(stat --format %X a) || fail=1

before you can guarantee that %X changed. But if %X doesn't print subsecond details (as in patch 2/2), ... :)

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library

reply via email to

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