The Pedigree Project 0.1
fanotify-queue.h
1/* Copyright (c) 2026, Pedigree Developers. */
2#ifndef POSIX_FANOTIFY_QUEUE_H
3#define POSIX_FANOTIFY_QUEUE_H
4
5#include "pedigree/kernel/process/ConditionVariable.h"
6#include "pedigree/kernel/process/Mutex.h"
7#include "pedigree/kernel/process/Readiness.h"
8#include "pedigree/kernel/utilities/Pointers.h"
9
10#include "modules/system/vfs/FileHandle.h"
11
13 uint32_t mountId = 0;
14 FileHandle handle;
15 FileSystemId fsid;
16 uint64_t mask = 0;
17 uint32_t producer = 0;
18
19 size_t encodedSize() const;
20 void encode(void* buffer) const;
21 bool sameTarget(const FanotifyRecord&) const;
22};
23
25class FanotifyQueue final : public ReadinessSource {
26 public:
27 static constexpr size_t MaximumEvents = 256;
28 static constexpr size_t MaximumRecordSize = 24 + 12 + 8 + 128;
29 enum class Take { Ready, Empty, Closed, TooSmall, Interrupted };
30
32 ~FanotifyQueue() override;
33 bool valid() const;
34 void enqueue(const FanotifyRecord&);
35 Take take(FanotifyRecord&, size_t capacity, bool canBlock);
36 void close();
37 ReadyMask queryReady();
39 int queuedMetadataBytes();
40
41 private:
42 Mutex m_Lock;
43 ConditionVariable m_Readers;
45 size_t m_Head = 0;
46 size_t m_Count = 0;
47 bool m_OverflowQueued = false;
48 bool m_Closed = false;
49 ReadinessGenerations m_Generations;
50};
51#endif
ReadinessGenerations readinessGenerations() override
Definition Mutex.h:56