OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/WINNT/afsrdr/kernel/lib/Include/AFSDefines.h
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_DEFINES_H
00036 #define _AFS_DEFINES_H
00037 //
00038 // File: AFSDefines.h
00039 //
00040 
00041 //
00042 // Conditional compiled code
00043 //
00044 
00045 //#define AFS_FLUSH_PAGES_SYNCHRONOUSLY       1       // Flush pages as we mark them dirty
00046 
00047 //
00048 // Debug information
00049 //
00050 
00051 #if DBG
00052 
00053 //#define AFS_VALIDATE_EXTENTS            0
00054 
00055 #define GEN_MD5 0
00056 
00057 #else
00058 
00059 #endif
00060 
00061 //
00062 // For 2K support
00063 //
00064 
00065 #ifndef FsRtlSetupAdvancedHeader
00066 
00067 #define FSRTL_FLAG_ADVANCED_HEADER              (0x40)
00068 #define FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS    (0x02)
00069 
00070 #define FsRtlSetupAdvancedHeader( _advhdr, _fmutx )                         \
00071 {                                                                           \
00072     SetFlag( (_advhdr)->Flags, FSRTL_FLAG_ADVANCED_HEADER );                \
00073     SetFlag( (_advhdr)->Flags2, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS );     \
00074     InitializeListHead( &(_advhdr)->FilterContexts );                       \
00075     if ((_fmutx) != NULL) {                                                 \
00076         (_advhdr)->FastMutex = (_fmutx);                                    \
00077     }                                                                       \
00078 }
00079 
00080 #endif
00081 
00082 typedef
00083 NTSTATUS
00084 (*PAFSRtlSetSaclSecurityDescriptor)( PSECURITY_DESCRIPTOR SecurityDescriptor,
00085                                      BOOLEAN SaclPresent,
00086                                      PACL Sacl,
00087                                      BOOLEAN SaclDefaulted);
00088 
00089 typedef
00090 NTSTATUS
00091 (*PAFSRtlSetGroupSecurityDescriptor)( IN PSECURITY_DESCRIPTOR  SecurityDescriptor,
00092                                       IN PSID  Group  OPTIONAL,
00093                                       IN BOOLEAN  GroupDefaulted);
00094 
00095 //
00096 // Worker thread count
00097 //
00098 
00099 #define AFS_WORKER_COUNT        16
00100 #define AFS_IO_WORKER_COUNT     8
00101 
00102 //
00103 // Worker thread states
00104 //
00105 
00106 #define AFS_WORKER_INITIALIZED                  0x0001
00107 #define AFS_WORKER_PROCESS_REQUESTS             0x0002
00108 
00109 //
00110 // Worker Thread codes
00111 //
00112 
00113 #define AFS_WORK_UNUSED_1                       0x0001
00114 #define AFS_WORK_FLUSH_FCB                      0x0002
00115 #define AFS_WORK_UNUSED_3                       0x0003
00116 #define AFS_WORK_UNUSED_4                       0x0004
00117 #define AFS_WORK_UNUSED_5                       0x0005
00118 #define AFS_WORK_ENUMERATE_GLOBAL_ROOT          0x0006
00119 #define AFS_WORK_INVALIDATE_OBJECT              0x0007
00120 #define AFS_WORK_START_IOS                      0x0008
00121 
00122 //
00123 // Worker request flags
00124 //
00125 
00126 #define AFS_SYNCHRONOUS_REQUEST                 0x00000001
00127 
00128 //
00129 // Fcb flags
00130 //
00131 
00132 #define AFS_FCB_FLAG_FILE_MODIFIED                           0x00000001
00133 #define AFS_FCB_FILE_CLOSED                                  0x00000002
00134 #define AFS_FCB_FLAG_UPDATE_WRITE_TIME                       0x00000004
00135 #define AFS_FCB_FLAG_UPDATE_CHANGE_TIME                      0x00000008
00136 #define AFS_FCB_FLAG_UPDATE_ACCESS_TIME                      0x00000010
00137 #define AFS_FCB_FLAG_UPDATE_CREATE_TIME                      0x00000020
00138 #define AFS_FCB_FLAG_UPDATE_LAST_WRITE_TIME                  0x00000040
00139 #define AFS_FCB_FLAG_PURGE_ON_CLOSE                          0x00000080
00140 
00141 //
00142 // Object information flags
00143 //
00144 
00145 #define AFS_OBJECT_FLAGS_OBJECT_INVALID                 0x00000001
00146 #define AFS_OBJECT_FLAGS_VERIFY                         0x00000002
00147 #define AFS_OBJECT_FLAGS_NOT_EVALUATED                  0x00000004
00148 #define AFS_OBJECT_FLAGS_DIRECTORY_ENUMERATED           0x00000008
00149 #define AFS_OBJECT_FLAGS_DELETED                        0x00000010
00150 #define AFS_OBJECT_INSERTED_HASH_TREE                   0x00000020
00151 #define AFS_OBJECT_INSERTED_VOLUME_LIST                 0x00000040
00152 #define AFS_OBJECT_HELD_IN_SERVICE                      0x00000080
00153 #define AFS_OBJECT_ROOT_VOLUME                          0x00000100
00154 #define AFS_OBJECT_FLAGS_VERIFY_DATA                    0x00000200
00155 
00156 //
00157 // Define one second in terms of 100 nS units
00158 //
00159 
00160 #define AFS_ONE_SECOND          10000000
00161 #define AFS_ONE_MILLISECOND     10000
00162 #define AFS_ONE_MICROSECOND     10
00163 
00164 //
00165 // Fcb lifetime in seconds
00166 //
00167 
00168 #define AFS_OBJECT_LIFETIME             600 * AFS_ONE_SECOND
00169 
00170 #define AFS_EXTENT_REQUEST_TIME         10 * AFS_ONE_SECOND
00171 
00172 //
00173 // How big to make the runs
00174 //
00175 #define AFS_MAX_STACK_IO_RUNS              5
00176 
00177 #ifndef FlagOn
00178 #define FlagOn(_F,_SF)        ((_F) & (_SF))
00179 #endif
00180 
00181 #ifndef BooleanFlagOn
00182 #define BooleanFlagOn(F,SF)   ((BOOLEAN)(((F) & (SF)) != 0))
00183 #endif
00184 
00185 #ifndef SetFlag
00186 #define SetFlag(_F,_SF)       ((_F) |= (_SF))
00187 #endif
00188 
00189 #ifndef ClearFlag
00190 #define ClearFlag(_F,_SF)     ((_F) &= ~(_SF))
00191 #endif
00192 
00193 #define QuadAlign(Ptr) (                \
00194     ((((ULONG)(Ptr)) + 7) & 0xfffffff8) \
00195     )
00196 
00197 #define CRC32_POLYNOMIAL     0xEDB88320L;
00198 
00199 #define AFS_SERVER_FLUSH_DELAY  (5LL * AFS_ONE_SECOND)
00200 #define AFS_SERVER_PURGE_DELAY  (300LL * AFS_ONE_SECOND)
00201 //
00202 // PURGE_SLEEP is the number of PURGE_DELAYS we wait before we will unilaterally
00203 // give back extents.
00204 //
00205 // If the Service asks us, we will start at PURGE_SLEEP of delays and then work back
00206 //
00207 #define AFS_SERVER_PURGE_SLEEP  6
00208 
00209 #define AFS_DIR_ENUM_BUFFER_LEN   (16 * 1024)
00210 
00211 //
00212 // IS_BYTE_OFFSET_WRITE_TO_EOF
00213 // liOffset - should be from Irp.StackLocation.Parameters.Write.ByteOffset
00214 // this macro checks to see if the Offset Large_Integer points to the
00215 // special constant value which denotes to start the write at EndOfFile
00216 //
00217 #define IS_BYTE_OFFSET_WRITE_TO_EOF(liOffset) \
00218     (((liOffset).LowPart == FILE_WRITE_TO_END_OF_FILE) \
00219       && ((liOffset).HighPart == 0xFFFFFFFF))
00220 
00221 //
00222 // Ccb Directory enum flags
00223 //
00224 
00225 #define CCB_FLAG_DIR_OF_DIRS_ONLY           0x00000001
00226 #define CCB_FLAG_FULL_DIRECTORY_QUERY       0x00000002
00227 #define CCB_FLAG_MASK_CONTAINS_WILD_CARDS   0x00000004
00228 #define CCB_FLAG_FREE_FULL_PATHNAME         0x00000008
00229 #define CCB_FLAG_RETURN_RELATIVE_ENTRIES    0x00000010
00230 #define CCB_FLAG_DIRECTORY_QUERY_MAPPED     0x00000020
00231 #define CCB_FLAG_MASK_PIOCTL_QUERY          0x00000040
00232 #define CCB_FLAG_MASK_OPENED_REPARSE_POINT  0x00000080
00233 #define CCB_FLAG_INSERTED_CCB_LIST          0x00000100
00234 
00235 //
00236 // DirEntry flags
00237 //
00238 
00239 #define AFS_DIR_RELEASE_NAME_BUFFER             0x00000001
00240 
00241 #define AFS_DIR_ENTRY_CASE_INSENSTIVE_LIST_HEAD 0x00000004
00242 #define AFS_DIR_ENTRY_NOT_IN_PARENT_TREE        0x00000008
00243 #define AFS_DIR_ENTRY_INSERTED_ENUM_LIST        0x00000010
00244 #define AFS_DIR_ENTRY_FAKE                      0x00000020
00245 #define AFS_DIR_RELEASE_TARGET_NAME_BUFFER      0x00000040
00246 #define AFS_DIR_ENTRY_VALID                     0x00000080
00247 #define AFS_DIR_ENTRY_PENDING_DELETE            0x00000100
00248 #define AFS_DIR_ENTRY_DELETED                   0x00000200
00249 #define AFS_DIR_ENTRY_SERVER_SERVICE            0x00000400
00250 #define AFS_DIR_ENTRY_WORKSTATION_SERVICE       0x00000800
00251 #define AFS_DIR_ENTRY_IPC                       0x00001000
00252 #define AFS_DIR_ENTRY_INSERTED_SHORT_NAME       0x00002000
00253 
00254 //
00255 // Network provider errors
00256 //
00257 
00258 #define WN_SUCCESS                              0L
00259 #define WN_ALREADY_CONNECTED                    85L
00260 #define WN_OUT_OF_MEMORY                        8L
00261 #define WN_NOT_CONNECTED                        2250L
00262 #define WN_BAD_NETNAME                          67L
00263 
00264 #define RESOURCE_CONNECTED      0x00000001
00265 #define RESOURCE_GLOBALNET      0x00000002
00266 #define RESOURCE_REMEMBERED     0x00000003
00267 #define RESOURCE_RECENT         0x00000004
00268 #define RESOURCE_CONTEXT        0x00000005
00269 
00270 #define RESOURCETYPE_ANY        0x00000000
00271 #define RESOURCETYPE_DISK       0x00000001
00272 #define RESOURCETYPE_PRINT      0x00000002
00273 #define RESOURCETYPE_RESERVED   0x00000008
00274 #define RESOURCETYPE_UNKNOWN    0xFFFFFFFF
00275 
00276 #define RESOURCEUSAGE_CONNECTABLE   0x00000001
00277 #define RESOURCEUSAGE_CONTAINER     0x00000002
00278 #define RESOURCEUSAGE_NOLOCALDEVICE 0x00000004
00279 #define RESOURCEUSAGE_SIBLING       0x00000008
00280 #define RESOURCEUSAGE_ATTACHED      0x00000010
00281 #define RESOURCEUSAGE_ALL           (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED)
00282 #define RESOURCEUSAGE_RESERVED      0x80000000
00283 
00284 #define RESOURCEDISPLAYTYPE_GENERIC        0x00000000
00285 #define RESOURCEDISPLAYTYPE_DOMAIN         0x00000001
00286 #define RESOURCEDISPLAYTYPE_SERVER         0x00000002
00287 #define RESOURCEDISPLAYTYPE_SHARE          0x00000003
00288 #define RESOURCEDISPLAYTYPE_FILE           0x00000004
00289 #define RESOURCEDISPLAYTYPE_GROUP          0x00000005
00290 #define RESOURCEDISPLAYTYPE_NETWORK        0x00000006
00291 #define RESOURCEDISPLAYTYPE_ROOT           0x00000007
00292 #define RESOURCEDISPLAYTYPE_SHAREADMIN     0x00000008
00293 #define RESOURCEDISPLAYTYPE_DIRECTORY      0x00000009
00294 #define RESOURCEDISPLAYTYPE_TREE           0x0000000A
00295 #define RESOURCEDISPLAYTYPE_NDSCONTAINER   0x0000000B
00296 
00297 //
00298 // Method for determining the different control device open requests
00299 //
00300 
00301 #define AFS_CONTROL_INSTANCE            0x00000001
00302 #define AFS_REDIRECTOR_INSTANCE         0x00000002
00303 
00304 //
00305 // Extent flags
00306 //
00307 
00308 #define AFS_EXTENT_DIRTY                0x00000001
00309 
00310 //
00311 // Extent skip list sizes
00312 //
00313 #define AFS_NUM_EXTENT_LISTS    3
00314 
00315 //
00316 // Extents skip lists
00317 //
00318 // We use constant sizes.
00319 //
00320 #define AFS_EXTENT_SIZE         (4*1024)
00321 #define AFS_EXTENTS_LIST        0
00322 //
00323 // A max of 64 extents in ther first skip list
00324 #define AFS_EXTENT_SKIP1_BITS   6
00325 
00326 //
00327 // Then 128 bits in the second skip list
00328 #define AFS_EXTENT_SKIP2_BITS   7
00329 
00330 //
00331 // This means that the top list skips in steps of 2^25 (=12+6+7) which
00332 // is 32 Mb.  It is to be expected that files which are massively
00333 // larger that this will not be fully mapped.
00334 //
00335 #define AFS_EXTENT_SKIP1_SIZE (AFS_EXTENT_SIZE << AFS_EXTENT_SKIP1_BITS)
00336 #define AFS_EXTENT_SKIP2_SIZE (AFS_EXTENT_SKIP1_SIZE << AFS_EXTENT_SKIP2_BITS)
00337 
00338 #define AFS_EXTENTS_MASKS { (AFS_EXTENT_SIZE-1),       \
00339                             (AFS_EXTENT_SKIP1_SIZE-1), \
00340                             (AFS_EXTENT_SKIP2_SIZE-1) }
00341 
00342 //
00343 // Maximum count to release at a time
00344 //
00345 
00346 #define AFS_MAXIMUM_EXTENT_RELEASE_COUNT        100
00347 
00348 #define AFS_DIRTY_CHUNK_THRESHOLD               2
00349 
00350 // {41966169-3FD7-4392-AFE4-E6A9D0A92C72}  - generated using guidgen.exe
00351 DEFINE_GUID (GUID_SD_AFS_REDIRECTOR_CONTROL_OBJECT,
00352         0x41966169, 0x3fd7, 0x4392, 0xaf, 0xe4, 0xe6, 0xa9, 0xd0, 0xa9, 0x2c, 0x72);
00353 
00354 //
00355 // Debug log length
00356 //
00357 
00358 #define AFS_DBG_LOG_LENGTH              256
00359 
00360 //
00361 // Debug log flags
00362 //
00363 
00364 #define AFS_DBG_LOG_WRAPPED             0x00000001
00365 
00366 //
00367 // Connection flags
00368 //
00369 
00370 #define AFS_CONNECTION_FLAG_GLOBAL_SHARE        0x00000001
00371 
00372 //
00373 // Process CB flags
00374 //
00375 
00376 #define AFS_PROCESS_FLAG_IS_64BIT           0x00000001
00377 
00378 //
00379 // Maximum number of special share names
00380 //
00381 
00382 #define AFS_SPECIAL_SHARE_NAME_COUNT_MAX    10
00383 
00384 //
00385 // Name Array flags
00386 //
00387 
00388 #define AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT        0x00000001
00389 #define AFS_NAME_ARRAY_FLAG_REDIRECTION_ELEMENT 0x00000002
00390 
00391 //
00392 // Maximum recursion depth
00393 //
00394 
00395 #define AFS_MAX_RECURSION_COUNT                 20
00396 
00397 //
00398 // LocateNameEntry flags
00399 //
00400 
00401 #define AFS_LOCATE_FLAGS_SUBSTITUTE_NAME        0x00000001
00402 #define AFS_LOCATE_FLAGS_NO_MP_TARGET_EVAL      0x00000002
00403 #define AFS_LOCATE_FLAGS_NO_SL_TARGET_EVAL      0x00000004
00404 #define AFS_LOCATE_FLAGS_NO_DFS_LINK_EVAL       0x00000008
00405 
00406 //
00407 // Parse flags
00408 //
00409 
00410 #define AFS_PARSE_FLAG_FREE_FILE_BUFFER         0x00000001
00411 #define AFS_PARSE_FLAG_ROOT_ACCESS              0x00000002
00412 
00413 //
00414 // Reparse tag information
00415 //
00416 
00417 //
00418 //  Tag allocated to OpenAFS for DFS by Microsoft
00419 //  GUID: EF21A155-5C92-4470-AB3B-370403D96369
00420 //
00421 
00422 #ifndef IO_REPARSE_TAG_OPENAFS_DFS
00423 #define IO_REPARSE_TAG_OPENAFS_DFS              0x00000037L
00424 #endif
00425 
00426 #ifndef IO_REPARSE_TAG_SURROGATE
00427 #define IO_REPARSE_TAG_SURROGATE                0x20000000L
00428 #endif
00429 
00430 //  {EF21A155-5C92-4470-AB3B-370403D96369}
00431 DEFINE_GUID (GUID_AFS_REPARSE_GUID,
00432         0xEF21A155, 0x5C92, 0x4470, 0xAB, 0x3B, 0x37, 0x04, 0x03, 0xD9, 0x63, 0x69);
00433 
00434 //
00435 // Enumeration constants
00436 //
00437 
00438 #define AFS_DIR_ENTRY_INITIAL_DIR_INDEX   (ULONG)-3
00439 #define AFS_DIR_ENTRY_INITIAL_ROOT_INDEX  (ULONG)-1
00440 
00441 #define AFS_DIR_ENTRY_PIOCTL_INDEX        (ULONG)-3
00442 #define AFS_DIR_ENTRY_DOT_INDEX           (ULONG)-2
00443 #define AFS_DIR_ENTRY_DOT_DOT_INDEX       (ULONG)-1
00444 
00445 //
00446 // Library state flags
00447 //
00448 
00449 #define AFS_REDIR_LIB_FLAGS_NONPERSISTENT_CACHE     0x00000001
00450 
00451 #endif /* _AFS_DEFINES_H */
 All Data Structures Files Functions Variables