futimesat(2)

πŸ’– futimesat(2) πŸ’– β€” the System Calls Manual, but make it a group chat

okay so bestie, gather round, because we're talking about futimesat(2) from the System Calls Manual and honestly? she's a legacy queen. we stan an icon but we also gently suggest you move on. let's get into it πŸ’…

✨ NAME ✨

futimesat β€” change timestamps of a file relative to a directory file descriptor

like, you're touching a file's timestamps, but you're doing it relative to a directory file descriptor. very "it's not about the destination, it's about the dirfd" of it all πŸ¦‹

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)


πŸŽ€ SYNOPSIS πŸŽ€

#include <fcntl.h>            /* Definition of AT_* constants */
#include <sys/time.h>

[[deprecated]] int futimesat(int dirfd, const char *path,
                             const struct timeval times[2]);

Feature Test Macro Requirements for glibc (peep feature_test_macros(7) if you're nosy πŸ‘€):

futimesat():
    _GNU_SOURCE
bestie. see that [[deprecated]] sitting right there in the signature? that's not a vibe, that's a warning label. the compiler is side-eyeing you fr fr πŸ’€

🌸 DESCRIPTION 🌸

okay so first thing first, and I need you to hear me on this one:

This system call is obsolete. Use utimensat(2) instead.

periodt. that's the whole assignment. she's retired, she's living her best life in the man-pages archives, and there's a newer, shinier syscall doing her job.

but if you're here for the lore (respect, honestly), the futimesat() system call operates in exactly the same way as utimes(2), except for the differences described in this manual page. so like… same energy, tiny plot twists ✨

the twists:

  • If path is relative, then it is interpreted relative to the directory referred to by the file descriptor dirfd β€” not relative to the current working directory of the calling process, which is what utimes(2) does for a relative pathname. she does things her way, with her dirfd πŸ‘‘
  • If path is relative and dirfd is the special value AT_FDCWD, then path is interpreted relative to the current working directory of the calling process (just like utimes(2) does it β€” so, the classic behaviour, no notes).
  • If path is absolute, then dirfd is ignored. like, fully ghosted. (If you're sitting there like "why does dirfd even exist then??", go read openat(2) for an explanation of why the dirfd argument is useful. she explains everything, she's so good to us 🫢)

πŸ¦‹ RETURN VALUE πŸ¦‹

  • On success, futimesat() returns a 0. slay.
  • On error, -1 is returned and errno is set to indicate the error. not slay, but informative πŸ’€

πŸ’œ ERRORS πŸ’œ

The same errors that occur for utimes(2) can also occur for futimesat(). so if you already know utimes(2)'s drama, you know hers β€” it's a shared trauma kind of situation 😭

The following additional errors can occur for futimesat():

  • EBADF β€” path is relative but dirfd is neither AT_FDCWD nor a valid file descriptor. girl, that's not a directory fd, that's ✨nothing✨
  • ENOTDIR β€” path is relative and dirfd is a file descriptor referring to a file other than a directory. the audacity of a regular file trying to act like a directory smh, we don't do that here πŸ™ˆ

🌈 VERSIONS 🌈

🧚 glibc 🧚

If path is NULL, then the glibc futimesat() wrapper function updates the times for the file referred to by dirfd.

yes bestie, NULL path is a real thing here. that's the little glibc-exclusive party trick πŸŽ€

⭐ STANDARDS ⭐

None.

not a POSIX girlie, not an ISO girlie, just out here existing on vibes alone. literally no standard claims her. it's giving independent πŸ¦‹

πŸ‘‘ HISTORY πŸ‘‘

Linux 2.6.16, glibc 2.4.

she's been around. she was implemented from a specification that was proposed for POSIX.1, but that specification was replaced by the one for utimensat(2). so she got drafted, then the draft got replaced, and now she's on the deprecated list. character development, honestly 😭

A similar system call exists on Solaris. (hi Solaris, we see you πŸ’–)

πŸ’€ NOTES πŸ’€

...it's giving empty. bestie there is genuinely nothing in this section. no cap. we're just here, standing in the notes section, vibing in silence πŸ•³οΈβœ¨

πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie! πŸŽ€ one last thing before you go: this little masterpiece came from Linux man-pages 6.20, dated 2026-02-08 β€” so go thank the man-pages girlies for their service, and go use utimensat(2) instead of this one, fr fr. mwah πŸ’…πŸ’–

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms