2004-11-03 13:51:07 +00:00
|
|
|
.\" Hey Emacs! This file is -*- nroff -*- source.
|
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" Modified by Michael Haardt <michael@moria.de>
|
|
|
|
.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
|
|
|
|
.\" Modified 1995-06-10 by Andries Brouwer <aeb@cwi.nl>
|
2007-09-20 06:52:22 +00:00
|
|
|
.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Modified 2004-10-10 by Andries Brouwer <aeb@cwi.nl>
|
|
|
|
.\"
|
2008-08-06 10:45:14 +00:00
|
|
|
.TH UTIME 2 2008-08-06 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
2008-03-18 09:50:51 +00:00
|
|
|
utime, utimes \- change file last access and modification times
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
|
|
|
.B #include <sys/types.h>
|
|
|
|
.br
|
|
|
|
.B #include <utime.h>
|
|
|
|
.sp
|
2008-05-16 13:40:15 +00:00
|
|
|
.BI "int utime(const char *" filename ", const struct utimbuf *" times );
|
2007-04-03 14:04:54 +00:00
|
|
|
.sp
|
2004-11-03 13:51:07 +00:00
|
|
|
.B #include <sys/time.h>
|
|
|
|
.sp
|
2006-04-22 00:00:13 +00:00
|
|
|
.BI "int utimes(const char *" filename ", const struct timeval " times [2]);
|
2004-11-03 13:51:07 +00:00
|
|
|
.fi
|
|
|
|
.SH DESCRIPTION
|
2008-05-16 13:40:15 +00:00
|
|
|
The
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR utime ()
|
2008-05-16 13:40:15 +00:00
|
|
|
system call
|
2004-11-03 13:51:07 +00:00
|
|
|
changes the access and modification times of the inode specified by
|
|
|
|
.I filename
|
|
|
|
to the
|
|
|
|
.IR actime " and " modtime
|
2007-04-12 22:42:49 +00:00
|
|
|
fields of
|
2008-05-30 14:12:46 +00:00
|
|
|
.I times
|
2004-11-03 13:51:07 +00:00
|
|
|
respectively.
|
|
|
|
|
|
|
|
If
|
2008-05-16 13:40:15 +00:00
|
|
|
.I times
|
2004-11-03 13:51:07 +00:00
|
|
|
is NULL, then the access and modification times of the file are set
|
|
|
|
to the current time.
|
|
|
|
|
2008-03-18 09:50:51 +00:00
|
|
|
Changing timestamps is permitted when: either
|
2008-05-16 13:40:15 +00:00
|
|
|
the process has appropriate privileges,
|
|
|
|
or the effective user ID equals the user ID
|
2004-11-03 13:51:07 +00:00
|
|
|
of the file, or
|
2008-05-16 13:40:15 +00:00
|
|
|
.I times
|
|
|
|
is NULL and the process has write permission for the file.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
|
|
|
The
|
|
|
|
.I utimbuf
|
|
|
|
structure is:
|
|
|
|
|
2007-12-19 06:16:04 +00:00
|
|
|
.in +4n
|
2004-11-03 13:51:07 +00:00
|
|
|
.nf
|
|
|
|
struct utimbuf {
|
2006-04-22 00:00:13 +00:00
|
|
|
time_t actime; /* access time */
|
|
|
|
time_t modtime; /* modification time */
|
2004-11-03 13:51:07 +00:00
|
|
|
};
|
|
|
|
.fi
|
2007-12-19 06:16:04 +00:00
|
|
|
.in
|
2004-11-03 13:51:07 +00:00
|
|
|
|
2008-05-16 13:40:15 +00:00
|
|
|
The
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR utime ()
|
2008-05-16 13:40:15 +00:00
|
|
|
system call
|
2008-03-18 09:50:51 +00:00
|
|
|
allows specification of timestamps with a resolution of 1 second.
|
2008-04-23 18:00:52 +00:00
|
|
|
|
2008-05-16 13:40:15 +00:00
|
|
|
The
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR utimes ()
|
2008-05-16 13:40:15 +00:00
|
|
|
system call
|
2007-07-08 18:25:40 +00:00
|
|
|
is similar, but the
|
|
|
|
.I times
|
2008-09-18 12:30:41 +00:00
|
|
|
argument refers to an array rather than a structure.
|
|
|
|
The elements of this array are
|
|
|
|
.I timeval
|
|
|
|
structures, which allow a precision of 1 microsecond for specifying timestamps.
|
2004-11-03 13:51:07 +00:00
|
|
|
The
|
|
|
|
.I timeval
|
|
|
|
structure is:
|
|
|
|
|
2007-12-19 06:16:04 +00:00
|
|
|
.in +4n
|
2004-11-03 13:51:07 +00:00
|
|
|
.nf
|
|
|
|
struct timeval {
|
2006-04-22 00:00:13 +00:00
|
|
|
long tv_sec; /* seconds */
|
|
|
|
long tv_usec; /* microseconds */
|
2004-11-03 13:51:07 +00:00
|
|
|
};
|
|
|
|
.fi
|
2007-12-19 06:16:04 +00:00
|
|
|
.in
|
2007-07-08 18:25:40 +00:00
|
|
|
.PP
|
|
|
|
.IR times [0]
|
|
|
|
specifies the new access time, and
|
|
|
|
.IR times [1]
|
|
|
|
specifies the new modification time.
|
|
|
|
If
|
|
|
|
.I times
|
|
|
|
is NULL, then analogously to
|
|
|
|
.BR utime (),
|
|
|
|
the access and modification times of the file are
|
|
|
|
set to the current time.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "RETURN VALUE"
|
2007-04-12 22:42:49 +00:00
|
|
|
On success, zero is returned.
|
|
|
|
On error, \-1 is returned, and
|
2004-11-03 13:51:07 +00:00
|
|
|
.I errno
|
|
|
|
is set appropriately.
|
|
|
|
.SH ERRORS
|
|
|
|
.TP
|
|
|
|
.B EACCES
|
|
|
|
Search permission is denied for one of the directories in
|
|
|
|
the path prefix of
|
|
|
|
.I path
|
|
|
|
(see also
|
2008-05-16 13:40:15 +00:00
|
|
|
.BR path_resolution (7)).
|
|
|
|
.TP
|
|
|
|
.B EACCES
|
|
|
|
.I times
|
|
|
|
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
|
|
|
|
or the
|
|
|
|
.B CAP_FOWNER
|
|
|
|
capability).
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B ENOENT
|
|
|
|
.I filename
|
|
|
|
does not exist.
|
|
|
|
.TP
|
|
|
|
.B EPERM
|
2008-05-16 13:40:15 +00:00
|
|
|
.I times
|
|
|
|
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
|
|
|
|
capability).
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B EROFS
|
|
|
|
.I path
|
|
|
|
resides on a read-only file system.
|
2007-05-18 16:30:46 +00:00
|
|
|
.SH "CONFORMING TO"
|
|
|
|
.BR utime ():
|
|
|
|
SVr4, POSIX.1-2001.
|
2008-08-06 10:45:14 +00:00
|
|
|
POSIX.1-2008 marks
|
|
|
|
.BR utime ()
|
|
|
|
as obsolete.
|
2007-05-18 16:30:46 +00:00
|
|
|
.br
|
|
|
|
.BR utimes ():
|
2008-03-20 06:09:01 +00:00
|
|
|
4.3BSD, POSIX.1-2001.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTES
|
2008-03-18 09:50:51 +00:00
|
|
|
Linux does not allow changing the timestamps on an immutable file,
|
|
|
|
or setting the timestamps to something other than the current time
|
2004-11-03 13:51:07 +00:00
|
|
|
on an append-only file.
|
|
|
|
|
|
|
|
In libc4 and libc5,
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR utimes ()
|
2004-11-03 13:51:07 +00:00
|
|
|
is just a wrapper for
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR utime ()
|
2004-11-03 13:51:07 +00:00
|
|
|
and hence does not allow a subsecond resolution.
|
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR chattr (1),
|
2006-05-02 00:03:35 +00:00
|
|
|
.BR futimesat (2),
|
2006-03-06 04:36:54 +00:00
|
|
|
.BR stat (2),
|
2008-07-16 08:30:35 +00:00
|
|
|
.BR utimensat (2),
|
clock_nanosleep.2, getpriority.2, kexec_load.2, nanosleep.2, nice.2, sched_setaffinity.2, timer_create.2, timer_delete.2, timer_settime.2, utime.2, btowc.3, futimes.3, log.3, pthread_attr_setguardsize.3, pthread_kill_other_threads_np.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setschedparam.3, pthread_setschedprio.3, pthread_tryjoin_np.3, strcoll.3, strcpy.3, string.3, strxfrm.3, networks.5, aio.7, sigevent.7, udplite.7: SEE ALSO: Place entries in correct order
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-11-01 05:34:26 +00:00
|
|
|
.BR futimens (3),
|
|
|
|
.BR futimes (3)
|