2 * Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
3 * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
14 * this list of conditions and the following disclaimer in the
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.
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.
35 #ifndef _AFS_STRUCTS_H
36 #define _AFS_STRUCTS_H
42 typedef struct _AFS_DIR_HDR
45 struct _AFS_DIRECTORY_CB *CaseSensitiveTreeHead;
47 struct _AFS_DIRECTORY_CB *CaseInsensitiveTreeHead;
59 typedef struct _AFS_WORKER_QUEUE_HDR
62 struct _AFS_WORKER_QUEUE_HDR *fLink;
64 KEVENT WorkerThreadReady;
66 void *WorkerThreadObject;
70 } AFSWorkQueueContext, *PAFSWorkQueueContext;
73 // These are the context control blocks for the open instance
76 typedef struct _AFS_CCB
84 AFSListEntry ListEntry;
87 // Directory enumeration informaiton
90 UNICODE_STRING MaskName;
92 struct _AFS_DIRECTORY_SS_HDR *DirectorySnapshot;
94 ULONG CurrentDirIndex;
97 // PIOCtl and share interface request id
103 // Full path of how the instance was opened
106 UNICODE_STRING FullFileName;
109 // Name array for this open
112 struct _AFS_NAME_ARRAY_HEADER *NameArray;
115 // Pointer to this entries meta data
118 struct _AFS_DIRECTORY_CB *DirectoryCB;
124 UNICODE_STRING NotifyMask;
126 ACCESS_MASK GrantedAccess;
135 ULONG FileAttributes;
137 LARGE_INTEGER CreationTime;
139 LARGE_INTEGER LastAccessTime;
141 LARGE_INTEGER LastWriteTime;
143 LARGE_INTEGER ChangeTime;
148 // Granted File Access
154 // Authentication group GUID
162 // Object information block
165 typedef struct _AFS_NONPAGED_OBJECT_INFO_CB
168 ERESOURCE DirectoryNodeHdrLock;
170 } AFSNonPagedObjectInfoCB;
172 typedef struct _AFS_OBJECT_INFORMATION_CB
175 AFSBTreeEntry TreeEntry;
177 AFSListEntry ListEntry;
181 LONG ObjectReferenceCount;
183 AFSNonPagedObjectInfoCB *NonPagedInfo;
186 // The VolumeCB where this entry resides
189 struct _AFS_VOLUME_CB *VolumeCB;
192 // Parent object information
195 struct _AFS_OBJECT_INFORMATION_CB *ParentObjectInformation;
198 // Pointer to the current Fcb, if available
207 LARGE_INTEGER LastAccessCount;
210 // Per file metadata information
215 AFSFileID TargetFileId;
217 LARGE_INTEGER Expiration; /* FILETIME */
219 LARGE_INTEGER DataVersion;
221 ULONG FileType; /* File, Dir, MountPoint, Symlink */
223 LARGE_INTEGER CreationTime; /* FILETIME */
225 LARGE_INTEGER LastAccessTime; /* FILETIME */
227 LARGE_INTEGER LastWriteTime; /* FILETIME */
229 LARGE_INTEGER ChangeTime; /* FILETIME */
231 ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */
233 LARGE_INTEGER EndOfFile;
235 LARGE_INTEGER AllocationSize;
242 // Directory and file specific information
252 // The directory search and listing information for the node
255 AFSDirHdr DirectoryNodeHdr;
257 struct _AFS_DIRECTORY_CB *DirectoryNodeListHead;
259 struct _AFS_DIRECTORY_CB *DirectoryNodeListTail;
261 LONG DirectoryNodeCount;
263 struct _AFS_DIRECTORY_CB *ShortNameTree;
266 // PIOCtl directory cb entry
269 struct _AFS_DIRECTORY_CB *PIOCtlDirectoryCB;
272 // Open handle and reference count for this object
275 LONG ChildOpenHandleCount;
277 LONG ChildOpenReferenceCount;
280 // Index for the PIOCtl and share open count
283 LONG OpenRequestIndex;
299 // Volume control block structure
302 typedef struct _AFS_NON_PAGED_VOLUME_CB
305 ERESOURCE VolumeLock;
307 ERESOURCE ObjectInfoTreeLock;
309 ERESOURCE DirectoryNodeHdrLock;
311 }AFSNonPagedVolumeCB;
313 typedef struct _AFS_VOLUME_CB
320 AFSBTreeEntry TreeEntry;
323 // This is the linked list of nodes processed asynchronously by the respective worker thread
326 AFSListEntry ListEntry;
330 AFSNonPagedVolumeCB *NonPagedVcb;
332 ERESOURCE *VolumeLock;
335 // Reference count on the object
338 LONG VolumeReferenceCount;
341 // Object information tree
344 AFSTreeHdr ObjectInfoTree;
346 AFSObjectInfoCB *ObjectInfoListHead;
348 AFSObjectInfoCB *ObjectInfoListTail;
351 // Object information for the volume
354 AFSObjectInfoCB ObjectInformation;
357 // Root directory cb for this volume
360 struct _AFS_DIRECTORY_CB *DirectoryCB;
363 // The Fcb for this volume
369 // Volume worker thread
372 AFSWorkQueueContext VolumeWorkerContext;
375 // Volume information
378 AFSVolumeInfoCB VolumeInformation;
382 typedef struct _AFS_NAME_INFORMATION_CB
385 CCHAR ShortNameLength;
389 UNICODE_STRING FileName;
391 UNICODE_STRING TargetName;
395 typedef struct _AFS_NON_PAGED_DIRECTORY_CB
400 } AFSNonPagedDirectoryCB;
402 typedef struct _AFS_DIRECTORY_CB
405 AFSBTreeEntry CaseSensitiveTreeEntry; // For entries in the NameEntry tree, the
406 // Index is a CRC on the name. For Volume,
407 // MP and SL nodes, the Index is the Cell, Volume
408 // For all others it is the vnode, uniqueid
410 AFSBTreeEntry CaseInsensitiveTreeEntry;
412 AFSListEntry CaseInsensitiveList;
417 // Current open reference count on the directory entry. This count is used
421 LONG OpenReferenceCount;
424 // File index used in directory enumerations
430 // Name information for this entry
433 AFSNameInfoCB NameInformation;
436 // List entry for the directory enumeration list in a parent node
439 AFSListEntry ListEntry;
442 // Back pointer to the ObjectInfo block for this entry
445 AFSObjectInfoCB *ObjectInformation;
451 AFSNonPagedDirectoryCB *NonPaged;
454 // Type specific information
463 AFSBTreeEntry ShortNameTreeEntry;
485 // Read and writes can fan out and so they are syncrhonized via one of
489 typedef struct _AFS_GATHER_READWRITE
501 BOOLEAN CompleteMasterIrp;
507 typedef struct _AFS_IO_RUNS {
509 LARGE_INTEGER CacheOffset;
515 // Name array element and header
518 typedef struct _AFS_NAME_ARRAY_ELEMENT
521 UNICODE_STRING Component;
525 AFSDirectoryCB *DirectoryCB;
531 typedef struct _AFS_NAME_ARRAY_HEADER
534 AFSNameArrayCB *CurrentEntry;
542 ULONG MaxElementCount;
544 AFSNameArrayCB ElementArray[ 1];
548 typedef struct _AFS_FILE_INFO_CB
551 ULONG FileAttributes;
553 LARGE_INTEGER AllocationSize;
555 LARGE_INTEGER EndOfFile;
557 LARGE_INTEGER CreationTime;
559 LARGE_INTEGER LastAccessTime;
561 LARGE_INTEGER LastWriteTime;
563 LARGE_INTEGER ChangeTime;
571 typedef struct _AFS_WORK_ITEM
574 struct _AFS_WORK_ITEM *next;
604 AFSFileInfoCB FileInfo;
606 struct _AFS_NAME_ARRAY_HEADER *NameArray;
614 PDEVICE_OBJECT Device;
616 HANDLE CallingProcess;
627 struct _AFS_IO_RUNS *IoRuns;
631 struct _AFS_GATHER_READWRITE *GatherIo;
633 FILE_OBJECT *CacheFileObject;
640 AFSObjectInfoCB *ObjectInfo;
642 ULONG InvalidateReason;
654 } AFSWorkItem, *PAFSWorkItem;
657 // Directory snapshot structures
660 typedef struct _AFS_DIRECTORY_SS_ENTRY
667 typedef struct _AFS_DIRECTORY_SS_HDR
672 AFSSnapshotEntry *TopEntry;
676 typedef struct _AFS_BYTE_RANGE
679 LARGE_INTEGER FileOffset;
681 LARGE_INTEGER Length;
685 #endif /* _AFS_STRUCTS_H */