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_NONPAGED_CCB
84 typedef struct _AFS_CCB
93 AFSNonPagedCcb *NPCcb;
95 AFSListEntry ListEntry;
98 // Directory enumeration informaiton
101 UNICODE_STRING MaskName;
103 struct _AFS_DIRECTORY_SS_HDR *DirectorySnapshot;
105 ULONG CurrentDirIndex;
108 // PIOCtl and share interface request id
114 // Full path of how the instance was opened
117 UNICODE_STRING FullFileName;
120 // Name array for this open
123 struct _AFS_NAME_ARRAY_HEADER *NameArray;
126 // Pointer to this entries meta data
129 struct _AFS_DIRECTORY_CB *DirectoryCB;
135 UNICODE_STRING NotifyMask;
137 ACCESS_MASK GrantedAccess;
146 ULONG FileAttributes;
148 LARGE_INTEGER CreationTime;
150 LARGE_INTEGER LastAccessTime;
152 LARGE_INTEGER LastWriteTime;
154 LARGE_INTEGER ChangeTime;
159 // Granted File Access
165 // Authentication group GUID
173 // Object information block
176 typedef struct _AFS_NONPAGED_OBJECT_INFO_CB
179 ERESOURCE DirectoryNodeHdrLock;
181 ERESOURCE ObjectInfoLock;
183 } AFSNonPagedObjectInfoCB;
185 typedef struct _AFS_OBJECT_INFORMATION_CB
188 AFSBTreeEntry TreeEntry;
190 AFSListEntry ListEntry;
194 LONG ObjectReferenceCount;
196 AFSNonPagedObjectInfoCB *NonPagedInfo;
199 // The VolumeCB where this entry resides
202 struct _AFS_VOLUME_CB *VolumeCB;
205 // Parent object information
208 struct _AFS_OBJECT_INFORMATION_CB *ParentObjectInformation;
211 // Pointer to the current Fcb, if available
220 LARGE_INTEGER LastAccessCount;
223 // Per file metadata information
228 AFSFileID TargetFileId;
230 LARGE_INTEGER Expiration; /* FILETIME */
232 LARGE_INTEGER DataVersion;
234 ULONG FileType; /* File, Dir, MountPoint, Symlink */
236 LARGE_INTEGER CreationTime; /* FILETIME */
238 LARGE_INTEGER LastAccessTime; /* FILETIME */
240 LARGE_INTEGER LastWriteTime; /* FILETIME */
242 LARGE_INTEGER ChangeTime; /* FILETIME */
244 ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */
246 LARGE_INTEGER EndOfFile;
248 LARGE_INTEGER AllocationSize;
255 // Directory and file specific information
265 // The directory search and listing information for the node
268 AFSDirHdr DirectoryNodeHdr;
270 struct _AFS_DIRECTORY_CB *DirectoryNodeListHead;
272 struct _AFS_DIRECTORY_CB *DirectoryNodeListTail;
274 LONG DirectoryNodeCount;
276 struct _AFS_DIRECTORY_CB *ShortNameTree;
279 // PIOCtl directory cb entry
282 struct _AFS_DIRECTORY_CB *PIOCtlDirectoryCB;
285 // Open handle and reference count for this object
288 LONG ChildOpenHandleCount;
290 LONG ChildOpenReferenceCount;
293 // Index for the PIOCtl and share open count
296 LONG OpenRequestIndex;
312 // Volume control block structure
315 typedef struct _AFS_NON_PAGED_VOLUME_CB
318 ERESOURCE VolumeLock;
320 ERESOURCE ObjectInfoTreeLock;
322 ERESOURCE DirectoryNodeHdrLock;
324 }AFSNonPagedVolumeCB;
326 typedef struct _AFS_VOLUME_CB
333 AFSBTreeEntry TreeEntry;
336 // This is the linked list of nodes processed asynchronously by the respective worker thread
339 AFSListEntry ListEntry;
343 AFSNonPagedVolumeCB *NonPagedVcb;
345 ERESOURCE *VolumeLock;
348 // Reference count on the object
351 LONG VolumeReferenceCount;
354 // Object information tree
357 AFSTreeHdr ObjectInfoTree;
359 AFSObjectInfoCB *ObjectInfoListHead;
361 AFSObjectInfoCB *ObjectInfoListTail;
364 // Object information for the volume
367 AFSObjectInfoCB ObjectInformation;
370 // Root directory cb for this volume
373 struct _AFS_DIRECTORY_CB *DirectoryCB;
376 // The Fcb for this volume
382 // Volume worker thread
385 AFSWorkQueueContext VolumeWorkerContext;
388 // Volume information
391 AFSVolumeInfoCB VolumeInformation;
395 typedef struct _AFS_NAME_INFORMATION_CB
398 CCHAR ShortNameLength;
402 UNICODE_STRING FileName;
404 UNICODE_STRING TargetName;
408 typedef struct _AFS_NON_PAGED_DIRECTORY_CB
413 } AFSNonPagedDirectoryCB;
415 typedef struct _AFS_DIRECTORY_CB
418 AFSBTreeEntry CaseSensitiveTreeEntry; // For entries in the NameEntry tree, the
419 // Index is a CRC on the name. For Volume,
420 // MP and SL nodes, the Index is the Cell, Volume
421 // For all others it is the vnode, uniqueid
423 AFSBTreeEntry CaseInsensitiveTreeEntry;
425 AFSListEntry CaseInsensitiveList;
430 // Current open reference count on the directory entry. This count is used
434 LONG OpenReferenceCount;
437 // File index used in directory enumerations
443 // Name information for this entry
446 AFSNameInfoCB NameInformation;
449 // List entry for the directory enumeration list in a parent node
452 AFSListEntry ListEntry;
455 // Back pointer to the ObjectInfo block for this entry
458 AFSObjectInfoCB *ObjectInformation;
464 AFSNonPagedDirectoryCB *NonPaged;
467 // Type specific information
476 AFSBTreeEntry ShortNameTreeEntry;
498 // Read and writes can fan out and so they are syncrhonized via one of
502 typedef struct _AFS_GATHER_READWRITE
514 BOOLEAN CompleteMasterIrp;
520 typedef struct _AFS_IO_RUNS {
522 LARGE_INTEGER CacheOffset;
528 // Name array element and header
531 typedef struct _AFS_NAME_ARRAY_ELEMENT
534 UNICODE_STRING Component;
538 AFSDirectoryCB *DirectoryCB;
544 typedef struct _AFS_NAME_ARRAY_HEADER
547 AFSNameArrayCB *CurrentEntry;
555 ULONG MaxElementCount;
557 AFSNameArrayCB ElementArray[ 1];
561 typedef struct _AFS_FILE_INFO_CB
564 ULONG FileAttributes;
566 LARGE_INTEGER AllocationSize;
568 LARGE_INTEGER EndOfFile;
570 LARGE_INTEGER CreationTime;
572 LARGE_INTEGER LastAccessTime;
574 LARGE_INTEGER LastWriteTime;
576 LARGE_INTEGER ChangeTime;
584 typedef struct _AFS_WORK_ITEM
587 struct _AFS_WORK_ITEM *next;
617 AFSFileInfoCB FileInfo;
619 struct _AFS_NAME_ARRAY_HEADER *NameArray;
627 PDEVICE_OBJECT Device;
629 HANDLE CallingProcess;
640 struct _AFS_IO_RUNS *IoRuns;
644 struct _AFS_GATHER_READWRITE *GatherIo;
646 FILE_OBJECT *CacheFileObject;
653 AFSObjectInfoCB *ObjectInfo;
655 ULONG InvalidateReason;
667 } AFSWorkItem, *PAFSWorkItem;
670 // Directory snapshot structures
673 typedef struct _AFS_DIRECTORY_SS_ENTRY
680 typedef struct _AFS_DIRECTORY_SS_HDR
685 AFSSnapshotEntry *TopEntry;
689 typedef struct _AFS_BYTE_RANGE
692 LARGE_INTEGER FileOffset;
694 LARGE_INTEGER Length;
698 #endif /* _AFS_STRUCTS_H */