xref: /reactos/ntoskrnl/include/internal/fsrtl.h (revision 34593d93)
1 /*
2  * PROJECT:         ReactOS Kernel
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * FILE:            ntoskrnl/include/internal/fsrtl.h
5  * PURPOSE:         Internal header for the File System Runtime Library
6  * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 //
10 // Define this if you want debugging support
11 //
12 #define _FSRTL_DEBUG_                                   0x00
13 
14 //
15 // These define the Debug Masks Supported
16 //
17 #define FSRTL_FASTIO_DEBUG                              0x01
18 #define FSRTL_OPLOCK_DEBUG                              0x02
19 #define FSRTL_TUNNEL_DEBUG                              0x04
20 #define FSRTL_MCB_DEBUG                                 0x08
21 #define FSRTL_NAME_DEBUG                                0x10
22 #define FSRTL_NOTIFY_DEBUG                              0x20
23 #define FSRTL_FILELOCK_DEBUG                            0x40
24 #define FSRTL_UNC_DEBUG                                 0x80
25 #define FSRTL_FILTER_DEBUG                              0x100
26 #define FSRTL_CONTEXT_DEBUG                             0x200
27 
28 //
29 // Debug/Tracing support
30 //
31 #if _FSRTL_DEBUG_
32 #ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
33 #define FSTRACE DbgPrintEx
34 #else
35 #define FSTRACE(x, ...)                                 \
36     if (x & FsRtlpTraceLevel) DbgPrint(__VA_ARGS__)
37 #endif
38 #else
39 #define FSTRACE(x, ...) DPRINT(__VA_ARGS__)
40 #endif
41 
42 //
43 // Number of internal ERESOURCE structures allocated for callers to request
44 //
45 #define FSRTL_MAX_RESOURCES 16
46 
47 //
48 // Number of maximum pair count per MCB
49 //
50 #define MAXIMUM_PAIR_COUNT  15
51 
52 //
53 // Notifications flags
54 //
55 #define WATCH_TREE         0x01
56 #define NOTIFY_IMMEDIATELY 0x02
57 #define CLEANUP_IN_PROCESS 0x04
58 #define NOTIFY_LATER       0x08
59 #define WATCH_ROOT         0x10
60 #define DELETE_IN_PROCESS  0x20
61 
62 //
63 // Internal structure for NOTIFY_SYNC
64 //
65 typedef struct _REAL_NOTIFY_SYNC
66 {
67     FAST_MUTEX FastMutex;
68     ULONG_PTR OwningThread;
69     ULONG OwnerCount;
70 } REAL_NOTIFY_SYNC, * PREAL_NOTIFY_SYNC;
71 
72 //
73 // Internal structure for notifications
74 //
75 typedef struct _NOTIFY_CHANGE
76 {
77     PREAL_NOTIFY_SYNC NotifySync;
78     PVOID FsContext;
79     PVOID StreamID;
80     PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback;
81     PSECURITY_SUBJECT_CONTEXT SubjectContext;
82     PSTRING FullDirectoryName;
83     LIST_ENTRY NotifyList;
84     LIST_ENTRY NotifyIrps;
85     PFILTER_REPORT_CHANGE FilterCallback;
86     USHORT Flags;
87     UCHAR CharacterSize;
88     ULONG CompletionFilter;
89     PVOID AllocatedBuffer;
90     PVOID Buffer;
91     ULONG BufferLength;
92     ULONG ThisBufferLength;
93     ULONG DataLength;
94     ULONG LastEntry;
95     ULONG ReferenceCount;
96     PEPROCESS OwningProcess;
97 } NOTIFY_CHANGE, *PNOTIFY_CHANGE;
98 
99 //
100 // Internal structure for MCB Mapping pointer
101 //
102 typedef struct _INT_MAPPING
103 {
104     VBN Vbn;
105     LBN Lbn;
106 } INT_MAPPING, *PINT_MAPPING;
107 
108 //
109 // Initialization Routines
110 //
111 CODE_SEG("INIT")
112 VOID
113 NTAPI
114 FsRtlInitializeLargeMcbs(
115     VOID
116 );
117 
118 CODE_SEG("INIT")
119 VOID
120 NTAPI
121 FsRtlInitializeTunnels(
122     VOID
123 );
124 
125 //
126 // File contexts Routines
127 //
128 VOID
129 NTAPI
130 FsRtlPTeardownPerFileObjectContexts(
131     IN PFILE_OBJECT FileObject
132 );
133 
134 CODE_SEG("INIT")
135 BOOLEAN
136 NTAPI
137 FsRtlInitSystem(
138     VOID
139 );
140 
141 //
142 // Global data inside the File System Runtime Library
143 //
144 extern PERESOURCE FsRtlPagingIoResources;
145 extern PAGED_LOOKASIDE_LIST FsRtlFileLockLookasideList;
146 
147 //
148 // File locking routine
149 //
150 NTSTATUS
151 NTAPI
152 FsRtlAcquireToCreateMappedSection(_In_ PFILE_OBJECT FileObject,
153                                   _In_ ULONG SectionPageProtection);
154 
155 VOID
156 NTAPI
157 FsRtlReleaseFileForCcFlush(IN PFILE_OBJECT FileObject);
158 
159 NTSTATUS
160 NTAPI
161 FsRtlAcquireFileForCcFlushEx(IN PFILE_OBJECT FileObject);
162