277 lines
5.7 KiB
HTML
277 lines
5.7 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of UTIME</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>UTIME</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
utime, utimes - change file last access and modification times
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>></B>
|
|
<B>#include <<A HREF="file:///usr/include/utime.h">utime.h</A>></B>
|
|
|
|
<B>int utime(const char *</B><I>filename</I><B>, const struct utimbuf *</B><I>times</I><B>);</B>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>></B>
|
|
|
|
<B>int utimes(const char *</B><I>filename</I><B>, const struct timeval </B><I>times</I><B>[2]);</B>
|
|
</PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>Note:</B>
|
|
|
|
modern applications may prefer to use the interfaces described in
|
|
<B><A HREF="/cgi-bin/man/man2html?2+utimensat">utimensat</A></B>(2).
|
|
|
|
<P>
|
|
|
|
The
|
|
<B>utime</B>()
|
|
|
|
system call
|
|
changes the access and modification times of the inode specified by
|
|
<I>filename</I>
|
|
|
|
to the
|
|
<I>actime</I> and <I>modtime</I>
|
|
|
|
fields of
|
|
<I>times</I>
|
|
|
|
respectively.
|
|
<P>
|
|
|
|
If
|
|
<I>times</I>
|
|
|
|
is NULL, then the access and modification times of the file are set
|
|
to the current time.
|
|
<P>
|
|
|
|
Changing timestamps is permitted when: either
|
|
the process has appropriate privileges,
|
|
or the effective user ID equals the user ID
|
|
of the file, or
|
|
<I>times</I>
|
|
|
|
is NULL and the process has write permission for the file.
|
|
<P>
|
|
|
|
The
|
|
<I>utimbuf</I>
|
|
|
|
structure is:
|
|
<P>
|
|
|
|
|
|
|
|
struct utimbuf {
|
|
<BR> time_t actime; /* access time */
|
|
<BR> time_t modtime; /* modification time */
|
|
};
|
|
|
|
|
|
<P>
|
|
|
|
The
|
|
<B>utime</B>()
|
|
|
|
system call
|
|
allows specification of timestamps with a resolution of 1 second.
|
|
<P>
|
|
|
|
The
|
|
<B>utimes</B>()
|
|
|
|
system call
|
|
is similar, but the
|
|
<I>times</I>
|
|
|
|
argument refers to an array rather than a structure.
|
|
The elements of this array are
|
|
<I>timeval</I>
|
|
|
|
structures, which allow a precision of 1 microsecond for specifying timestamps.
|
|
The
|
|
<I>timeval</I>
|
|
|
|
structure is:
|
|
<P>
|
|
|
|
|
|
|
|
struct timeval {
|
|
<BR> long tv_sec; /* seconds */
|
|
<BR> long tv_usec; /* microseconds */
|
|
};
|
|
|
|
|
|
<P>
|
|
|
|
<I>times</I>[0]
|
|
|
|
specifies the new access time, and
|
|
<I>times</I>[1]
|
|
|
|
specifies the new modification time.
|
|
If
|
|
<I>times</I>
|
|
|
|
is NULL, then analogously to
|
|
<B>utime</B>(),
|
|
|
|
the access and modification times of the file are
|
|
set to the current time.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success, zero is returned.
|
|
On error, -1 is returned, and
|
|
<I>errno</I>
|
|
|
|
is set appropriately.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>EACCES</B>
|
|
|
|
<DD>
|
|
Search permission is denied for one of the directories in
|
|
the path prefix of
|
|
<I>path</I>
|
|
|
|
(see also
|
|
<B><A HREF="/cgi-bin/man/man2html?7+path_resolution">path_resolution</A></B>(7)).
|
|
|
|
<DT id="2"><B>EACCES</B>
|
|
|
|
<DD>
|
|
<I>times</I>
|
|
|
|
is NULL,
|
|
the caller's effective user ID 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
|
|
<B>CAP_DAC_OVERRIDE</B>
|
|
|
|
or the
|
|
<B>CAP_FOWNER</B>
|
|
|
|
capability).
|
|
<DT id="3"><B>ENOENT</B>
|
|
|
|
<DD>
|
|
<I>filename</I>
|
|
|
|
does not exist.
|
|
<DT id="4"><B>EPERM</B>
|
|
|
|
<DD>
|
|
<I>times</I>
|
|
|
|
is not NULL,
|
|
the caller's effective UID does not match the owner of the file,
|
|
and the caller is not privileged
|
|
(Linux: does not have the
|
|
<B>CAP_FOWNER</B>
|
|
|
|
capability).
|
|
<DT id="5"><B>EROFS</B>
|
|
|
|
<DD>
|
|
<I>path</I>
|
|
|
|
resides on a read-only filesystem.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
<B>utime</B>():
|
|
|
|
SVr4, POSIX.1-2001.
|
|
POSIX.1-2008 marks
|
|
<B>utime</B>()
|
|
|
|
as obsolete.
|
|
<P>
|
|
|
|
<B>utimes</B>():
|
|
|
|
4.3BSD, POSIX.1-2001.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
Linux does not allow changing the timestamps on an immutable file,
|
|
or setting the timestamps to something other than the current time
|
|
on an append-only file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+chattr">chattr</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+touch">touch</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+futimesat">futimesat</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+stat">stat</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+utimensat">utimensat</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+futimens">futimens</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+futimes">futimes</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+inode">inode</A></B>(7)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="6"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="7"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="8"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="9"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="10"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="11"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="12"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DT id="13"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="14"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:35 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|