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
85 // Directory enumeration informaiton
88 UNICODE_STRING MaskName;
90 struct _AFS_DIRECTORY_SS_HDR *DirectorySnapshot;
92 ULONG CurrentDirIndex;
95 // PIOCtl and share interface request id
101 // Full path of how the instance was opened
104 UNICODE_STRING FullFileName;
107 // Name array for this open
110 struct _AFS_NAME_ARRAY_HEADER *NameArray;
113 // Pointer to this entries meta data
116 struct _AFS_DIRECTORY_CB *DirectoryCB;
122 UNICODE_STRING NotifyMask;
131 ULONG FileAttributes;
133 LARGE_INTEGER CreationTime;
135 LARGE_INTEGER LastAccessTime;
137 LARGE_INTEGER LastWriteTime;
139 LARGE_INTEGER ChangeTime;
144 // Granted File Access
152 // Object information block
155 typedef struct _AFS_NONPAGED_OBJECT_INFO_CB
158 ERESOURCE DirectoryNodeHdrLock;
160 } AFSNonPagedObjectInfoCB;
162 typedef struct _AFS_OBJECT_INFORMATION_CB
165 AFSBTreeEntry TreeEntry;
167 AFSListEntry ListEntry;
171 LONG ObjectReferenceCount;
173 AFSNonPagedObjectInfoCB *NonPagedInfo;
176 // The VolumeCB where this entry resides
179 struct _AFS_VOLUME_CB *VolumeCB;
182 // Parent object information
185 struct _AFS_OBJECT_INFORMATION_CB *ParentObjectInformation;
188 // Pointer to the current Fcb, if available
197 LARGE_INTEGER LastAccessCount;
200 // Per file metadata information
205 AFSFileID TargetFileId;
207 LARGE_INTEGER Expiration; /* FILETIME */
209 LARGE_INTEGER DataVersion;
211 ULONG FileType; /* File, Dir, MountPoint, Symlink */
213 LARGE_INTEGER CreationTime; /* FILETIME */
215 LARGE_INTEGER LastAccessTime; /* FILETIME */
217 LARGE_INTEGER LastWriteTime; /* FILETIME */
219 LARGE_INTEGER ChangeTime; /* FILETIME */
221 ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */
223 LARGE_INTEGER EndOfFile;
225 LARGE_INTEGER AllocationSize;
232 // Directory and file specific information
242 // The directory search and listing information for the node
245 AFSDirHdr DirectoryNodeHdr;
247 struct _AFS_DIRECTORY_CB *DirectoryNodeListHead;
249 struct _AFS_DIRECTORY_CB *DirectoryNodeListTail;
251 LONG DirectoryNodeCount;
253 struct _AFS_DIRECTORY_CB *ShortNameTree;
256 // PIOCtl directory cb entry
259 struct _AFS_DIRECTORY_CB *PIOCtlDirectoryCB;
262 // Open handle and reference count for this object
265 LONG ChildOpenHandleCount;
267 LONG ChildOpenReferenceCount;
270 // Index for the PIOCtl and share open count
273 LONG OpenRequestIndex;
289 // Volume control block structure
292 typedef struct _AFS_NON_PAGED_VOLUME_CB
295 ERESOURCE VolumeLock;
297 ERESOURCE ObjectInfoTreeLock;
299 ERESOURCE DirectoryNodeHdrLock;
301 }AFSNonPagedVolumeCB;
303 typedef struct _AFS_VOLUME_CB
310 AFSBTreeEntry TreeEntry;
313 // This is the linked list of nodes processed asynchronously by the respective worker thread
316 AFSListEntry ListEntry;
320 AFSNonPagedVolumeCB *NonPagedVcb;
322 ERESOURCE *VolumeLock;
325 // Reference count on the object
328 LONG VolumeReferenceCount;
331 // Object information tree
334 AFSTreeHdr ObjectInfoTree;
336 AFSObjectInfoCB *ObjectInfoListHead;
338 AFSObjectInfoCB *ObjectInfoListTail;
341 // Object information for the volume
344 AFSObjectInfoCB ObjectInformation;
347 // Root directory cb for this volume
350 struct _AFS_DIRECTORY_CB *DirectoryCB;
353 // The Fcb for this volume
359 // Volume worker thread
362 AFSWorkQueueContext VolumeWorkerContext;
365 // Volume information
368 AFSVolumeInfoCB VolumeInformation;
372 typedef struct _AFS_NAME_INFORMATION_CB
375 CCHAR ShortNameLength;
379 UNICODE_STRING FileName;
381 UNICODE_STRING TargetName;
385 typedef struct _AFS_NON_PAGED_DIRECTORY_CB
390 } AFSNonPagedDirectoryCB;
392 typedef struct _AFS_DIRECTORY_CB
395 AFSBTreeEntry CaseSensitiveTreeEntry; // For entries in the NameEntry tree, the
396 // Index is a CRC on the name. For Volume,
397 // MP and SL nodes, the Index is the Cell, Volume
398 // For all others it is the vnode, uniqueid
400 AFSBTreeEntry CaseInsensitiveTreeEntry;
402 AFSListEntry CaseInsensitiveList;
407 // Current open reference count on the directory entry. This count is used
411 LONG OpenReferenceCount;
414 // File index used in directory enumerations
420 // Name information for this entry
423 AFSNameInfoCB NameInformation;
426 // List entry for the directory enumeration list in a parent node
429 AFSListEntry ListEntry;
432 // Back pointer to the ObjectInfo block for this entry
435 AFSObjectInfoCB *ObjectInformation;
441 AFSNonPagedDirectoryCB *NonPaged;
444 // Type specific information
453 AFSBTreeEntry ShortNameTreeEntry;
475 // Read and writes can fan out and so they are syncrhonized via one of
479 typedef struct _AFS_GATHER_READWRITE
491 BOOLEAN CompleteMasterIrp;
497 typedef struct _AFS_IO_RUNS {
499 LARGE_INTEGER CacheOffset;
505 // Name array element and header
508 typedef struct _AFS_NAME_ARRAY_ELEMENT
511 UNICODE_STRING Component;
515 AFSDirectoryCB *DirectoryCB;
521 typedef struct _AFS_NAME_ARRAY_HEADER
524 AFSNameArrayCB *CurrentEntry;
532 ULONG MaxElementCount;
534 AFSNameArrayCB ElementArray[ 1];
538 typedef struct _AFS_FILE_INFO_CB
541 ULONG FileAttributes;
543 LARGE_INTEGER AllocationSize;
545 LARGE_INTEGER EndOfFile;
547 LARGE_INTEGER CreationTime;
549 LARGE_INTEGER LastAccessTime;
551 LARGE_INTEGER LastWriteTime;
553 LARGE_INTEGER ChangeTime;
561 typedef struct _AFS_WORK_ITEM
564 struct _AFS_WORK_ITEM *next;
592 AFSFileInfoCB FileInfo;
594 struct _AFS_NAME_ARRAY_HEADER *NameArray;
602 PDEVICE_OBJECT Device;
604 HANDLE CallingProcess;
615 struct _AFS_IO_RUNS *IoRuns;
619 struct _AFS_GATHER_READWRITE *GatherIo;
621 FILE_OBJECT *CacheFileObject;
633 } AFSWorkItem, *PAFSWorkItem;
636 // Directory snapshot structures
639 typedef struct _AFS_DIRECTORY_SS_ENTRY
646 typedef struct _AFS_DIRECTORY_SS_HDR
651 AFSSnapshotEntry *TopEntry;
655 #endif /* _AFS_STRUCTS_H */