Kernel: Move UTIME_OMIT handling to the syscall from inode
This commit is contained in:
@@ -390,20 +390,18 @@ namespace Kernel
|
||||
{
|
||||
RWLockWRGuard _(m_lock);
|
||||
|
||||
const uint32_t old_times[2] {
|
||||
static_cast<uint32_t>(m_atime.tv_sec),
|
||||
static_cast<uint32_t>(m_mtime.tv_sec),
|
||||
const timespec old_times[2] {
|
||||
m_atime,
|
||||
m_mtime,
|
||||
};
|
||||
|
||||
if (times[0].tv_nsec != UTIME_OMIT)
|
||||
m_atime.tv_sec = times[0].tv_sec;
|
||||
if (times[1].tv_nsec != UTIME_OMIT)
|
||||
m_mtime.tv_sec = times[1].tv_sec;
|
||||
m_atime = times[0];
|
||||
m_mtime = times[1];
|
||||
|
||||
if (auto ret = sync_no_lock(); ret.is_error())
|
||||
{
|
||||
m_atime.tv_sec = old_times[0];
|
||||
m_mtime.tv_sec = old_times[1];
|
||||
m_atime = old_times[0];
|
||||
m_mtime = old_times[1];
|
||||
return ret.release_error();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,10 +119,8 @@ namespace Kernel
|
||||
BAN::ErrorOr<void> TmpInode::utimens_impl(const timespec times[2])
|
||||
{
|
||||
// FIXME: make this atomic
|
||||
if (times[0].tv_nsec != UTIME_OMIT)
|
||||
m_atime = times[0];
|
||||
if (times[1].tv_nsec != UTIME_OMIT)
|
||||
m_atime = times[1];
|
||||
m_atime = times[0];
|
||||
m_mtime = times[1];
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -1535,11 +1535,7 @@ namespace Kernel
|
||||
if (flag == AT_SYMLINK_NOFOLLOW)
|
||||
flag = O_NOFOLLOW;
|
||||
|
||||
const uint64_t current_ns = SystemTimer::get().ns_since_boot();
|
||||
const timespec current_ts = {
|
||||
.tv_sec = static_cast<time_t>(current_ns / 1'000'000),
|
||||
.tv_nsec = static_cast<long>(current_ns % 1'000'000),
|
||||
};
|
||||
const timespec current_ts = SystemTimer::get().real_time();
|
||||
|
||||
timespec times[2];
|
||||
if (user_times == nullptr)
|
||||
@@ -1560,7 +1556,6 @@ namespace Kernel
|
||||
else if (times[i].tv_nsec < 0 || times[i].tv_nsec >= 1'000'000'000)
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (times[0].tv_nsec == UTIME_OMIT && times[1].tv_nsec == UTIME_OMIT)
|
||||
@@ -1581,6 +1576,11 @@ namespace Kernel
|
||||
}
|
||||
}
|
||||
|
||||
if (times[0].tv_nsec == UTIME_OMIT)
|
||||
times[0] = inode->atime();
|
||||
if (times[1].tv_nsec == UTIME_OMIT)
|
||||
times[1] = inode->mtime();
|
||||
|
||||
TRY(inode->utimens(times));
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user