UTIME(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… UTIME(3) β€” bestie edition ✨

okay so this is the utime page from the Library Functions Manual, and it lives in the Standard C Library (libc, -lc) 🫢 she's a classic, she's been around forever, and she still does her little job β€” setting file times β€” even if the cool kids have moved on. let's get into it 🌸


✨ NAME ✨

utime β€” set file times πŸ’– that's it, that's the whole vibe. she sets the times on a file. iconic behaviour, no notes.


πŸŽ€ LIBRARY πŸŽ€

Standard C Library (libc, -lc) β€” she's right there in libc, always has been, no extra linking drama queens needed πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <utime.h>

int
utime(const char *file, const struct utimbuf *timep);

so you pull in <utime.h>, and then you call her with a file and a pointer to a struct utimbuf named timep. she returns an int, like a good little function should ✨


🌸 DESCRIPTION 🌸

heads up bestie: this interface is obsoleted by utimensat(2) 😭 and the reason is genuinely important β€” it's not accurate to fractions of a second. so if you need sub-second precision, this is NOT the girl. she rounds, she vibes, she moves on.

so what does utime() actually do? she sets the access and modification times of the file you named β€” and she gets those values from the actime and modtime fields of the struct utimbuf that timep points at. cute, simple, very demure 🌷

now here's the permission tea, and it's giving main character energy because the rules change depending on timep:

  • if the times ARE specified (so timep is non-NULL) β€” the caller must be the owner of the file or be the super-user. that's it, that's the whole list πŸ‘‘
  • if the times are NOT specified (so timep is NULL) β€” the caller must be the owner of the file, have permission to write the file, or be the super-user. three ways in, pick your fighter 🫢

πŸ’€ ERRORS πŸ’€

utime() may fail and set errno for any of the errors specified for the library function utimes(2) 😭 so yeah, when she's mad, go read that page β€” she's not going to spell it out here, she's pointing you at her cousin.


πŸ”₯ SEE ALSO πŸ”₯

  • stat(2)
  • utimensat(2) β€” the one who replaced her, sub-second accurate, the upgrade ✨
  • utimes(2) β€” also owns the error list, iykyk

⭐ STANDARDS ⭐

utime() conforms to IEEE Std 1003.1-1988 (β€œPOSIX.1”) πŸŽ€ certified vintage, she's got receipts.


🌈 HISTORY 🌈

a utime() function appeared in Version 7 AT&T UNIX 🀯 like, actual ancient lore. she's a founding mother, respect the elders πŸ’œ


and that's the whole page bestie, every flag and field and caveat intact, no cap πŸ§šπŸ’–

Debian 🌸 June 9, 2016 🌸 UTIME(3) β€” mwah, love u, go set some timestamps responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms