UTIME(3)
π 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
- Copyright (c) 1980, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms