summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorSeekingBlues <seekingblues@gmail.com>2021-10-16 17:35:59 -0400
committerAndreas Kling <kling@serenityos.org>2021-10-17 14:46:59 +0200
commit3d174e3ad204c4d32459ceb8717b855435a32311 (patch)
tree95d6505591f18c579b30eede2d3670b83807943f /Kernel/FileSystem
parentf8e89306e06e7d65c95f3d47193e4b174b4326af (diff)
downloadserenity-3d174e3ad204c4d32459ceb8717b855435a32311.zip
Kernel/ProcFS: Provide a way to write to ProcFS inodes
ProcFSGlobalInode now calls `write_bytes()`, `truncate()` and `set_mtime()` on its associated component. This allows us to write 0 or 1 to a ProcFSSystemBoolean component to toggle a boolean value.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/ProcFS.cpp15
-rw-r--r--Kernel/FileSystem/ProcFS.h3
2 files changed, 12 insertions, 6 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index e6a034e8a6..fd88f671a4 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -99,11 +99,6 @@ KResult ProcFSInode::chown(UserID, GroupID)
return EPERM;
}
-KResult ProcFSInode::truncate(u64)
-{
- return EPERM;
-}
-
KResultOr<NonnullRefPtr<ProcFSGlobalInode>> ProcFSGlobalInode::try_create(const ProcFS& fs, const ProcFSExposedComponent& component)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSGlobalInode(fs, component));
@@ -151,6 +146,16 @@ KResultOr<NonnullRefPtr<Inode>> ProcFSGlobalInode::lookup(StringView)
VERIFY_NOT_REACHED();
}
+KResult ProcFSGlobalInode::truncate(u64 size)
+{
+ return m_associated_component->truncate(size);
+}
+
+KResult ProcFSGlobalInode::set_mtime(time_t time)
+{
+ return m_associated_component->set_mtime(time);
+}
+
InodeMetadata ProcFSGlobalInode::metadata() const
{
MutexLocker locker(m_inode_lock);
diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h
index 1be5b2f1c6..966cfd55a4 100644
--- a/Kernel/FileSystem/ProcFS.h
+++ b/Kernel/FileSystem/ProcFS.h
@@ -62,7 +62,6 @@ protected:
virtual KResult remove_child(const StringView& name) override final;
virtual KResult chmod(mode_t) override final;
virtual KResult chown(UserID, GroupID) override final;
- virtual KResult truncate(u64) override final;
};
class ProcFSGlobalInode : public ProcFSInode {
@@ -84,6 +83,8 @@ protected:
virtual InodeMetadata metadata() const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView) override;
+ virtual KResult truncate(u64) override final;
+ virtual KResult set_mtime(time_t) override final;
NonnullRefPtr<ProcFSExposedComponent> m_associated_component;
};