utimensat(2) System Calls Manual utimensat(2) utimensat, futimens - (libc -lc) #include /* AT_* */ #include int utimensat(int dirfd, const char *path, const struct timespec times[_Nullable 2], int flags); int futimens(int fd, const struct timespec times[_Nullable 2]); glibc ( feature_test_macros(7)): utimensat(): glibc 2.10: _POSIX_C_SOURCE >= 200809L glibc 2.10: _ATFILE_SOURCE futimens(): glibc 2.10: _POSIX_C_SOURCE >= 200809L glibc 2.10: _GNU_SOURCE utimensat() futimens() . utime(2) utimes(2) . utimensat() path. futimens() fd. times: times[0] " " (atime) times[1] " " (mtime). times 1970-01-01 00:00:00 +0000 (UTC). timespec(3). . tv_nsec timespec UTIME_NOW . tv_nsec timespec UTIME_OMIT . tv_sec . times NULL . (ctime) . ( times NULL tv_nsec UTIME_NOW) : o o o . ( times NULL tv_nsec UTIME_NOW tv_nsec UTIME_OMIT) 2 3 . tv_nsec UTIME_OMIT . utimensat() path dirfd ( utimes(2) ). openat(2) . path dirfd AT_FDCWD path ( utimes(2)). path dirfd. flags OR : AT_EMPTY_PATH ( 5.8) path dirfd ( O_PATH open(2)). dirfd . dirfd AT_FDCWD . _GNU_SOURCE . AT_SYMLINK_NOFOLLOW path . utimensat() futimens() 0. -1 errno . EACCES times NULL tv_nsec UTIME_NOW (: CAP_FOWNER CAP_DAC_OVERRIDE). EBADF (futimens()) fd . EBADF (utimensat()) path dirfd AT_FDCWD . EFAULT times dirfd AT_FDCWD path NULL . EINVAL flags. EINVAL tv_nsec ( [0, 999,999,999] UTIME_NOW UTIME_OMIT) tv_sec. EINVAL path NULL dirfd AT_FDCWD flags AT_SYMLINK_NOFOLLOW. ELOOP (utimensat()) path. ENAMETOOLONG (utimensat()) path . ENOENT (utimensat()) path path . ENOTDIR (utimensat()) path dirfd AT_FDCWD path . EPERM ( times NULL tv_nsec UTIME_NOW tv_nsec UTIME_OMIT) : o (: CAP_FOWNER) o ( chattr(1)). EROFS . ESRCH (utimensat()) path. attributes(7). +------------+------------------------------------+--------------------+ || | | +------------+------------------------------------+--------------------+ |utimensat(),| | MT-Safe | |futimens() | | | +------------+------------------------------------+--------------------+ ABI C futimens() utimensat(). utimensat() : path NULL dirfd ( ). futimens(fd, times) : utimensat(fd, NULL, times, 0); glibc utimensat() NULL path: EINVAL . POSIX.1-2024. utimensat() 2.6.22 glibc 2.6. POSIX.1-2008. futimens() glibc 2.6. POSIX.1-2008. utimensat() futimesat(2). . ( utime(2) utimes(2) .) tv_nsec UTIME_OMIT utimensat() dirfd path . utimensat() futimens() 2.6.26. POSIX.1 . o POSIX.1 tv_nsec UTIME_NOW UTIME_OMIT tv_sec . tv_sec 0 ( EINVAL). o tv_nsec UTIME_NOW times NULL tv_nsec UTIME_NOW UTIME_OMIT times . : ) ) ) errno . o POSIX.1 times NULL times tv_nsec UTIME_NOW . futimens() . chattr(1), touch(1), futimesat(2), openat(2), stat(2), utimes(2), futimes(3), timespec(3), inode(7), path_resolution(7), symlink(7) 3 . . : . 6.18 29 2025 utimensat(2)