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: Martin Bukatovic
Subject: Re: stat: reading btime on linux via statx
Date: Tue, 5 Mar 2019 01:26:50 +0100
User-agent: Mutt/1.11.3 (2019-02-01)

On Sun, Mar 03, 2019 at 11:39:27PM -0800, Pádraig Brady wrote:
> On 03/03/19 23:12, Bernhard Voelker wrote:
> > +          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.

In my 1st version of the patch, I didn't use stx_mask check because I
haven't read the manpage throuhg enough. But your point about check in
systemd get me thinking what else I'm missing, as it seems that checking
the mask should be enough. So I run into this note in commit
introcuding statx syscall[1]:


     (1) stx_mode, stx_nlinks, stx_uid, stx_gid, stx_[amc]time, stx_ino,
         stx_size, stx_blocks.
    
         These will be returned whether the caller asks for them or not.  The
         corresponding bits in stx_mask will be set to indicate whether they
         actually have valid values.
    
         If the caller didn't ask for them, then they may be approximated.  For
         example, NFS won't waste any time updating them from the server,
         unless as a byproduct of updating something requested.
    
         If the values don't actually exist for the underlying object (such as
         UID or GID on a DOS file), then the bit won't be set in the stx_mask,
         even if the caller asked for the value.  In such a case, the returned
         value will be a fabrication.
    
         Note that there are instances where the type might not be valid, for
         instance Windows reparse points.
    
     (3) stx_btime.
    
         Similar to (1), except this will be set to 0 if it doesn't exist.


That said, the manpage doesn't mention this.

[1]: 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a528d35e8bfcc521d7cb70aaf03e1bd296c8493f


-- 
Martin Bukatovič



reply via email to

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