Kernel: Add "child added" and "child removed" InodeWatcher events

The child name is not yet accessible to userspace, but will be in a
future patch.
This commit is contained in:
Andreas Kling 2020-07-04 13:36:55 +02:00
parent ea17d2d3da
commit 0d577ab781
Notes: sideshowbarker 2024-07-19 05:11:34 +09:00
6 changed files with 47 additions and 3 deletions

View file

@ -59,6 +59,7 @@ bool InodeWatcher::can_write(const FileDescription&, size_t) const
ssize_t InodeWatcher::read(FileDescription&, size_t, u8* buffer, ssize_t buffer_size)
{
LOCKER(m_lock);
ASSERT(!m_queue.is_empty() || !m_inode);
if (!m_inode)
@ -85,7 +86,20 @@ String InodeWatcher::absolute_path(const FileDescription&) const
void InodeWatcher::notify_inode_event(Badge<Inode>, Event::Type event_type)
{
m_queue.enqueue({ event_type });
LOCKER(m_lock);
m_queue.enqueue({ event_type, {} });
}
void InodeWatcher::notify_child_added(Badge<Inode>, const String& child_name)
{
LOCKER(m_lock);
m_queue.enqueue({ Event::Type::ChildAdded, child_name });
}
void InodeWatcher::notify_child_removed(Badge<Inode>, const String& child_name)
{
LOCKER(m_lock);
m_queue.enqueue({ Event::Type::ChildRemoved, child_name });
}
}