mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Update tv_nsec field when using utimensat() with UTIME_NOW
We were only updating the tv_sec field and leaving UTIME_NOW in tv_nsec.
This commit is contained in:
parent
376b3c95f7
commit
5556b27e38
Notes:
sideshowbarker
2024-07-17 11:33:34 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5556b27e38 Pull-request: https://github.com/SerenityOS/serenity/pull/16147 Reviewed-by: https://github.com/Hendiadyoin1
1 changed files with 5 additions and 7 deletions
|
@ -18,7 +18,7 @@ ErrorOr<FlatPtr> Process::sys$utimensat(Userspace<Syscall::SC_utimensat_params c
|
||||||
TRY(require_promise(Pledge::fattr));
|
TRY(require_promise(Pledge::fattr));
|
||||||
|
|
||||||
auto params = TRY(copy_typed_from_user(user_params));
|
auto params = TRY(copy_typed_from_user(user_params));
|
||||||
auto now = kgettimeofday().to_truncated_seconds();
|
auto now = kgettimeofday().to_timespec();
|
||||||
|
|
||||||
int dirfd = params.dirfd;
|
int dirfd = params.dirfd;
|
||||||
int follow_symlink = params.flag & AT_SYMLINK_NOFOLLOW ? O_NOFOLLOW_NOERROR : 0;
|
int follow_symlink = params.flag & AT_SYMLINK_NOFOLLOW ? O_NOFOLLOW_NOERROR : 0;
|
||||||
|
@ -27,16 +27,14 @@ ErrorOr<FlatPtr> Process::sys$utimensat(Userspace<Syscall::SC_utimensat_params c
|
||||||
if (params.times) {
|
if (params.times) {
|
||||||
TRY(copy_from_user(times, params.times, sizeof(times)));
|
TRY(copy_from_user(times, params.times, sizeof(times)));
|
||||||
if (times[0].tv_nsec == UTIME_NOW)
|
if (times[0].tv_nsec == UTIME_NOW)
|
||||||
times[0].tv_sec = now;
|
times[0] = now;
|
||||||
if (times[1].tv_nsec == UTIME_NOW)
|
if (times[1].tv_nsec == UTIME_NOW)
|
||||||
times[1].tv_sec = now;
|
times[1] = now;
|
||||||
} else {
|
} else {
|
||||||
// According to POSIX, both access and modification times are set to
|
// According to POSIX, both access and modification times are set to
|
||||||
// the current time given a nullptr.
|
// the current time given a nullptr.
|
||||||
times[0].tv_sec = now;
|
times[0] = now;
|
||||||
times[0].tv_nsec = UTIME_NOW;
|
times[1] = now;
|
||||||
times[1].tv_sec = now;
|
|
||||||
times[1].tv_nsec = UTIME_NOW;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OwnPtr<KString> path;
|
OwnPtr<KString> path;
|
||||||
|
|
Loading…
Reference in a new issue