mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
Kernel: Make kgettimeofday use AK::Time
This commit is contained in:
parent
05d5e3fad9
commit
336303bda4
Notes:
sideshowbarker
2024-07-18 21:47:33 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/336303bda47 Pull-request: https://github.com/SerenityOS/serenity/pull/5323 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/bgianfo
@ -572,7 +572,7 @@ void Ext2FS::free_inode(Ext2FSInode& inode)
|
||||
|
||||
// NOTE: After this point, the inode metadata is wiped.
|
||||
memset(&inode.m_raw_inode, 0, sizeof(ext2_inode));
|
||||
inode.m_raw_inode.i_dtime = kgettimeofday().tv_sec;
|
||||
inode.m_raw_inode.i_dtime = kgettimeofday().to_truncated_seconds();
|
||||
write_ext2_inode(inode.index(), inode.m_raw_inode);
|
||||
|
||||
// Mark the inode as free.
|
||||
@ -1429,14 +1429,14 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode,
|
||||
return ENOENT;
|
||||
|
||||
ext2_inode e2inode {};
|
||||
auto now = kgettimeofday();
|
||||
auto now = kgettimeofday().to_truncated_seconds();
|
||||
e2inode.i_mode = mode;
|
||||
e2inode.i_uid = uid;
|
||||
e2inode.i_gid = gid;
|
||||
e2inode.i_size = 0;
|
||||
e2inode.i_atime = now.tv_sec;
|
||||
e2inode.i_ctime = now.tv_sec;
|
||||
e2inode.i_mtime = now.tv_sec;
|
||||
e2inode.i_atime = now;
|
||||
e2inode.i_ctime = now;
|
||||
e2inode.i_mtime = now;
|
||||
e2inode.i_dtime = 0;
|
||||
e2inode.i_flags = 0;
|
||||
|
||||
|
@ -68,7 +68,7 @@ KResultOr<size_t> InodeFile::write(FileDescription& description, size_t offset,
|
||||
|
||||
ssize_t nwritten = m_inode->write_bytes(offset, count, data, &description);
|
||||
if (nwritten > 0) {
|
||||
m_inode->set_mtime(kgettimeofday().tv_sec);
|
||||
m_inode->set_mtime(kgettimeofday().to_truncated_seconds());
|
||||
Thread::current()->did_file_write(nwritten);
|
||||
evaluate_block_conditions();
|
||||
}
|
||||
@ -132,7 +132,7 @@ KResult InodeFile::truncate(u64 size)
|
||||
auto truncate_result = m_inode->truncate(size);
|
||||
if (truncate_result.is_error())
|
||||
return truncate_result;
|
||||
int mtime_result = m_inode->set_mtime(kgettimeofday().tv_sec);
|
||||
int mtime_result = m_inode->set_mtime(kgettimeofday().to_truncated_seconds());
|
||||
if (mtime_result < 0)
|
||||
return KResult((ErrnoCode)-mtime_result);
|
||||
return KSuccess;
|
||||
|
@ -114,10 +114,10 @@ NonnullRefPtr<TmpFSInode> TmpFSInode::create(TmpFS& fs, InodeMetadata metadata,
|
||||
NonnullRefPtr<TmpFSInode> TmpFSInode::create_root(TmpFS& fs)
|
||||
{
|
||||
InodeMetadata metadata;
|
||||
auto now = kgettimeofday();
|
||||
metadata.atime = now.tv_sec;
|
||||
metadata.ctime = now.tv_sec;
|
||||
metadata.mtime = now.tv_sec;
|
||||
auto now = kgettimeofday().to_truncated_seconds();
|
||||
metadata.atime = now;
|
||||
metadata.ctime = now;
|
||||
metadata.mtime = now;
|
||||
metadata.mode = S_IFDIR | S_ISVTX | 0777;
|
||||
return create(fs, metadata, { fs.fsid(), 1 });
|
||||
}
|
||||
@ -280,15 +280,15 @@ KResultOr<NonnullRefPtr<Inode>> TmpFSInode::create_child(const String& name, mod
|
||||
if (dev != 0)
|
||||
return ENOTSUP;
|
||||
|
||||
struct timeval now = kgettimeofday();
|
||||
time_t now = kgettimeofday().to_truncated_seconds();
|
||||
|
||||
InodeMetadata metadata;
|
||||
metadata.mode = mode;
|
||||
metadata.uid = uid;
|
||||
metadata.gid = gid;
|
||||
metadata.atime = now.tv_sec;
|
||||
metadata.ctime = now.tv_sec;
|
||||
metadata.mtime = now.tv_sec;
|
||||
metadata.atime = now;
|
||||
metadata.ctime = now;
|
||||
metadata.mtime = now;
|
||||
|
||||
auto child = TmpFSInode::create(fs(), metadata, identifier());
|
||||
auto result = add_child(child, name, mode);
|
||||
|
@ -346,7 +346,7 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::open(StringView path, int options
|
||||
KResult result = inode.truncate(0);
|
||||
if (result.is_error())
|
||||
return result;
|
||||
inode.set_mtime(kgettimeofday().tv_sec);
|
||||
inode.set_mtime(kgettimeofday().to_truncated_seconds());
|
||||
}
|
||||
auto description = FileDescription::create(custody);
|
||||
if (!description.is_error()) {
|
||||
|
@ -193,7 +193,8 @@ void NetworkAdapter::did_receive(ReadonlyBytes payload)
|
||||
}
|
||||
}
|
||||
|
||||
m_packet_queue.append({ buffer.value(), kgettimeofday() });
|
||||
// FIXME: Should use AK::Time internally
|
||||
m_packet_queue.append({ buffer.value(), kgettimeofday().to_timeval() });
|
||||
|
||||
if (on_receive)
|
||||
on_receive();
|
||||
|
@ -238,7 +238,8 @@ void TCPSocket::send_outgoing_packets()
|
||||
auto routing_decision = route_to(peer_address(), local_address(), bound_interface());
|
||||
VERIFY(!routing_decision.is_zero());
|
||||
|
||||
auto now = kgettimeofday();
|
||||
// FIXME: Should use AK::Time internally
|
||||
auto now = kgettimeofday().to_timeval();
|
||||
|
||||
LOCKER(m_not_acked_lock, Lock::Mode::Shared);
|
||||
for (auto& packet : m_not_acked) {
|
||||
|
@ -381,9 +381,9 @@ int Process::alloc_fd(int first_candidate_fd)
|
||||
return -EMFILE;
|
||||
}
|
||||
|
||||
timeval kgettimeofday()
|
||||
Time kgettimeofday()
|
||||
{
|
||||
return TimeManagement::now().to_timeval();
|
||||
return TimeManagement::now();
|
||||
}
|
||||
|
||||
siginfo_t Process::wait_info()
|
||||
|
@ -54,8 +54,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
// FIXME: Should use AK::Time internally
|
||||
timeval kgettimeofday();
|
||||
Time kgettimeofday();
|
||||
|
||||
#define ENUMERATE_PLEDGE_PROMISES \
|
||||
__ENUMERATE_PLEDGE_PROMISE(stdio) \
|
||||
|
@ -135,7 +135,7 @@ KResultOr<int> Process::sys$adjtime(Userspace<const timeval*> user_delta, Usersp
|
||||
KResultOr<int> Process::sys$gettimeofday(Userspace<timeval*> user_tv)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
auto tv = kgettimeofday();
|
||||
auto tv = kgettimeofday().to_timeval();
|
||||
if (!copy_to_user(user_tv, &tv))
|
||||
return EFAULT;
|
||||
return 0;
|
||||
|
@ -41,8 +41,9 @@ KResultOr<int> Process::sys$utime(Userspace<const char*> user_path, size_t path_
|
||||
if (!copy_from_user(&buf, user_buf))
|
||||
return EFAULT;
|
||||
} else {
|
||||
auto now = kgettimeofday();
|
||||
buf = { now.tv_sec, now.tv_sec };
|
||||
auto now = kgettimeofday().to_truncated_seconds();
|
||||
// Not a bug!
|
||||
buf = { now, now };
|
||||
}
|
||||
return VFS::the().utime(path.value(), current_directory(), buf.actime, buf.modtime);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ void SlavePTY::on_master_write(const UserOrKernelBuffer& buffer, ssize_t size)
|
||||
|
||||
ssize_t SlavePTY::on_tty_write(const UserOrKernelBuffer& data, ssize_t size)
|
||||
{
|
||||
m_time_of_last_write = kgettimeofday().tv_sec;
|
||||
m_time_of_last_write = kgettimeofday().to_truncated_seconds();
|
||||
return m_master->on_slave_write(data, size);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user