mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 17:47:44 +00:00
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.
This commit is contained in:
parent
f8e89306e0
commit
3d174e3ad2
4 changed files with 58 additions and 11 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue