Kernel/ProcFS: Tighten modified time value across the filesystem objects

It didn't make any sense to hardcode the modified time of all created
inodes with "mepoch", so we should query the procfs "backend" to get
the modified time value.
Since ProcFS is dynamically changed all the time, the modified time
equals to the querying time.
This could be changed if desired, by making the modified_time()
method virtual and overriding it in different procfs-backed objects :)
This commit is contained in:
Liav A 2021-06-23 15:59:34 +03:00 committed by Andreas Kling
parent d79d9e833e
commit 1f98d7d638
Notes: sideshowbarker 2024-07-18 11:16:20 +09:00
2 changed files with 4 additions and 3 deletions

View File

@ -145,7 +145,7 @@ InodeMetadata ProcFSInode::metadata() const
metadata.uid = m_associated_component->owner_user();
metadata.gid = m_associated_component->owner_group();
metadata.size = m_associated_component->size();
metadata.mtime = mepoch;
metadata.mtime = m_associated_component->modified_time();
return metadata;
}
@ -216,7 +216,7 @@ InodeMetadata ProcFSDirectoryInode::metadata() const
metadata.uid = m_associated_component->owner_user();
metadata.gid = m_associated_component->owner_group();
metadata.size = 0;
metadata.mtime = mepoch;
metadata.mtime = m_associated_component->modified_time();
return metadata;
}
KResult ProcFSDirectoryInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
@ -258,7 +258,7 @@ InodeMetadata ProcFSLinkInode::metadata() const
metadata.uid = m_associated_component->owner_user();
metadata.gid = m_associated_component->owner_group();
metadata.size = 0;
metadata.mtime = mepoch;
metadata.mtime = m_associated_component->modified_time();
return metadata;
}

View File

@ -69,6 +69,7 @@ public:
virtual mode_t required_mode() const { return 0444; }
virtual uid_t owner_user() const { return 0; }
virtual gid_t owner_group() const { return 0; }
time_t modified_time() const { return TimeManagement::now().to_timeval().tv_sec; }
virtual void prepare_for_deletion() { }
virtual KResult refresh_data(FileDescription&) const