/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace Kernel { class Inode; class InodeWatcher final : public File { public: static NonnullRefPtr create(Inode&); virtual ~InodeWatcher() override; virtual bool can_read(const FileDescription&, size_t) const override; virtual bool can_write(const FileDescription&, size_t) const override; virtual KResultOr read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override; virtual KResultOr write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override; virtual String absolute_path(const FileDescription&) const override; virtual const char* class_name() const override { return "InodeWatcher"; }; void notify_inode_event(Badge, InodeWatcherEvent::Type); void notify_child_added(Badge, const InodeIdentifier& child_id); void notify_child_removed(Badge, const InodeIdentifier& child_id); private: explicit InodeWatcher(Inode&); Lock m_lock; WeakPtr m_inode; CircularQueue m_queue; }; }