man.bsd.lv manual page server

Manual Page Search Parameters

UTIMES(2) System Calls Manual UTIMES(2)

utimesset file access and modification times

#include <sys/time.h>

int
utimes(const char *file, const struct timeval *times);

The () 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 modification 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.

Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.

Utimes() will fail if:

[]
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.
[]
File or times points outside the process's allocated address space.
[]
The pathname contains a character with the high-order bit set.
[]
An I/O error occurred while reading or writing the affected inode.
[]
Too many symbolic links were encountered in translating the pathname.
[]
A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters.
[]
The named file does not exist.
[]
A component of the path prefix is not a directory.
[]
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.
[]
The file system containing the file is mounted read-only.

stat(2)

The utimes function call appeared in 4.2BSD.

BSD 4 June 4, 1993 UTIMES(2)