TUX: Penguin Power!
Linux| Perl| PHP| Webserv| Databases| Sysadmin| Programming| Filesystems| Java| Webprog

Make Tux happy: Link to us!


SYNOPSIS
       #include <sys/stat.h>

       int utimensat(int dirfd, const char *pathname,
                     const struct timespec times[2], int flags);

       int futimens(int fd, const struct timespec times[2]);

   feature test macro requirements for glibc (see feature_test_macros(7)):

       utimensat(): _ATFILE_SOURCE
       futimens():  _GNU_SOURCE   /*  Will  likely  change  after POSIX.1-2008
       changes are incorporated into glibc */

DESCRIPTION
       utimensat() and  futimens()  update  the  timestamps  of  a  file  with
       nanosecond  precision.  this contrasts with the historical utime(2) and
       utimes(2), which permit only second and microsecond precision,  respec-
       tively, when setting file timestamps.

       With  utimensat() the file is specified via the pathname given in path-
       name.  With futimens() the file whose timestamps are to be  updated  is
       specified via an open file descriptor, fd.

       For  both  calls,  the  new  file timestamps are specified in the array
       times: times[0] specifies the new "last access time" (atime);  times[1]
       specifies  the  new "last modification time" (mtime).  Each of the ele-
       ments of times specifies a time in seconds and  nanoseconds  since  the
       Epoch  (00:00:00,  1  Jan  1970,  UTC), in a structure of the following
       form:

           struct timespec {
               time_t tv_sec;        /* seconds */
               long   tv_nsec;       /* nanoseconds */
           };

       Updated file timestamps are set to the greatest value supported by  the
       file system that is not greater than the specified time.

       If  the tv_nsec field of one of the timespec structures has the special
       value UTIME_NOW, then the corresponding file timestamp is  set  to  the
       current  time.   If the tv_nsec field of one of the timespec structures
       has the special value UTIME_OMIT, then the corresponding file timestamp
       is  left  unchanged.   In  both of these cases, the value of the corre-
       sponding tv_sec field is ignored.

       If times is NULL, then both timestamps are set to the current time.

   Permissions requirements
       To set both file timestamps to the current time (i.e., times  is  NULL,
       or both tv_nsec fields specify UTIME_NOW), either:

       1. the caller must have write access to the file;
       not modified, but other error conditions may still be detected.

   utimensat() specifics
       If pathname is relative, then by default it is interpreted relative  to
       the  directory  referred  to by the open file descriptor, dirfd (rather
       than relative to the current working directory of the calling  process,
       as is done by utimes(2) for a relative pathname).  see openat(2) for an
       explanation of why this can be useful.

       If pathname is relative and dirfd is the special value  AT_FDCWD,  then
       pathname  is  interpreted  relative to the current working directory of
       the calling process (like utimes(2)).

       If pathname is absolute, then dirfd is ignored.

       The flags field is a bit mask that may be 0, or include  the  following
       constant, defined in <fcntl.h>:

       AT_SYMLINK_NOFOLLOW
              If  pathname  specifies  a  symbolic link, then update the time-
              stamps of the link, rather than the file to which it refers.

RETURN VALUE
       On success, utimensat() and futimens()  return  0.   On  error,  -1  is
       returned and errno is set to indicate the error.

ERRORS
       EACCES times is NULL, or both tv_nsec values are UTIME_NOW, and:
              * the  effective  user ID of the caller does not match the owner
                of the file, the caller does not  have  write  access  to  the
                file,  and  the caller is not privileged (Linux: does not have
                either the CAP_FOWNER or the CAP_DAC_OVERRIDE capability); or,
              * the file is marked immutable (see chattr(1)).

       EBADF  (futimens()) fd is not a valid file descriptor.

       EBADF  (utimensat()) pathname is a relative pathname, but dirfd is nei-
              ther AT_FDCWD nor a valid file descriptor.

       EFAULT times pointed to an invalid address; or, dirfd was AT_FDCWD, and
              pathname is NULL or an invalid address.

       EINVAL Invalid value in flags.

       EINVAL Invalid value in one of the tv_nsec fields (value outside  range
              0  to  999,999,999,  and  not  UTIME_NOW  or  UTIME_OMIT); or an
              invalid value in one of the tv_sec fields.

       EINVAL pathname is NULL, dirfd is  not  AT_FDCWD,  and  flags  contains
              AT_SYMLINK_NOFOLLOW.

       ELOOP  (utimensat())  Too  many  symbolic  links  were  encountered  in
              resolving pathname.

              other than the current time, or to change one of the  timestamps
              to the current time while leaving the other timestamp unchanged,
              (i.e., times is not NULL, both tv_nsec fields are not UTIME_NOW,
              and both tv_nsec fields are not UTIME_OMIT) and:
              * the  caller's  effective  user  ID does not match the owner of
                file, and the caller is not privileged (Linux: does  not  have
                the CAP_FOWNER capability); or,
              * the file is marked append-only or immutable (see chattr(1)).

       EROFS  The file is on a read-only file system.

       ESRCH  (utimensat())  Search permission is denied for one of the prefix
              components of pathname.

VERSIONS
       utimensat() was added to Linux in  kernel  2.6.22;  glibc  support  was
       added with version 2.6.

       Support for futimens() first appeared in glibc 2.6.

CONFORMING TO
       futimens() and utimensat() are specified in POSIX.1-2008.

NOTES
       utimensat() obsoletes futimesat(2).

       On Linux, timestamps cannot be changed for a file marked immutable, and
       the only change permitted for files marked append-only is  to  set  the
       timestamps  to the current time.  (This is consistent with the histori-
       cal behavior of utime(2) and utimes(2) on linux.)

       On Linux, futimens() is a library function implemented on  top  of  the
       utimensat() system call.  To support this, the Linux utimensat() system
       call implements a non-standard feature: if pathname is NULL,  then  the
       call  modifies  the  timestamps  of  the  file  referred to by the file
       descriptor dirfd (which may refer to any type  of  file).   Using  this
       feature, the call futimens(fd, times) is implemented as:

           utimensat(fd, NULL, times, 0);

BUGS
       Several  bugs  afflict  utimensat()  and  futimens()  on kernels before
       2.6.26.  These bugs are either non-conformances with the POSIX.1  draft
       specification or inconsistencies with historical Linux behavior.

       * POSIX.1  specifies  that  if  one of the tv_nsec fields has the value
         UTIME_NOW or UTIME_OMIT, then the value of the  corresponding  tv_sec
         field  should  be ignored.  Instead, the value of the tv_sec field is
         required to be 0 (or the error EINVAL results).

       * Various bugs mean that for the purposes of permission  checking,  the
         case  where  both  tv_nsec  fields  are set to UTIME_NOW isn't always
         treated the same as specifying times as NULL, and the case where  one
         tv_nsec  value is UTIME_NOW and the other is UTIME_OMIT isn't treated
         writing.

SEE ALSO
       chattr(1), futimesat(2),  openat(2),  stat(2),  utimes(2),  futimes(3),
       path_resolution(7), symlink(7)

COLOPHON
       This  page  is  part of release 3.23 of the Linux man-pages project.  A
       description of the project, and information about reporting  bugs,  can
       be found at http://www.kernel.org/doc/man-pages/.



Find all the song lyrics here: Lyrics Now!