The Pedigree Project
0.1
src
modules
subsys
posix
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
12
struct
FanotifyRecord
{
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
25
class
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
31
FanotifyQueue
();
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();
38
ReadinessGenerations
readinessGenerations
()
override
;
39
int
queuedMetadataBytes();
40
41
private
:
42
Mutex
m_Lock;
43
ConditionVariable
m_Readers;
44
UniqueArray<FanotifyRecord>
m_Records;
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
ConditionVariable
Definition
ConditionVariable.h:35
FanotifyQueue
Definition
fanotify-queue.h:25
FanotifyQueue::readinessGenerations
ReadinessGenerations readinessGenerations() override
Definition
fanotify-queue.cc:152
Mutex
Definition
Mutex.h:56
ReadinessSource
Definition
Readiness.h:86
UniqueArray
Definition
Pointers.h:131
FanotifyRecord
Definition
fanotify-queue.h:12
FileHandle
Definition
FileHandle.h:11
FileSystemId
Definition
FileHandle.h:17
ReadinessGenerations
Definition
Readiness.h:31
Generated on Tue Sep 22 2026 06:05:42 for The Pedigree Project by
1.9.8