Blame man-pages-posix-2013-a/man3p/utime.3p

Packit 7cfc04
'\" et
Packit 7cfc04
.TH UTIME "3P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
Packit 7cfc04
.SH PROLOG
Packit 7cfc04
This manual page is part of the POSIX Programmer's Manual.
Packit 7cfc04
The Linux implementation of this interface may differ (consult
Packit 7cfc04
the corresponding Linux manual page for details of Linux behavior),
Packit 7cfc04
or the interface may not be implemented on Linux.
Packit 7cfc04
Packit 7cfc04
.SH NAME
Packit 7cfc04
utime
Packit 7cfc04
\(em set file access and modification times
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.LP
Packit 7cfc04
.nf
Packit 7cfc04
#include <utime.h>
Packit 7cfc04
.P
Packit 7cfc04
int utime(const char *\fIpath\fP, const struct utimbuf *\fItimes\fP);
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
\fIutime\fR()
Packit 7cfc04
function shall set the access and modification times of the file named
Packit 7cfc04
by the
Packit 7cfc04
.IR path
Packit 7cfc04
argument.
Packit 7cfc04
.P
Packit 7cfc04
If
Packit 7cfc04
.IR times
Packit 7cfc04
is a null pointer, the access and modification times of the file shall
Packit 7cfc04
be set to the current time. The effective user ID of the process shall
Packit 7cfc04
match the owner of the file, or the process has write permission to the
Packit 7cfc04
file or has appropriate privileges, to use
Packit 7cfc04
\fIutime\fR()
Packit 7cfc04
in this manner.
Packit 7cfc04
.P
Packit 7cfc04
If
Packit 7cfc04
.IR times
Packit 7cfc04
is not a null pointer,
Packit 7cfc04
.IR times
Packit 7cfc04
shall be interpreted as a pointer to a
Packit 7cfc04
.BR utimbuf
Packit 7cfc04
structure and the access and modification times shall be set to the
Packit 7cfc04
values contained in the designated structure. Only a process with
Packit 7cfc04
the effective user ID equal to the user ID of the file or a process with
Packit 7cfc04
appropriate privileges may use
Packit 7cfc04
\fIutime\fR()
Packit 7cfc04
this way.
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR utimbuf
Packit 7cfc04
structure is defined in the
Packit 7cfc04
.IR <utime.h> 
Packit 7cfc04
header. The times in the structure
Packit 7cfc04
.BR utimbuf
Packit 7cfc04
are measured in seconds since the Epoch.
Packit 7cfc04
.P
Packit 7cfc04
Upon successful completion, the
Packit 7cfc04
\fIutime\fR()
Packit 7cfc04
function shall mark the last file status change timestamp
Packit 7cfc04
for update; see
Packit 7cfc04
.IR <sys/stat.h> .
Packit 7cfc04
.SH "RETURN VALUE"
Packit 7cfc04
Upon successful completion, 0 shall be returned. Otherwise, \(mi1
Packit 7cfc04
shall be returned and
Packit 7cfc04
.IR errno
Packit 7cfc04
shall be set to indicate the error, and the file times shall not be
Packit 7cfc04
affected.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
The
Packit 7cfc04
\fIutime\fR()
Packit 7cfc04
function shall fail if:
Packit 7cfc04
.TP
Packit 7cfc04
.BR EACCES
Packit 7cfc04
Search permission is denied by a component of the path prefix; or the
Packit 7cfc04
.IR times
Packit 7cfc04
argument is a null pointer and the effective user ID of the process
Packit 7cfc04
does not match the owner of the file, the process does not have write
Packit 7cfc04
permission for the file, and the process does not have appropriate
Packit 7cfc04
privileges.
Packit 7cfc04
.TP
Packit 7cfc04
.BR ELOOP
Packit 7cfc04
A loop exists in symbolic links encountered during resolution of the
Packit 7cfc04
.IR path
Packit 7cfc04
argument.
Packit 7cfc04
.TP
Packit 7cfc04
.BR ENAMETOOLONG
Packit 7cfc04
.br
Packit 7cfc04
The length of a component of a pathname is longer than
Packit 7cfc04
{NAME_MAX}.
Packit 7cfc04
.TP
Packit 7cfc04
.BR ENOENT
Packit 7cfc04
A component of
Packit 7cfc04
.IR path
Packit 7cfc04
does not name an existing file or
Packit 7cfc04
.IR path
Packit 7cfc04
is an empty string.
Packit 7cfc04
.TP
Packit 7cfc04
.BR ENOTDIR
Packit 7cfc04
A component of the path prefix names an existing file that is neither
Packit 7cfc04
a directory nor a symbolic link to a directory, or the
Packit 7cfc04
.IR path
Packit 7cfc04
argument contains at least one non-\c
Packit 7cfc04
<slash>
Packit 7cfc04
character and ends with one or more trailing
Packit 7cfc04
<slash>
Packit 7cfc04
characters and the last pathname component names an existing file
Packit 7cfc04
that is neither a directory nor a symbolic link to a directory.
Packit 7cfc04
.TP
Packit 7cfc04
.BR EPERM
Packit 7cfc04
The
Packit 7cfc04
.IR times
Packit 7cfc04
argument is not a null pointer and the effective user ID of the calling
Packit 7cfc04
process does not match the owner of the file and the calling process
Packit 7cfc04
does not have appropriate privileges.
Packit 7cfc04
.TP
Packit 7cfc04
.BR EROFS
Packit 7cfc04
The file system containing the file is read-only.
Packit 7cfc04
.br
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
\fIutime\fR()
Packit 7cfc04
function may fail if:
Packit 7cfc04
.TP
Packit 7cfc04
.BR ELOOP
Packit 7cfc04
More than
Packit 7cfc04
{SYMLOOP_MAX}
Packit 7cfc04
symbolic links were encountered during resolution of the
Packit 7cfc04
.IR path
Packit 7cfc04
argument.
Packit 7cfc04
.TP
Packit 7cfc04
.BR ENAMETOOLONG
Packit 7cfc04
.br
Packit 7cfc04
The length of a pathname exceeds
Packit 7cfc04
{PATH_MAX},
Packit 7cfc04
or pathname resolution of a symbolic link produced an intermediate
Packit 7cfc04
result with a length that exceeds
Packit 7cfc04
{PATH_MAX}.
Packit 7cfc04
.LP
Packit 7cfc04
.IR "The following sections are informative."
Packit 7cfc04
.SH EXAMPLES
Packit 7cfc04
None.
Packit 7cfc04
.SH "APPLICATION USAGE"
Packit 7cfc04
Since the
Packit 7cfc04
.BR utimbuf
Packit 7cfc04
structure only contains
Packit 7cfc04
.BR time_t
Packit 7cfc04
variables and is not accurate to fractions of a second,
Packit 7cfc04
applications should use the
Packit 7cfc04
\fIutimensat\fR()
Packit 7cfc04
function instead of the obsolescent
Packit 7cfc04
\fIutime\fR()
Packit 7cfc04
function.
Packit 7cfc04
.SH RATIONALE
Packit 7cfc04
The
Packit 7cfc04
.IR actime
Packit 7cfc04
structure member must be present so that an application may set it,
Packit 7cfc04
even though an implementation may ignore it and not change the last data
Packit 7cfc04
access timestamp on the file. If an application intends to leave one of
Packit 7cfc04
the times of a file unchanged while changing the other, it should use
Packit 7cfc04
\fIstat\fR()
Packit 7cfc04
or
Packit 7cfc04
\fIfstat\fR()
Packit 7cfc04
to retrieve the file's
Packit 7cfc04
.IR st_atim
Packit 7cfc04
and
Packit 7cfc04
.IR st_mtim
Packit 7cfc04
parameters, set
Packit 7cfc04
.IR actime
Packit 7cfc04
and
Packit 7cfc04
.IR modtime
Packit 7cfc04
in the buffer, and change one of them before making the
Packit 7cfc04
\fIutime\fR()
Packit 7cfc04
call.
Packit 7cfc04
.SH "FUTURE DIRECTIONS"
Packit 7cfc04
The
Packit 7cfc04
\fIutime\fR()
Packit 7cfc04
function may be removed in a future version.
Packit 7cfc04
.SH "SEE ALSO"
Packit 7cfc04
.IR "\fIfstat\fR\^(\|)",
Packit 7cfc04
.IR "\fIfstatat\fR\^(\|)",
Packit 7cfc04
.IR "\fIfutimens\fR\^(\|)"
Packit 7cfc04
.P
Packit 7cfc04
The Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "\fB<sys_stat.h>\fP",
Packit 7cfc04
.IR "\fB<utime.h>\fP"
Packit 7cfc04
.SH COPYRIGHT
Packit 7cfc04
Portions of this text are reprinted and reproduced in electronic form
Packit 7cfc04
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
Packit 7cfc04
-- Portable Operating System Interface (POSIX), The Open Group Base
Packit 7cfc04
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Packit 7cfc04
Electrical and Electronics Engineers, Inc and The Open Group.
Packit 7cfc04
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
Packit 7cfc04
event of any discrepancy between this version and the original IEEE and
Packit 7cfc04
The Open Group Standard, the original IEEE and The Open Group Standard
Packit 7cfc04
is the referee document. The original Standard can be obtained online at
Packit 7cfc04
http://www.unix.org/online.html .
Packit 7cfc04
Packit 7cfc04
Any typographical or formatting errors that appear
Packit 7cfc04
in this page are most likely
Packit 7cfc04
to have been introduced during the conversion of the source files to
Packit 7cfc04
man page format. To report such errors, see
Packit 7cfc04
https://www.kernel.org/doc/man-pages/reporting_bugs.html .