UTIME(3V)

NAME
utime - set file times

SYNOPSIS

#include <utime.h>

int utime(path, times)
char *path;
struct utimbuf *times;

DESCRIPTION

utime() sets the access and modification times of the file named by path.

If times is NULL, the access and modification times are set to the current time. The effective user ID (UID) of the calling process must match the owner of the file or the process must have write permission for the file to use utime() in this manner.

If times is not NULL, it is assumed to point to a utimbuf structure, defined in <utime.h> as:

    struct  utimbuf {
            time_t  actime;	/* set the access time */
            time_t  modtime;	/* set the modification time */
    };

The access time is set to the value of the first member, and the modification time is set to the value of the second member. The times contained in this structure are measured in seconds since 00:00:00 GMT Jan 1, 1970. Only the owner of the file or the super-user may use utime() in this manner.

Upon successful completion, utime() marks for update the st_ctime field of the file.

RETURN VALUES

utime() returns:

0   on success.

-1  on failure and sets errno to indicate the error.

ERRORS

EACCES
    Search permission is denied for a component of the path prefix of path.

EACCES
    The effective user ID is not super-user and not the owner of the file, write permission is denied for the file, and times is NULL.

EFAULT
    path or times points outside the process's allocated address space.

EIO An I/O error occurred while reading from or writing to the file system.

ELOOP
    Too many symbolic links were encountered in translating path.

ENAMETOOLONG
    The length of path exceeds {PATH_MAX}.

    A pathname component is longer than {NAME_MAX} while {_POSIX_NO_TRUNC} is in effect (see pathconf(2V)).

ENOENT
    The file referred to by path does not exist.

ENOTDIR
    A component of the path prefix of path is not a directory.

EPERM
    The effective user ID of the process is not super-user and not the owner of the file, and times is not NULL.

EROFS
    The file system containing the file is mounted read-only.

SYSTEM V ERRORS

In addition to the above, the following may also occur:

ENOENT
    path points to an empty string.

SEE ALSO
pathconf(2V), stat(2V), utimes(2)