1UTIME(3P)                  POSIX Programmer's Manual                 UTIME(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       utime — set file access and modification times
14

SYNOPSIS

16       #include <utime.h>
17
18       int utime(const char *path, const struct utimbuf *times);
19

DESCRIPTION

21       The utime() function shall set the access and modification times of the
22       file named by the path argument.
23
24       If  times  is  a null pointer, the access and modification times of the
25       file shall be set to the current time. The effective  user  ID  of  the
26       process  shall  match  the  owner of the file, or the process has write
27       permission to the file or has appropriate privileges, to use utime() in
28       this manner.
29
30       If times is not a null pointer, times shall be interpreted as a pointer
31       to a utimbuf structure and the access and modification times  shall  be
32       set to the values contained in the designated structure. Only a process
33       with the effective user ID equal to the  user  ID  of  the  file  or  a
34       process with appropriate privileges may use utime() this way.
35
36       The  utimbuf structure is defined in the <utime.h> header. The times in
37       the structure utimbuf are measured in seconds since the Epoch.
38
39       Upon successful completion, the utime() function shall  mark  the  last
40       file status change timestamp for update; see <sys/stat.h>.
41

RETURN VALUE

43       Upon successful completion, 0 shall be returned. Otherwise, −1 shall be
44       returned and errno shall be set to indicate the  error,  and  the  file
45       times shall not be affected.
46

ERRORS

48       The utime() function shall fail if:
49
50       EACCES Search  permission  is denied by a component of the path prefix;
51              or the times argument is a null pointer and the  effective  user
52              ID  of  the  process  does  not match the owner of the file, the
53              process does not have write permission for  the  file,  and  the
54              process does not have appropriate privileges.
55
56       ELOOP  A loop exists in symbolic links encountered during resolution of
57              the path argument.
58
59       ENAMETOOLONG
60              The  length  of  a  component  of  a  pathname  is  longer  than
61              {NAME_MAX}.
62
63       ENOENT A component of path does not name an existing file or path is an
64              empty string.
65
66       ENOTDIR
67              A component of the path prefix names an existing  file  that  is
68              neither  a  directory nor a symbolic link to a directory, or the
69              path argument contains at least one  non-<slash>  character  and
70              ends  with  one or more trailing <slash> characters and the last
71              pathname component names an existing  file  that  is  neither  a
72              directory nor a symbolic link to a directory.
73
74       EPERM  The  times argument is not a null pointer and the effective user
75              ID of the calling process does not match the owner of  the  file
76              and the calling process does not have appropriate privileges.
77
78       EROFS  The file system containing the file is read-only.
79
80       The utime() function may fail if:
81
82       ELOOP  More  than  {SYMLOOP_MAX} symbolic links were encountered during
83              resolution of the path argument.
84
85       ENAMETOOLONG
86              The length of a pathname exceeds {PATH_MAX}, or pathname resolu‐
87              tion  of  a symbolic link produced an intermediate result with a
88              length that exceeds {PATH_MAX}.
89
90       The following sections are informative.
91

EXAMPLES

93       None.
94

APPLICATION USAGE

96       Since the utimbuf structure only contains time_t variables and  is  not
97       accurate  to fractions of a second, applications should use the utimen‐
98       sat() function instead of the obsolescent utime() function.
99

RATIONALE

101       The actime structure member must be present so that an application  may
102       set  it, even though an implementation may ignore it and not change the
103       last data access timestamp on the file. If an  application  intends  to
104       leave one of the times of a file unchanged while changing the other, it
105       should use stat() or fstat() to retrieve the file's st_atim and st_mtim
106       parameters,  set  actime  and  modtime in the buffer, and change one of
107       them before making the utime() call.
108

FUTURE DIRECTIONS

110       The utime() function may be removed in a future version.
111

SEE ALSO

113       fstat(), fstatat(), futimens()
114
115       The Base Definitions volume of POSIX.1‐2008, <sys_stat.h>, <utime.h>
116
118       Portions of this text are reprinted and reproduced in  electronic  form
119       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
120       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
121       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
122       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
123       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
124       event of any discrepancy between this version and the original IEEE and
125       The  Open Group Standard, the original IEEE and The Open Group Standard
126       is the referee document. The original Standard can be  obtained  online
127       at http://www.unix.org/online.html .
128
129       Any  typographical  or  formatting  errors that appear in this page are
130       most likely to have been introduced during the conversion of the source
131       files  to  man page format. To report such errors, see https://www.ker
132       nel.org/doc/man-pages/reporting_bugs.html .
133
134
135
136IEEE/The Open Group                  2013                            UTIME(3P)
Impressum