[Top][All Lists]

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

Re: [coreutils] [PATCH 2/2] stat: print timestamps to full resolution

From: Pádraig Brady
Subject: Re: [coreutils] [PATCH 2/2] stat: print timestamps to full resolution
Date: Fri, 01 Oct 2010 02:00:05 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100227 Thunderbird/3.0.3

On 01/10/10 00:32, Eric Blake wrote:
> * src/stat.c (epoch_time): New function.
> (print_stat): Use it for %[WXYZ].
> * NEWS: Document this.
> * tests/touch/60-seconds: Adjust test to match.
> ---
> It bugs me that %x has more information than %X in 'stat --format',
> especially, since we don't support any format modifiers for getting
> at the additional information.  We're already incompatible with
> BSD stat(1) format modifiers, and there is no standard for stat(1),
> so I wasn't too worried about changing the meaning of existing
> modifiers rather than burning new letters just for the nanosecond
> portions.  And now that POSIX 2008 requires nanonsecond resolution
> in stat(2), you could argue that we should always be displaying it.

It looks like ext4 at least supports
nanosecond resolution timestamps

$ date --reference=/ext4/ +%s.%N
$ date --reference=/ext3/ +%s.%N

There is a fair chance that scripts may break
that assume %X is an integer.
I'd be all on for it otherwise.
As it is I'm 60:40 for the change.


> +epoch_time (struct timespec t)
> +{
> +  static char str[INT_STRLEN_BOUND (time_t) + sizeof ".NNNNNNNNN"];
> +  if (TYPE_SIGNED (time_t))
> +    sprintf (str, "%" PRIdMAX ".%09lu", (intmax_t) t.tv_sec,
> +             (unsigned long) t.tv_nsec);
> +  else
> +    sprintf (str, "%" PRIuMAX ".%09lu", (uintmax_t) t.tv_sec,
> +             (unsigned long) t.tv_nsec);
> +  return str;

time_t can be a float on weird platforms I think?


reply via email to

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