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 LONG ObjectReferences[ 8];
198 AFSNonPagedObjectInfoCB *NonPagedInfo;
201 // The VolumeCB where this entry resides
204 struct _AFS_VOLUME_CB *VolumeCB;
207 // Parent object information
210 AFSFileID ParentFileId;
213 // Pointer to the current Fcb, if available
222 LARGE_INTEGER LastAccessCount;
225 // Per file metadata information
230 AFSFileID TargetFileId;
232 LARGE_INTEGER Expiration; /* FILETIME */
234 LARGE_INTEGER DataVersion;
236 ULONG FileType; /* File, Dir, MountPoint, Symlink */
238 LARGE_INTEGER CreationTime; /* FILETIME */
240 LARGE_INTEGER LastAccessTime; /* FILETIME */
242 LARGE_INTEGER LastWriteTime; /* FILETIME */
244 LARGE_INTEGER ChangeTime; /* FILETIME */
246 ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */
248 LARGE_INTEGER EndOfFile;
250 LARGE_INTEGER AllocationSize;
257 // Directory and file specific information
267 // The directory search and listing information for the node
270 AFSDirHdr DirectoryNodeHdr;
272 struct _AFS_DIRECTORY_CB *DirectoryNodeListHead;
274 struct _AFS_DIRECTORY_CB *DirectoryNodeListTail;
276 LONG DirectoryNodeCount;
278 struct _AFS_DIRECTORY_CB *ShortNameTree;
281 // PIOCtl directory cb entry
284 struct _AFS_DIRECTORY_CB *PIOCtlDirectoryCB;
287 // Open handle and reference count for this object
290 LONG ChildOpenHandleCount;
292 LONG ChildOpenReferenceCount;
295 // Index for the PIOCtl and share open count
298 LONG OpenRequestIndex;
314 // Volume control block structure
317 typedef struct _AFS_NON_PAGED_VOLUME_CB
320 ERESOURCE VolumeLock;
322 ERESOURCE ObjectInfoTreeLock;
324 ERESOURCE DirectoryNodeHdrLock;
327 // Volume worker thread
330 AFSWorkQueueContext VolumeWorkerContext;
332 } AFSNonPagedVolumeCB;
334 typedef struct _AFS_VOLUME_CB
341 AFSBTreeEntry TreeEntry;
344 // This is the linked list of nodes processed asynchronously by the respective worker thread
347 AFSListEntry ListEntry;
351 AFSNonPagedVolumeCB *NonPagedVcb;
353 ERESOURCE *VolumeLock;
356 // Reference count on the object
359 LONG VolumeReferenceCount;
362 // Object information tree
365 AFSTreeHdr ObjectInfoTree;
367 AFSObjectInfoCB *ObjectInfoListHead;
369 AFSObjectInfoCB *ObjectInfoListTail;
372 // Object information for the volume
375 AFSObjectInfoCB ObjectInformation;
378 // Root directory cb for this volume
381 struct _AFS_DIRECTORY_CB *DirectoryCB;
384 // The Fcb for this volume
390 // Volume information
393 AFSVolumeInfoCB VolumeInformation;
397 typedef struct _AFS_NAME_INFORMATION_CB
400 CCHAR ShortNameLength;
404 UNICODE_STRING FileName;
406 UNICODE_STRING TargetName;
410 typedef struct _AFS_NON_PAGED_DIRECTORY_CB
415 } AFSNonPagedDirectoryCB;
417 typedef struct _AFS_DIRECTORY_CB
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
425 AFSBTreeEntry CaseInsensitiveTreeEntry;
427 AFSListEntry CaseInsensitiveList;
432 // Current open reference count on the directory entry. This count is used
436 LONG DirOpenReferenceCount;
439 // Current count of reference from Name Array entries
442 LONG NameArrayReferenceCount;
445 // File index used in directory enumerations
451 // Name information for this entry
454 AFSNameInfoCB NameInformation;
457 // List entry for the directory enumeration list in a parent node
460 AFSListEntry ListEntry;
463 // Back pointer to the ObjectInfo block for this entry
466 AFSObjectInfoCB *ObjectInformation;
472 AFSNonPagedDirectoryCB *NonPaged;
475 // Type specific information
484 AFSBTreeEntry ShortNameTreeEntry;
506 // Read and writes can fan out and so they are syncrhonized via one of
510 typedef struct _AFS_GATHER_READWRITE
522 BOOLEAN CompleteMasterIrp;
528 typedef struct _AFS_IO_RUNS {
530 LARGE_INTEGER CacheOffset;
536 // Name array element and header
539 typedef struct _AFS_NAME_ARRAY_ELEMENT
542 UNICODE_STRING Component;
546 AFSDirectoryCB *DirectoryCB;
552 typedef struct _AFS_NAME_ARRAY_HEADER
555 AFSNameArrayCB *CurrentEntry;
563 ULONG MaxElementCount;
565 AFSNameArrayCB ElementArray[ 1];
569 typedef struct _AFS_FILE_INFO_CB
572 ULONG FileAttributes;
574 LARGE_INTEGER AllocationSize;
576 LARGE_INTEGER EndOfFile;
578 LARGE_INTEGER CreationTime;
580 LARGE_INTEGER LastAccessTime;
582 LARGE_INTEGER LastWriteTime;
584 LARGE_INTEGER ChangeTime;
592 typedef struct _AFS_WORK_ITEM
595 struct _AFS_WORK_ITEM *next;
625 AFSFileInfoCB FileInfo;
627 struct _AFS_NAME_ARRAY_HEADER *NameArray;
635 PDEVICE_OBJECT Device;
637 HANDLE CallingProcess;
648 struct _AFS_IO_RUNS *IoRuns;
652 struct _AFS_GATHER_READWRITE *GatherIo;
654 FILE_OBJECT *CacheFileObject;
661 AFSObjectInfoCB *ObjectInfo;
663 ULONG InvalidateReason;
675 } AFSWorkItem, *PAFSWorkItem;
678 // Directory snapshot structures
681 typedef struct _AFS_DIRECTORY_SS_ENTRY
688 typedef struct _AFS_DIRECTORY_SS_HDR
693 AFSSnapshotEntry *TopEntry;
697 typedef struct _AFS_BYTE_RANGE
700 LARGE_INTEGER FileOffset;
702 LARGE_INTEGER Length;
706 #endif /* _AFS_STRUCTS_H */