1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +00:00

Kernel: Update atime/ctime/mtime timestamps atomically

Instead of having three separate APIs (one for each timestamp),
there's now only Inode::update_timestamps() and it takes 3x optional
timestamps. The non-empty timestamps are updated while holding the inode
mutex, and the outside world no longer has to look at intermediate
timestamp states.
This commit is contained in:
Andreas Kling 2022-08-22 13:34:22 +02:00
parent 35b2e9c663
commit 280694bb46
18 changed files with 34 additions and 109 deletions

View file

@ -106,17 +106,7 @@ void Inode::will_be_destroyed()
(void)flush_metadata();
}
ErrorOr<void> Inode::set_atime(time_t)
{
return ENOTIMPL;
}
ErrorOr<void> Inode::set_ctime(time_t)
{
return ENOTIMPL;
}
ErrorOr<void> Inode::set_mtime(time_t)
ErrorOr<void> Inode::update_timestamps([[maybe_unused]] Optional<time_t> atime, [[maybe_unused]] Optional<time_t> ctime, [[maybe_unused]] Optional<time_t> mtime)
{
return ENOTIMPL;
}
@ -236,8 +226,7 @@ void Inode::did_modify_contents()
// FIXME: What happens if this fails?
// ENOTIMPL would be a meaningless error to return here
auto time = kgettimeofday().to_truncated_seconds();
(void)set_mtime(time);
(void)set_ctime(time);
(void)update_timestamps({}, time, time);
m_watchers.for_each([&](auto& watcher) {
watcher->notify_inode_event({}, identifier(), InodeWatcherEvent::Type::ContentModified);