OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC. 00003 * Copyright (c) 2009, 2010, 2011 Your File System, Inc. 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * - Redistributions of source code must retain the above copyright notice, 00011 * this list of conditions and the following disclaimer. 00012 * - Redistributions in binary form must reproduce the above copyright 00013 * notice, 00014 * this list of conditions and the following disclaimer in the 00015 * documentation 00016 * and/or other materials provided with the distribution. 00017 * - Neither the names of Kernel Drivers, LLC and Your File System, Inc. 00018 * nor the names of their contributors may be used to endorse or promote 00019 * products derived from this software without specific prior written 00020 * permission from Kernel Drivers, LLC and Your File System, Inc. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00024 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00025 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00026 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00027 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00028 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00029 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00030 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00032 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00035 #ifndef _AFS_STRUCTS_H 00036 #define _AFS_STRUCTS_H 00037 00038 // 00039 // File: AFSStructs.h 00040 // 00041 00042 typedef struct _AFS_DIR_HDR 00043 { 00044 00045 struct _AFS_DIRECTORY_CB *CaseSensitiveTreeHead; 00046 00047 struct _AFS_DIRECTORY_CB *CaseInsensitiveTreeHead; 00048 00049 ERESOURCE *TreeLock; 00050 00051 LONG ContentIndex; 00052 00053 } AFSDirHdr; 00054 00055 // 00056 // Worker pool header 00057 // 00058 00059 typedef struct _AFS_WORKER_QUEUE_HDR 00060 { 00061 00062 struct _AFS_WORKER_QUEUE_HDR *fLink; 00063 00064 KEVENT WorkerThreadReady; 00065 00066 void *WorkerThreadObject; 00067 00068 ULONG State; 00069 00070 } AFSWorkQueueContext, *PAFSWorkQueueContext; 00071 00072 // 00073 // These are the context control blocks for the open instance 00074 // 00075 00076 typedef struct _AFS_NONPAGED_CCB 00077 { 00078 00079 ERESOURCE CcbLock; 00080 00081 } AFSNonPagedCcb; 00082 00083 00084 typedef struct _AFS_CCB 00085 { 00086 00087 USHORT Size; 00088 00089 USHORT Type; 00090 00091 ULONG Flags; 00092 00093 AFSNonPagedCcb *NPCcb; 00094 00095 AFSListEntry ListEntry; 00096 00097 // 00098 // Directory enumeration informaiton 00099 // 00100 00101 UNICODE_STRING MaskName; 00102 00103 struct _AFS_DIRECTORY_SS_HDR *DirectorySnapshot; 00104 00105 ULONG CurrentDirIndex; 00106 00107 // 00108 // PIOCtl and share interface request id 00109 // 00110 00111 ULONG RequestID; 00112 00113 // 00114 // Full path of how the instance was opened 00115 // 00116 00117 UNICODE_STRING FullFileName; 00118 00119 // 00120 // Name array for this open 00121 // 00122 00123 struct _AFS_NAME_ARRAY_HEADER *NameArray; 00124 00125 // 00126 // Pointer to this entries meta data 00127 // 00128 00129 struct _AFS_DIRECTORY_CB *DirectoryCB; 00130 00131 // 00132 // Notification name 00133 // 00134 00135 UNICODE_STRING NotifyMask; 00136 00137 ACCESS_MASK GrantedAccess; 00138 00139 // 00140 // File unwind info 00141 // 00142 00143 struct 00144 { 00145 00146 ULONG FileAttributes; 00147 00148 LARGE_INTEGER CreationTime; 00149 00150 LARGE_INTEGER LastAccessTime; 00151 00152 LARGE_INTEGER LastWriteTime; 00153 00154 LARGE_INTEGER ChangeTime; 00155 00156 } FileUnwindInfo; 00157 00158 // 00159 // Granted File Access 00160 // 00161 00162 ULONG FileAccess; 00163 00164 // 00165 // Authentication group GUID 00166 // 00167 00168 GUID AuthGroup; 00169 00170 } AFSCcb; 00171 00172 // 00173 // Object information block 00174 // 00175 00176 typedef struct _AFS_NONPAGED_OBJECT_INFO_CB 00177 { 00178 00179 ERESOURCE DirectoryNodeHdrLock; 00180 00181 } AFSNonPagedObjectInfoCB; 00182 00183 typedef struct _AFS_OBJECT_INFORMATION_CB 00184 { 00185 00186 AFSBTreeEntry TreeEntry; 00187 00188 AFSListEntry ListEntry; 00189 00190 ULONG Flags; 00191 00192 LONG ObjectReferenceCount; 00193 00194 AFSNonPagedObjectInfoCB *NonPagedInfo; 00195 00196 // 00197 // The VolumeCB where this entry resides 00198 // 00199 00200 struct _AFS_VOLUME_CB *VolumeCB; 00201 00202 // 00203 // Parent object information 00204 // 00205 00206 struct _AFS_OBJECT_INFORMATION_CB *ParentObjectInformation; 00207 00208 // 00209 // Pointer to the current Fcb, if available 00210 // 00211 00212 AFSFcb *Fcb; 00213 00214 // 00215 // Last access time. 00216 // 00217 00218 LARGE_INTEGER LastAccessCount; 00219 00220 // 00221 // Per file metadata information 00222 // 00223 00224 AFSFileID FileId; 00225 00226 AFSFileID TargetFileId; 00227 00228 LARGE_INTEGER Expiration; /* FILETIME */ 00229 00230 LARGE_INTEGER DataVersion; 00231 00232 ULONG FileType; /* File, Dir, MountPoint, Symlink */ 00233 00234 LARGE_INTEGER CreationTime; /* FILETIME */ 00235 00236 LARGE_INTEGER LastAccessTime; /* FILETIME */ 00237 00238 LARGE_INTEGER LastWriteTime; /* FILETIME */ 00239 00240 LARGE_INTEGER ChangeTime; /* FILETIME */ 00241 00242 ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */ 00243 00244 LARGE_INTEGER EndOfFile; 00245 00246 LARGE_INTEGER AllocationSize; 00247 00248 ULONG EaSize; 00249 00250 ULONG Links; 00251 00252 // 00253 // Directory and file specific information 00254 // 00255 00256 union 00257 { 00258 00259 struct 00260 { 00261 00262 // 00263 // The directory search and listing information for the node 00264 // 00265 00266 AFSDirHdr DirectoryNodeHdr; 00267 00268 struct _AFS_DIRECTORY_CB *DirectoryNodeListHead; 00269 00270 struct _AFS_DIRECTORY_CB *DirectoryNodeListTail; 00271 00272 LONG DirectoryNodeCount; 00273 00274 struct _AFS_DIRECTORY_CB *ShortNameTree; 00275 00276 // 00277 // PIOCtl directory cb entry 00278 // 00279 00280 struct _AFS_DIRECTORY_CB *PIOCtlDirectoryCB; 00281 00282 // 00283 // Open handle and reference count for this object 00284 // 00285 00286 LONG ChildOpenHandleCount; 00287 00288 LONG ChildOpenReferenceCount; 00289 00290 // 00291 // Index for the PIOCtl and share open count 00292 // 00293 00294 LONG OpenRequestIndex; 00295 00296 } Directory; 00297 00298 struct 00299 { 00300 00301 ULONG Reserved; 00302 00303 } File; 00304 00305 } Specific; 00306 00307 } AFSObjectInfoCB; 00308 00309 // 00310 // Volume control block structure 00311 // 00312 00313 typedef struct _AFS_NON_PAGED_VOLUME_CB 00314 { 00315 00316 ERESOURCE VolumeLock; 00317 00318 ERESOURCE ObjectInfoTreeLock; 00319 00320 ERESOURCE DirectoryNodeHdrLock; 00321 00322 }AFSNonPagedVolumeCB; 00323 00324 typedef struct _AFS_VOLUME_CB 00325 { 00326 00327 // 00328 // Our tree entry. 00329 // 00330 00331 AFSBTreeEntry TreeEntry; 00332 00333 // 00334 // This is the linked list of nodes processed asynchronously by the respective worker thread 00335 // 00336 00337 AFSListEntry ListEntry; 00338 00339 ULONG Flags; 00340 00341 AFSNonPagedVolumeCB *NonPagedVcb; 00342 00343 ERESOURCE *VolumeLock; 00344 00345 // 00346 // Reference count on the object 00347 // 00348 00349 LONG VolumeReferenceCount; 00350 00351 // 00352 // Object information tree 00353 // 00354 00355 AFSTreeHdr ObjectInfoTree; 00356 00357 AFSObjectInfoCB *ObjectInfoListHead; 00358 00359 AFSObjectInfoCB *ObjectInfoListTail; 00360 00361 // 00362 // Object information for the volume 00363 // 00364 00365 AFSObjectInfoCB ObjectInformation; 00366 00367 // 00368 // Root directory cb for this volume 00369 // 00370 00371 struct _AFS_DIRECTORY_CB *DirectoryCB; 00372 00373 // 00374 // The Fcb for this volume 00375 // 00376 00377 AFSFcb *RootFcb; 00378 00379 // 00380 // Volume worker thread 00381 // 00382 00383 AFSWorkQueueContext VolumeWorkerContext; 00384 00385 // 00386 // Volume information 00387 // 00388 00389 AFSVolumeInfoCB VolumeInformation; 00390 00391 } AFSVolumeCB; 00392 00393 typedef struct _AFS_NAME_INFORMATION_CB 00394 { 00395 00396 CCHAR ShortNameLength; 00397 00398 WCHAR ShortName[12]; 00399 00400 UNICODE_STRING FileName; 00401 00402 UNICODE_STRING TargetName; 00403 00404 } AFSNameInfoCB; 00405 00406 typedef struct _AFS_NON_PAGED_DIRECTORY_CB 00407 { 00408 00409 ERESOURCE Lock; 00410 00411 } AFSNonPagedDirectoryCB; 00412 00413 typedef struct _AFS_DIRECTORY_CB 00414 { 00415 00416 AFSBTreeEntry CaseSensitiveTreeEntry; // For entries in the NameEntry tree, the 00417 // Index is a CRC on the name. For Volume, 00418 // MP and SL nodes, the Index is the Cell, Volume 00419 // For all others it is the vnode, uniqueid 00420 00421 AFSBTreeEntry CaseInsensitiveTreeEntry; 00422 00423 AFSListEntry CaseInsensitiveList; 00424 00425 ULONG Flags; 00426 00427 // 00428 // Current open reference count on the directory entry. This count is used 00429 // for tear down 00430 // 00431 00432 LONG OpenReferenceCount; 00433 00434 // 00435 // File index used in directory enumerations 00436 // 00437 00438 ULONG FileIndex; 00439 00440 // 00441 // Name information for this entry 00442 // 00443 00444 AFSNameInfoCB NameInformation; 00445 00446 // 00447 // List entry for the directory enumeration list in a parent node 00448 // 00449 00450 AFSListEntry ListEntry; 00451 00452 // 00453 // Back pointer to the ObjectInfo block for this entry 00454 // 00455 00456 AFSObjectInfoCB *ObjectInformation; 00457 00458 // 00459 // Non paged pointer 00460 // 00461 00462 AFSNonPagedDirectoryCB *NonPaged; 00463 00464 // 00465 // Type specific information 00466 // 00467 00468 union 00469 { 00470 00471 struct 00472 { 00473 00474 AFSBTreeEntry ShortNameTreeEntry; 00475 00476 } Data; 00477 00478 struct 00479 { 00480 00481 ULONG Reserved; 00482 00483 } MountPoint; 00484 00485 struct 00486 { 00487 00488 ULONG Reserved; 00489 00490 } SymLink; 00491 00492 } Type; 00493 00494 } AFSDirectoryCB; 00495 00496 // Read and writes can fan out and so they are syncrhonized via one of 00497 // these structures 00498 // 00499 00500 typedef struct _AFS_GATHER_READWRITE 00501 { 00502 KEVENT Event; 00503 00504 LONG Count; 00505 00506 NTSTATUS Status; 00507 00508 PIRP MasterIrp; 00509 00510 BOOLEAN Synchronous; 00511 00512 BOOLEAN CompleteMasterIrp; 00513 00514 AFSFcb *Fcb; 00515 00516 } AFSGatherIo; 00517 00518 typedef struct _AFS_IO_RUNS { 00519 00520 LARGE_INTEGER CacheOffset; 00521 PIRP ChildIrp; 00522 ULONG ByteCount; 00523 } AFSIoRun; 00524 00525 // 00526 // Name array element and header 00527 // 00528 00529 typedef struct _AFS_NAME_ARRAY_ELEMENT 00530 { 00531 00532 UNICODE_STRING Component; 00533 00534 AFSFileID FileId; 00535 00536 AFSDirectoryCB *DirectoryCB; 00537 00538 ULONG Flags; 00539 00540 } AFSNameArrayCB; 00541 00542 typedef struct _AFS_NAME_ARRAY_HEADER 00543 { 00544 00545 AFSNameArrayCB *CurrentEntry; 00546 00547 LONG Count; 00548 00549 LONG LinkCount; 00550 00551 ULONG Flags; 00552 00553 ULONG MaxElementCount; 00554 00555 AFSNameArrayCB ElementArray[ 1]; 00556 00557 } AFSNameArrayHdr; 00558 00559 typedef struct _AFS_FILE_INFO_CB 00560 { 00561 00562 ULONG FileAttributes; 00563 00564 LARGE_INTEGER AllocationSize; 00565 00566 LARGE_INTEGER EndOfFile; 00567 00568 LARGE_INTEGER CreationTime; 00569 00570 LARGE_INTEGER LastAccessTime; 00571 00572 LARGE_INTEGER LastWriteTime; 00573 00574 LARGE_INTEGER ChangeTime; 00575 00576 } AFSFileInfoCB; 00577 00578 // 00579 // Work item 00580 // 00581 00582 typedef struct _AFS_WORK_ITEM 00583 { 00584 00585 struct _AFS_WORK_ITEM *next; 00586 00587 ULONG RequestType; 00588 00589 ULONG RequestFlags; 00590 00591 NTSTATUS Status; 00592 00593 KEVENT Event; 00594 00595 ULONG Size; 00596 00597 ULONGLONG ProcessID; 00598 00599 GUID AuthGroup; 00600 00601 union 00602 { 00603 struct 00604 { 00605 PIRP Irp; 00606 00607 } ReleaseExtents; 00608 00609 struct 00610 { 00611 AFSFcb *Fcb; 00612 00613 AFSFcb **TargetFcb; 00614 00615 AFSFileInfoCB FileInfo; 00616 00617 struct _AFS_NAME_ARRAY_HEADER *NameArray; 00618 00619 } Fcb; 00620 00621 struct 00622 { 00623 PIRP Irp; 00624 00625 PDEVICE_OBJECT Device; 00626 00627 HANDLE CallingProcess; 00628 00629 } AsynchIo; 00630 00631 struct 00632 { 00633 00634 UCHAR FunctionCode; 00635 00636 ULONG RequestFlags; 00637 00638 struct _AFS_IO_RUNS *IoRuns; 00639 00640 ULONG RunCount; 00641 00642 struct _AFS_GATHER_READWRITE *GatherIo; 00643 00644 FILE_OBJECT *CacheFileObject; 00645 00646 } CacheAccess; 00647 00648 struct 00649 { 00650 00651 AFSObjectInfoCB *ObjectInfo; 00652 00653 ULONG InvalidateReason; 00654 00655 } Invalidate; 00656 00657 struct 00658 { 00659 char Context[ 1]; 00660 00661 } Other; 00662 00663 } Specific; 00664 00665 } AFSWorkItem, *PAFSWorkItem; 00666 00667 // 00668 // Directory snapshot structures 00669 // 00670 00671 typedef struct _AFS_DIRECTORY_SS_ENTRY 00672 { 00673 00674 ULONG NameHash; 00675 00676 } AFSSnapshotEntry; 00677 00678 typedef struct _AFS_DIRECTORY_SS_HDR 00679 { 00680 00681 ULONG EntryCount; 00682 00683 AFSSnapshotEntry *TopEntry; 00684 00685 } AFSSnapshotHdr; 00686 00687 typedef struct _AFS_BYTE_RANGE 00688 { 00689 00690 LARGE_INTEGER FileOffset; 00691 00692 LARGE_INTEGER Length; 00693 00694 } AFSByteRange; 00695 00696 #endif /* _AFS_STRUCTS_H */