mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 21:25:07 +00:00
Add mechanism to expose kernel variables to userspace via ProcFS.
Only booleans are supported at first. More types can be added easily. Use this to add /proc/sys/wm_flash_flush which when enabled flashes pending screen flush rects in yellow before they happen.
This commit is contained in:
parent
9454c5dd52
commit
f7cc454162
8 changed files with 121 additions and 29 deletions
|
@ -69,7 +69,7 @@ RetainPtr<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& co
|
|||
return file;
|
||||
}
|
||||
|
||||
RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer()>&& generator, Unix::mode_t mode)
|
||||
RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& generator, Unix::mode_t mode)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
file->m_generator = move(generator);
|
||||
|
@ -82,6 +82,20 @@ RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<B
|
|||
return file;
|
||||
}
|
||||
|
||||
RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer(SynthFSInode&)>&& read_callback, Function<ssize_t(SynthFSInode&, const ByteBuffer&)>&& write_callback, Unix::mode_t mode)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generate_inode_index()));
|
||||
file->m_generator = move(read_callback);
|
||||
file->m_write_callback = move(write_callback);
|
||||
file->m_name = move(name);
|
||||
file->m_metadata.size = 0;
|
||||
file->m_metadata.uid = 0;
|
||||
file->m_metadata.gid = 0;
|
||||
file->m_metadata.mode = mode;
|
||||
file->m_metadata.mtime = mepoch;
|
||||
return file;
|
||||
}
|
||||
|
||||
InodeIdentifier SynthFS::add_file(RetainPtr<SynthFSInode>&& file, InodeIndex parent)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
|
@ -197,10 +211,10 @@ ssize_t SynthFSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer,
|
|||
ByteBuffer generatedData;
|
||||
if (m_generator) {
|
||||
if (!descriptor) {
|
||||
generatedData = m_generator();
|
||||
generatedData = m_generator(*this);
|
||||
} else {
|
||||
if (!descriptor->generator_cache())
|
||||
descriptor->generator_cache() = m_generator();
|
||||
descriptor->generator_cache() = m_generator(*this);
|
||||
generatedData = descriptor->generator_cache();
|
||||
}
|
||||
}
|
||||
|
@ -259,10 +273,11 @@ void SynthFSInode::flush_metadata()
|
|||
{
|
||||
}
|
||||
|
||||
bool SynthFSInode::write(const ByteBuffer&)
|
||||
bool SynthFSInode::write(const ByteBuffer& data)
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
return false;
|
||||
if (!m_write_callback)
|
||||
return 0; // FIXME: -EPERM?
|
||||
return m_write_callback(*this, data);
|
||||
}
|
||||
|
||||
bool SynthFSInode::add_child(InodeIdentifier child_id, const String& name, byte file_type, int& error)
|
||||
|
@ -274,3 +289,7 @@ bool SynthFSInode::add_child(InodeIdentifier child_id, const String& name, byte
|
|||
ASSERT_NOT_REACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
SynthFSInodeCustomData::~SynthFSInodeCustomData()
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue