• Cesar Eduardo Barros's avatar
    [PATCH] O_NOATIME support · 5a86174c
    Cesar Eduardo Barros authored
    This patch adds support for the O_NOATIME open flag (GNU extension):
    
    int O_NOATIME  	Macro
      If this bit is set, read will not update the access time of the file.
      See File Times. This is used by programs that do backups, so that
      backing a file up does not count as reading it. Only the owner of the
      file or the superuser may use this bit.
    
    It is useful if you want to do something with the file atime (for instance,
    moving files that have not been accessed in a while to somewhere else, or
    something like Debian's popularity-contest) but you also want to read all
    files periodically (for instance, tripwire or debsums).
    
    Currently, the program that reads all files periodically has to use utimes,
    which can race with the atime update:
    
        A               B
      open
      fstat
      read
                      open
                      read
                      close
      close
      utimes
    
    And the file still has the old atime, instead of the new one from when B
    did the read from it.  This problem does not happen if A uses O_NOATIME
    instead of utimes to preserve the atime.
    
    This patch adds the O_NOATIME constant for all architectures, but it would
    also be possible to add it one architecture at a time by defining it to 0
    when not defined in asm-*.
    
    Based on patch by Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl> at
    http://www.uwsg.iu.edu/hypermail/linux/kernel/9811.2/0118.htmlSigned-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    5a86174c
fcntl.c 13.9 KB