coreutils
[Top][All Lists]
Advanced

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

Re: stat: reading btime on linux via statx


From: Pádraig Brady
Subject: Re: stat: reading btime on linux via statx
Date: Sun, 3 Mar 2019 23:39:27 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 03/03/19 23:12, Bernhard Voelker wrote:
> On 3/4/19 6:20 AM, Pádraig Brady wrote:
>> I'll push this now.
> 
> Sorry, a bit late:
> 
> $ make sc_space_before_open_paren
>   space_before_open_paren
>              ? statx(AT_FDCWD, filename,
>              : statx(fd, "", AT_EMPTY_PATH, STATX_BTIME, &stx)) == 0)
>   *** src/stat.c
>   maint.mk: the above files lack a space-before-open-paren

Fixed.

> And a little question:
> 
> +#if HAVE_STATX
> +  if (ts.tv_nsec < 0)
> +    {
> +      struct statx stx;
> +      if ((fd < 0
> +           ? statx(AT_FDCWD, filename,
> +                   follow_links ? 0 : AT_SYMLINK_NOFOLLOW,
> +                   STATX_BTIME, &stx)
> +           : statx(fd, "", AT_EMPTY_PATH, STATX_BTIME, &stx)) == 0)
> +        {
> +          if ((stx.stx_mask & STATX_BTIME) && stx.stx_btime.tv_sec != 0)
> ____________________________________________^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Why do we need this extra check? As I read 'man statx', the test on the 
> stx_mask
> should be enough.  And - highly unlikely -: if the BTIME is in the first 
> second
> after epoch, then TV_SEC will be 0 while TV_NSEC might not.
> 
> Otherwise: nice feature, thanks!

I would have just used the mask,
though searching I see that systemd also checks tv_sec.
So I'm thinking perhaps on some kernels/file systems
this is left at zero, without setting the mask.
Also this feature wasn't available in 1970 :),
so I thought it safer to keep that check.

thanks for the review,
Pádraig




reply via email to

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