Windows: Test for PRSFS_INSERT in redirector interface
[openafs.git] / src / WINNT / afsrdr / kernel / lib / Include / AFSStructs.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
3  * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * - Redistributions of source code must retain the above copyright notice,
11  *   this list of conditions and the following disclaimer.
12  * - Redistributions in binary form must reproduce the above copyright
13  *   notice,
14  *   this list of conditions and the following disclaimer in the
15  *   documentation
16  *   and/or other materials provided with the distribution.
17  * - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
18  *   nor the names of their contributors may be used to endorse or promote
19  *   products derived from this software without specific prior written
20  *   permission from Kernel Drivers, LLC and Your File System, Inc.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
26  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #ifndef _AFS_STRUCTS_H
36 #define _AFS_STRUCTS_H
37
38 //
39 // File: AFSStructs.h
40 //
41
42 typedef struct _AFS_DIR_HDR
43 {
44
45     struct _AFS_DIRECTORY_CB *CaseSensitiveTreeHead;
46
47     struct _AFS_DIRECTORY_CB *CaseInsensitiveTreeHead;
48
49     ERESOURCE               *TreeLock;
50
51     LONG                     ContentIndex;
52
53 } AFSDirHdr;
54
55 //
56 // Worker pool header
57 //
58
59 typedef struct _AFS_WORKER_QUEUE_HDR
60 {
61
62     struct _AFS_WORKER_QUEUE_HDR    *fLink;
63
64     KEVENT           WorkerThreadReady;
65
66     void            *WorkerThreadObject;
67
68     ULONG            State;
69
70 } AFSWorkQueueContext, *PAFSWorkQueueContext;
71
72 //
73 // These are the context control blocks for the open instance
74 //
75
76 typedef struct _AFS_NONPAGED_CCB
77 {
78
79     ERESOURCE           CcbLock;
80
81 } AFSNonPagedCcb;
82
83
84 typedef struct _AFS_CCB
85 {
86
87     USHORT        Size;
88
89     USHORT        Type;
90
91     ULONG         Flags;
92
93     AFSNonPagedCcb  *NPCcb;
94
95     AFSListEntry  ListEntry;
96
97     //
98     // Directory enumeration informaiton
99     //
100
101     UNICODE_STRING MaskName;
102
103     struct _AFS_DIRECTORY_SS_HDR    *DirectorySnapshot;
104
105     ULONG          CurrentDirIndex;
106
107     //
108     // PIOCtl and share interface request id
109     //
110
111     ULONG          RequestID;
112
113     //
114     // Full path of how the instance was opened
115     //
116
117     UNICODE_STRING FullFileName;
118
119     //
120     // Name array for this open
121     //
122
123     struct _AFS_NAME_ARRAY_HEADER  *NameArray;
124
125     //
126     // Pointer to this entries meta data
127     //
128
129     struct _AFS_DIRECTORY_CB  *DirectoryCB;
130
131     //
132     // Notification name
133     //
134
135     UNICODE_STRING          NotifyMask;
136
137     ACCESS_MASK             GrantedAccess;
138
139     //
140     // File unwind info
141     //
142
143     struct
144     {
145
146         ULONG           FileAttributes;
147
148         LARGE_INTEGER   CreationTime;
149
150         LARGE_INTEGER   LastAccessTime;
151
152         LARGE_INTEGER   LastWriteTime;
153
154         LARGE_INTEGER   ChangeTime;
155
156     } FileUnwindInfo;
157
158     //
159     // Granted File Access
160     //
161
162     ULONG               FileAccess;
163
164     //
165     // Authentication group GUID
166     //
167
168     GUID                AuthGroup;
169
170 } AFSCcb;
171
172 //
173 // Object information block
174 //
175
176 typedef struct _AFS_NONPAGED_OBJECT_INFO_CB
177 {
178
179     ERESOURCE           DirectoryNodeHdrLock;
180
181     ERESOURCE           ObjectInfoLock;
182
183 } AFSNonPagedObjectInfoCB;
184
185 typedef struct _AFS_OBJECT_INFORMATION_CB
186 {
187
188     AFSBTreeEntry             TreeEntry;
189
190     AFSListEntry              ListEntry;
191
192     ULONG                     Flags;
193
194     LONG                      ObjectReferenceCount;
195
196     LONG                      ObjectReferences[ 8];
197
198     AFSNonPagedObjectInfoCB  *NonPagedInfo;
199
200     //
201     // The VolumeCB where this entry resides
202     //
203
204     struct _AFS_VOLUME_CB    *VolumeCB;
205
206     //
207     // Parent object information
208     //
209
210     struct _AFS_OBJECT_INFORMATION_CB   *ParentObjectInformation;
211
212     //
213     // Pointer to the current Fcb, if available
214     //
215
216     AFSFcb                   *Fcb;
217
218     //
219     // Last access time.
220     //
221
222     LARGE_INTEGER           LastAccessCount;
223
224     //
225     // Per file metadata information
226     //
227
228     AFSFileID               FileId;
229
230     AFSFileID               TargetFileId;
231
232     LARGE_INTEGER           Expiration;         /* FILETIME */
233
234     LARGE_INTEGER           DataVersion;
235
236     ULONG                   FileType;           /* File, Dir, MountPoint, Symlink */
237
238     LARGE_INTEGER           CreationTime;       /* FILETIME */
239
240     LARGE_INTEGER           LastAccessTime;     /* FILETIME */
241
242     LARGE_INTEGER           LastWriteTime;      /* FILETIME */
243
244     LARGE_INTEGER           ChangeTime;         /* FILETIME */
245
246     ULONG                   FileAttributes;     /* NTFS FILE_ATTRIBUTE_xxxx see below */
247
248     LARGE_INTEGER           EndOfFile;
249
250     LARGE_INTEGER           AllocationSize;
251
252     ULONG                   EaSize;
253
254     ULONG                   Links;
255
256     //
257     // Directory and file specific information
258     //
259
260         union
261         {
262
263                 struct
264                 {
265
266                         //
267                         // The directory search and listing information for the node
268                         //
269
270                         AFSDirHdr                  DirectoryNodeHdr;
271
272                         struct _AFS_DIRECTORY_CB  *DirectoryNodeListHead;
273
274                         struct _AFS_DIRECTORY_CB  *DirectoryNodeListTail;
275
276                         LONG                       DirectoryNodeCount;
277
278                         struct _AFS_DIRECTORY_CB  *ShortNameTree;
279
280                         //
281                         // PIOCtl directory cb entry
282                         //
283
284                         struct _AFS_DIRECTORY_CB  *PIOCtlDirectoryCB;
285
286                         //
287                         // Open handle and reference count for this object
288                         //
289
290                         LONG                       ChildOpenHandleCount;
291
292                         LONG                       ChildOpenReferenceCount;
293
294                         //
295                         // Index for the PIOCtl and share open count
296                         //
297
298                         LONG                OpenRequestIndex;
299
300                 } Directory;
301
302                 struct
303                 {
304
305                         ULONG       Reserved;
306
307                 } File;
308
309         } Specific;
310
311 } AFSObjectInfoCB;
312
313 //
314 // Volume control block structure
315 //
316
317 typedef struct _AFS_NON_PAGED_VOLUME_CB
318 {
319
320     ERESOURCE           VolumeLock;
321
322     ERESOURCE           ObjectInfoTreeLock;
323
324     ERESOURCE           DirectoryNodeHdrLock;
325
326     //
327     // Volume worker thread
328     //
329
330     AFSWorkQueueContext       VolumeWorkerContext;
331
332 } AFSNonPagedVolumeCB;
333
334 typedef struct _AFS_VOLUME_CB
335 {
336
337     //
338     // Our tree entry.
339     //
340
341     AFSBTreeEntry             TreeEntry;
342
343     //
344     // This is the linked list of nodes processed asynchronously by the respective worker thread
345     //
346
347     AFSListEntry              ListEntry;
348
349     ULONG                     Flags;
350
351     AFSNonPagedVolumeCB      *NonPagedVcb;
352
353     ERESOURCE                *VolumeLock;
354
355     //
356     // Reference count on the object
357     //
358
359     LONG                      VolumeReferenceCount;
360
361     //
362     // Object information tree
363     //
364
365     AFSTreeHdr                ObjectInfoTree;
366
367     AFSObjectInfoCB          *ObjectInfoListHead;
368
369     AFSObjectInfoCB          *ObjectInfoListTail;
370
371     //
372     // Object information for the volume
373     //
374
375     AFSObjectInfoCB           ObjectInformation;
376
377     //
378     // Root directory cb for this volume
379     //
380
381     struct _AFS_DIRECTORY_CB *DirectoryCB;
382
383     //
384     // The Fcb for this volume
385     //
386
387     AFSFcb                   *RootFcb;
388
389     //
390     // Volume information
391     //
392
393     AFSVolumeInfoCB           VolumeInformation;
394
395 } AFSVolumeCB;
396
397 typedef struct _AFS_NAME_INFORMATION_CB
398 {
399
400     CCHAR           ShortNameLength;
401
402     WCHAR           ShortName[12];
403
404     UNICODE_STRING  FileName;
405
406     UNICODE_STRING  TargetName;
407
408 } AFSNameInfoCB;
409
410 typedef struct _AFS_NON_PAGED_DIRECTORY_CB
411 {
412
413     ERESOURCE       Lock;
414
415 } AFSNonPagedDirectoryCB;
416
417 typedef struct _AFS_DIRECTORY_CB
418 {
419
420     AFSBTreeEntry    CaseSensitiveTreeEntry;    // For entries in the NameEntry tree, the
421                                                 // Index is a CRC on the name. For Volume,
422                                                 // MP and SL nodes, the Index is the Cell, Volume
423                                                 // For all others it is the vnode, uniqueid
424
425     AFSBTreeEntry    CaseInsensitiveTreeEntry;
426
427     AFSListEntry     CaseInsensitiveList;
428
429     ULONG            Flags;
430
431     //
432     // Current open reference count on the directory entry. This count is used
433     // for tear down
434     //
435
436     LONG             DirOpenReferenceCount;
437
438     //
439     // Current count of reference from Name Array entries
440     //
441
442     LONG             NameArrayReferenceCount;
443
444     //
445     // File index used in directory enumerations
446     //
447
448     ULONG            FileIndex;
449
450     //
451     // Name information for this entry
452     //
453
454     AFSNameInfoCB    NameInformation;
455
456     //
457     // List entry for the directory enumeration list in a parent node
458     //
459
460     AFSListEntry     ListEntry;
461
462     //
463     // Back pointer to the ObjectInfo block for this entry
464     //
465
466     AFSObjectInfoCB *ObjectInformation;
467
468     //
469     // Non paged pointer
470     //
471
472     AFSNonPagedDirectoryCB  *NonPaged;
473
474     //
475     // Type specific information
476     //
477
478     union
479     {
480
481         struct
482         {
483
484             AFSBTreeEntry    ShortNameTreeEntry;
485
486         } Data;
487
488         struct
489         {
490
491             ULONG           Reserved;
492
493         } MountPoint;
494
495         struct
496         {
497
498             ULONG           Reserved;
499
500         } SymLink;
501
502     } Type;
503
504 } AFSDirectoryCB;
505
506 // Read and writes can fan out and so they are syncrhonized via one of
507 // these structures
508 //
509
510 typedef struct _AFS_GATHER_READWRITE
511 {
512     KEVENT     Event;
513
514     LONG       Count;
515
516     NTSTATUS   Status;
517
518     PIRP       MasterIrp;
519
520     BOOLEAN    Synchronous;
521
522     BOOLEAN    CompleteMasterIrp;
523
524     AFSFcb    *Fcb;
525
526 } AFSGatherIo;
527
528 typedef struct _AFS_IO_RUNS {
529
530     LARGE_INTEGER CacheOffset;
531     PIRP          ChildIrp;
532     ULONG         ByteCount;
533 } AFSIoRun;
534
535 //
536 // Name array element and header
537 //
538
539 typedef struct _AFS_NAME_ARRAY_ELEMENT
540 {
541
542     UNICODE_STRING      Component;
543
544     AFSFileID           FileId;
545
546     AFSDirectoryCB     *DirectoryCB;
547
548     ULONG               Flags;
549
550 } AFSNameArrayCB;
551
552 typedef struct _AFS_NAME_ARRAY_HEADER
553 {
554
555     AFSNameArrayCB      *CurrentEntry;
556
557     LONG                 Count;
558
559     LONG                 LinkCount;
560
561     ULONG                Flags;
562
563     ULONG                MaxElementCount;
564
565     AFSNameArrayCB       ElementArray[ 1];
566
567 } AFSNameArrayHdr;
568
569 typedef struct _AFS_FILE_INFO_CB
570 {
571
572     ULONG           FileAttributes;
573
574     LARGE_INTEGER   AllocationSize;
575
576     LARGE_INTEGER   EndOfFile;
577
578     LARGE_INTEGER   CreationTime;
579
580     LARGE_INTEGER   LastAccessTime;
581
582     LARGE_INTEGER   LastWriteTime;
583
584     LARGE_INTEGER   ChangeTime;
585
586 } AFSFileInfoCB;
587
588 //
589 // Work item
590 //
591
592 typedef struct _AFS_WORK_ITEM
593 {
594
595     struct _AFS_WORK_ITEM *next;
596
597     ULONG    RequestType;
598
599     ULONG    RequestFlags;
600
601     NTSTATUS Status;
602
603     KEVENT   Event;
604
605     ULONG    Size;
606
607     ULONGLONG   ProcessID;
608
609     GUID     AuthGroup;
610
611     union
612     {
613         struct
614         {
615             PIRP Irp;
616
617         } ReleaseExtents;
618
619         struct
620         {
621             AFSFcb *Fcb;
622
623             AFSFcb **TargetFcb;
624
625             AFSFileInfoCB   FileInfo;
626
627             struct _AFS_NAME_ARRAY_HEADER *NameArray;
628
629         } Fcb;
630
631         struct
632         {
633             PIRP Irp;
634
635             PDEVICE_OBJECT Device;
636
637             HANDLE CallingProcess;
638
639         } AsynchIo;
640
641         struct
642         {
643
644             UCHAR FunctionCode;
645
646             ULONG RequestFlags;
647
648             struct _AFS_IO_RUNS    *IoRuns;
649
650             ULONG RunCount;
651
652             struct _AFS_GATHER_READWRITE *GatherIo;
653
654             FILE_OBJECT *CacheFileObject;
655
656         } CacheAccess;
657
658         struct
659         {
660
661             AFSObjectInfoCB *ObjectInfo;
662
663             ULONG            InvalidateReason;
664
665         } Invalidate;
666
667         struct
668         {
669             char     Context[ 1];
670
671         } Other;
672
673     } Specific;
674
675 } AFSWorkItem, *PAFSWorkItem;
676
677 //
678 // Directory snapshot structures
679 //
680
681 typedef struct _AFS_DIRECTORY_SS_ENTRY
682 {
683
684     ULONG       NameHash;
685
686 } AFSSnapshotEntry;
687
688 typedef struct _AFS_DIRECTORY_SS_HDR
689 {
690
691     ULONG       EntryCount;
692
693     AFSSnapshotEntry    *TopEntry;
694
695 } AFSSnapshotHdr;
696
697 typedef struct _AFS_BYTE_RANGE
698 {
699
700     LARGE_INTEGER       FileOffset;
701
702     LARGE_INTEGER       Length;
703
704 } AFSByteRange;
705
706 #endif /* _AFS_STRUCTS_H */