mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
Kernel: Use AK::Time for InodeMetadata timestamps instead of time_t
Before this change, we were truncating the nanosecond part of file timestamps in many different places.
This commit is contained in:
parent
f8290e1ad4
commit
10fa72d451
Notes:
sideshowbarker
2024-07-17 04:10:17 +09:00
Author: https://github.com/awesomekling
Commit: 10fa72d451
Pull-request: https://github.com/SerenityOS/serenity/pull/16147
Reviewed-by: https://github.com/Hendiadyoin1
23 changed files with 56 additions and 58 deletions
|
@ -281,7 +281,7 @@ ErrorOr<void> VirtualFileSystem::utime(Credentials const& credentials, StringVie
|
|||
if (custody->is_readonly())
|
||||
return EROFS;
|
||||
|
||||
TRY(inode.update_timestamps(atime, {}, mtime));
|
||||
TRY(inode.update_timestamps(Time::from_timespec({ atime, 0 }), {}, Time::from_timespec({ mtime, 0 })));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -296,9 +296,9 @@ ErrorOr<void> VirtualFileSystem::utimensat(Credentials const& credentials, Strin
|
|||
|
||||
// NOTE: A standard ext2 inode cannot store nanosecond timestamps.
|
||||
TRY(inode.update_timestamps(
|
||||
(atime.tv_nsec != UTIME_OMIT) ? atime.tv_sec : Optional<time_t> {},
|
||||
(atime.tv_nsec != UTIME_OMIT) ? Time::from_timespec(atime) : Optional<Time> {},
|
||||
{},
|
||||
(mtime.tv_nsec != UTIME_OMIT) ? mtime.tv_sec : Optional<time_t> {}));
|
||||
(mtime.tv_nsec != UTIME_OMIT) ? Time::from_timespec(mtime) : Optional<Time> {}));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ ErrorOr<NonnullLockRefPtr<OpenFileDescription>> VirtualFileSystem::open(Credenti
|
|||
|
||||
if (should_truncate_file) {
|
||||
TRY(inode.truncate(0));
|
||||
TRY(inode.update_timestamps({}, {}, kgettimeofday().to_truncated_seconds()));
|
||||
TRY(inode.update_timestamps({}, {}, kgettimeofday()));
|
||||
}
|
||||
auto description = TRY(OpenFileDescription::try_create(custody));
|
||||
description->set_rw_mode(options);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue