UTIMES(2) BSD System Calls Manual UTIMES(2)NAME
utimes — set file access and modification times
SYNOPSIS
#include <sys/time.h>
int
utimes(const char *file, const struct timeval *times);
DESCRIPTION
The utimes() function sets the access and modification times of the named
file from the structures in the argument array times.
The first structure is the access time, and the second is the modifica‐
tion time.
If the times are specified (the times argument is non-NULL) the caller
must be the owner of the file or be the super-user.
If the times are not specified (the times argument is NULL) the caller
must be the owner of the file, have permission to write the file, or be
the super-user.
RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, a value
of -1 is returned and errno is set to indicate the error.
ERRORSUtimes() will fail if:
[EACCES] Search permission is denied for a component of the
path prefix; or the times argument is NULL and the
effective user ID of the process does not match the
owner of the file, and is not the super-user, and
write access is denied.
[EFAULT] File or times points outside the process's allocated
address space.
[EINVAL] The pathname contains a character with the high-order
bit set.
[EIO] An I/O error occurred while reading or writing the
affected inode.
[ELOOP] Too many symbolic links were encountered in translat‐
ing the pathname.
[ENAMETOOLONG] A component of a pathname exceeded 255 characters, or
an entire path name exceeded 1023 characters.
[ENOENT] The named file does not exist.
[ENOTDIR] A component of the path prefix is not a directory.
[EPERM] The times argument is not NULL and the calling
process's effective user ID does not match the owner
of the file and is not the super-user.
[EROFS] The file system containing the file is mounted read-
only.
SEE ALSOstat(2)HISTORY
The utimes function call appeared in 4.2BSD.
4th Berkeley Distribution June 4, 1993 4th Berkeley Distribution