1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +00:00

Kernel+LibC: Implement futimens(3)

Implement futimes() in terms of utimensat(). Now, utimensat() strays
from POSIX compliance because it also accepts a combination of a file
descriptor of a regular file and an empty path. utimensat() then uses
this file descriptor instead of the path to update the last access
and/or modification time of a file. That being said, its prior behavior
remains intact.

With the new behavior of utimensat(), `path` must point to a valid
string; given a null pointer instead of an empty string, utimensat()
sets `errno` to `EFAULT` and returns a failure.
This commit is contained in:
Ariel Don 2022-05-03 14:52:08 -05:00 committed by Andreas Kling
parent 9a6bd85924
commit 8a854ba309
3 changed files with 36 additions and 12 deletions

View file

@ -109,4 +109,10 @@ int fstatat(int fd, char const* path, struct stat* statbuf, int flags)
{
return do_stat(fd, path, statbuf, !(flags & AT_SYMLINK_NOFOLLOW));
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html
int futimens(int fd, struct timespec const times[2])
{
return utimensat(fd, "", times, 0);
}
}