OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/WINNT/afsrdr/kernel/fs/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 // Registry names
00043 //
00044 
00045 #define AFS_REG_DEBUG_FLAGS              L"DebugFlags"
00046 #define AFS_REG_TRACE_LEVEL              L"TraceLevel"
00047 #define AFS_REG_TRACE_SUBSYSTEM          L"TraceSubsystem"
00048 #define AFS_REG_TRACE_BUFFER_LENGTH      L"TraceBufferSize"  // in KB
00049 #define AFS_REG_MAX_DIRTY                L"MaxDirtyMb"
00050 #define AFS_REG_MAX_IO                   L"MaxIOMb"
00051 #define AFS_NETBIOS_NAME                 L"NetbiosName"
00052 #define AFS_REG_SHUTDOWN_STATUS          L"ShutdownStatus"
00053 #define AFS_REG_REQUIRE_CLEAN_SHUTDOWN   L"RequireCleanShutdown"
00054 
00055 //
00056 // Control Device name
00057 //
00058 
00059 #define AFS_CONTROL_DEVICE_NAME     L"\\Device\\AFSControlDevice"
00060 #define AFS_SYMLINK_NAME            L"\\??\\AFSRedirector"
00061 
00062 //
00063 // How big to make the runs
00064 //
00065 #define AFS_MAX_STACK_IO_RUNS              5
00066 
00067 #ifndef FlagOn
00068 #define FlagOn(_F,_SF)        ((_F) & (_SF))
00069 #endif
00070 
00071 #ifndef BooleanFlagOn
00072 #define BooleanFlagOn(F,SF)   ((BOOLEAN)(((F) & (SF)) != 0))
00073 #endif
00074 
00075 #ifndef SetFlag
00076 #define SetFlag(_F,_SF)       ((_F) |= (_SF))
00077 #endif
00078 
00079 #ifndef ClearFlag
00080 #define ClearFlag(_F,_SF)     ((_F) &= ~(_SF))
00081 #endif
00082 
00083 #define QuadAlign(Ptr) (                \
00084     ((((ULONG)(Ptr)) + 7) & 0xfffffff8) \
00085     )
00086 
00087 #define CRC32_POLYNOMIAL     0xEDB88320L;
00088 
00089 //
00090 // Define one second in terms of 100 nS units
00091 //
00092 
00093 #define AFS_ONE_SECOND          10000000
00094 
00095 #define AFS_SERVER_FLUSH_DELAY  30
00096 #define AFS_SERVER_PURGE_DELAY  60
00097 //
00098 // PURGE_SLEEP is the number of PURGE_DELAYS we wait before we will unilaterally
00099 // give back extents.
00100 //
00101 // If the Service asks us, we will start at PURGE_SLEEP of delays and then work back
00102 //
00103 #define AFS_SERVER_PURGE_SLEEP  6
00104 
00105 //
00106 // Read ahead granularity
00107 //
00108 
00109 #define READ_AHEAD_GRANULARITY      0x10000     // 64KB
00110 
00111 #define AFS_DIR_ENUM_BUFFER_LEN   (16 * 1024)
00112 
00113 //
00114 // IS_BYTE_OFFSET_WRITE_TO_EOF
00115 // liOffset - should be from Irp.StackLocation.Parameters.Write.ByteOffset
00116 // this macro checks to see if the Offset Large_Integer points to the
00117 // special constant value which denotes to start the write at EndOfFile
00118 //
00119 #define IS_BYTE_OFFSET_WRITE_TO_EOF(liOffset) \
00120     (((liOffset).LowPart == FILE_WRITE_TO_END_OF_FILE) \
00121       && ((liOffset).HighPart == 0xFFFFFFFF))
00122 
00123 //
00124 // Ccb Directory enum flags
00125 //
00126 
00127 #define CCB_FLAG_DIR_OF_DIRS_ONLY           0x00000001
00128 #define CCB_FLAG_FULL_DIRECTORY_QUERY       0x00000002
00129 #define CCB_FLAG_MASK_CONTAINS_WILD_CARDS   0x00000004
00130 #define CCB_FLAG_FREE_FULL_PATHNAME         0x00000008
00131 #define CCB_FLAG_RETURN_RELATIVE_ENTRIES    0x00000010
00132 #define CCB_FLAGS_DIRECTORY_QUERY_MAPPED    0x00000020
00133 
00134 //
00135 // DirEntry flags
00136 //
00137 
00138 #define AFS_DIR_RELEASE_NAME_BUFFER             0x00000001
00139 #define AFS_DIR_ENTRY_CASE_INSENSTIVE_LIST_HEAD 0x00000004
00140 #define AFS_DIR_ENTRY_NOT_IN_PARENT_TREE        0x00000008
00141 // Use this entry
00142 #define AFS_DIR_ENTRY_FAKE                      0x00000020
00143 #define AFS_DIR_RELEASE_TARGET_NAME_BUFFER      0x00000040
00144 #define AFS_DIR_ENTRY_VALID                     0x00000080
00145 #define AFS_DIR_ENTRY_PENDING_DELETE            0x00000100
00146 #define AFS_DIR_ENTRY_DELETED                   0x00000200
00147 #define AFS_DIR_ENTRY_SERVER_SERVICE            0x00000400
00148 #define AFS_DIR_ENTRY_WORKSTATION_SERVICE       0x00000800
00149 #define AFS_DIR_ENTRY_IPC                       0x00001000
00150 
00151 //
00152 // Network provider errors
00153 //
00154 
00155 #define WN_SUCCESS                              0L
00156 #define WN_ALREADY_CONNECTED                    85L
00157 #define WN_OUT_OF_MEMORY                        8L
00158 #define WN_NOT_CONNECTED                        2250L
00159 #define WN_BAD_NETNAME                          67L
00160 
00161 #define RESOURCE_CONNECTED      0x00000001
00162 #define RESOURCE_GLOBALNET      0x00000002
00163 #define RESOURCE_REMEMBERED     0x00000003
00164 #define RESOURCE_RECENT         0x00000004
00165 #define RESOURCE_CONTEXT        0x00000005
00166 
00167 #define RESOURCETYPE_ANY        0x00000000
00168 #define RESOURCETYPE_DISK       0x00000001
00169 #define RESOURCETYPE_PRINT      0x00000002
00170 #define RESOURCETYPE_RESERVED   0x00000008
00171 #define RESOURCETYPE_UNKNOWN    0xFFFFFFFF
00172 
00173 #define RESOURCEUSAGE_CONNECTABLE   0x00000001
00174 #define RESOURCEUSAGE_CONTAINER     0x00000002
00175 #define RESOURCEUSAGE_NOLOCALDEVICE 0x00000004
00176 #define RESOURCEUSAGE_SIBLING       0x00000008
00177 #define RESOURCEUSAGE_ATTACHED      0x00000010
00178 #define RESOURCEUSAGE_ALL           (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED)
00179 #define RESOURCEUSAGE_RESERVED      0x80000000
00180 
00181 #define RESOURCEDISPLAYTYPE_GENERIC        0x00000000
00182 #define RESOURCEDISPLAYTYPE_DOMAIN         0x00000001
00183 #define RESOURCEDISPLAYTYPE_SERVER         0x00000002
00184 #define RESOURCEDISPLAYTYPE_SHARE          0x00000003
00185 #define RESOURCEDISPLAYTYPE_FILE           0x00000004
00186 #define RESOURCEDISPLAYTYPE_GROUP          0x00000005
00187 #define RESOURCEDISPLAYTYPE_NETWORK        0x00000006
00188 #define RESOURCEDISPLAYTYPE_ROOT           0x00000007
00189 #define RESOURCEDISPLAYTYPE_SHAREADMIN     0x00000008
00190 #define RESOURCEDISPLAYTYPE_DIRECTORY      0x00000009
00191 #define RESOURCEDISPLAYTYPE_TREE           0x0000000A
00192 #define RESOURCEDISPLAYTYPE_NDSCONTAINER   0x0000000B
00193 
00194 //
00195 // Method for determining the different control device open requests
00196 //
00197 
00198 #define AFS_CONTROL_INSTANCE            0x00000001
00199 #define AFS_REDIRECTOR_INSTANCE         0x00000002
00200 
00201 //
00202 // Extent flags
00203 //
00204 
00205 #define AFS_EXTENT_DIRTY                0x00000001
00206 
00207 //
00208 // Extent skip list sizes
00209 //
00210 #define AFS_NUM_EXTENT_LISTS    3
00211 
00212 //
00213 // Extents skip lists
00214 //
00215 // We use constant sizes.
00216 //
00217 #define AFS_EXTENT_SIZE         (4*1024)
00218 #define AFS_EXTENTS_LIST        0
00219 //
00220 // A max of 64 extents in ther first skip list
00221 #define AFS_EXTENT_SKIP1_BITS   6
00222 
00223 //
00224 // Then 128 bits in the second skip list
00225 #define AFS_EXTENT_SKIP2_BITS   7
00226 
00227 //
00228 // This means that the top list skips in steps of 2^25 (=12+6+7) which
00229 // is 32 Mb.  It is to be expected that files which are massively
00230 // larger that this will not be fully mapped.
00231 //
00232 #define AFS_EXTENT_SKIP1_SIZE (AFS_EXTENT_SIZE << AFS_EXTENT_SKIP1_BITS)
00233 #define AFS_EXTENT_SKIP2_SIZE (AFS_EXTENT_SKIP1_SIZE << AFS_EXTENT_SKIP2_BITS)
00234 
00235 #define AFS_EXTENTS_MASKS { (AFS_EXTENT_SIZE-1),       \
00236                             (AFS_EXTENT_SKIP1_SIZE-1), \
00237                             (AFS_EXTENT_SKIP2_SIZE-1) }
00238 
00239 //
00240 // Maximum count to release at a time
00241 //
00242 
00243 #define AFS_MAXIMUM_EXTENT_RELEASE_COUNT        100
00244 
00245 // {41966169-3FD7-4392-AFE4-E6A9D0A92C72}  - generated using guidgen.exe
00246 DEFINE_GUID (GUID_SD_AFS_REDIRECTOR_CONTROL_OBJECT,
00247         0x41966169, 0x3fd7, 0x4392, 0xaf, 0xe4, 0xe6, 0xa9, 0xd0, 0xa9, 0x2c, 0x72);
00248 
00249 //
00250 // Debug log length
00251 //
00252 
00253 #define AFS_DBG_LOG_LENGTH              256
00254 
00255 //
00256 // Debug log flags
00257 //
00258 
00259 #define AFS_DBG_LOG_WRAPPED             0x00000001
00260 
00261 //
00262 // Connection flags
00263 //
00264 
00265 #define AFS_CONNECTION_FLAG_GLOBAL_SHARE        0x00000001
00266 
00267 //
00268 // Process CB flags
00269 //
00270 
00271 #define AFS_PROCESS_FLAG_IS_64BIT           0x00000001
00272 #define AFS_PROCESS_FLAG_ACE_SET            0x00000002
00273 #define AFS_PROCESS_LOCAL_SYSTEM_AUTH       0x00000004
00274 
00275 //
00276 // Auth group flags
00277 //
00278 
00279 #define AFS_AUTHGROUP_ACTIVE_SESSION        0x00000001
00280 
00281 //
00282 // Maximum number of special share names
00283 //
00284 
00285 #define AFS_SPECIAL_SHARE_NAME_COUNT_MAX    10
00286 
00287 //
00288 // Reparse tag information
00289 //
00290 
00291 //
00292 //  Tag allocated to OpenAFS for DFS by Microsoft
00293 //  GUID: EF21A155-5C92-4470-AB3B-370403D96369
00294 //
00295 
00296 #ifndef IO_REPARSE_TAG_OPENAFS_DFS
00297 #define IO_REPARSE_TAG_OPENAFS_DFS              0x00000037L
00298 #endif
00299 
00300 //  {EF21A155-5C92-4470-AB3B-370403D96369}
00301 DEFINE_GUID (GUID_AFS_REPARSE_GUID,
00302         0xEF21A155, 0x5C92, 0x4470, 0xAB, 0x3B, 0x37, 0x04, 0x03, 0xD9, 0x63, 0x69);
00303 
00304 //
00305 // Enumeration constants
00306 //
00307 
00308 #define AFS_DIR_ENTRY_INITIAL_DIR_INDEX   (ULONG)-3
00309 #define AFS_DIR_ENTRY_INITIAL_ROOT_INDEX  (ULONG)-1
00310 
00311 #define AFS_DIR_ENTRY_DOT_INDEX           (ULONG)-2
00312 #define AFS_DIR_ENTRY_DOT_DOT_INDEX       (ULONG)-1
00313 
00314 //
00315 // Library flags
00316 //
00317 
00318 #define AFS_LIBRARY_LOADED                  0x00000001
00319 #define AFS_LIBRARY_QUEUE_CANCELLED         0x00000002
00320 
00321 //
00322 // Custom ACE Information
00323 //
00324 
00325 // {7E5D0E2F-7500-45df-857A-C0C8A2CC6BE8}
00326 static const GUID AFSSidGuid = { 0x7f5d0e2f, 0x7500, 0x45df, { 0x85, 0x7a, 0xc0, 0xc8, 0xa2, 0xcc, 0x6b, 0xe8 } };
00327 
00328 // size of our special DACL SID...  S-1-8-GuidDword1-GuidDword2-GuidDword3-GuidDword4-AuthGroupGUIDDword1-AuthGroupGUIDDword2-AuthGroupGUIDDword3-AuthGroupGUIDDword4
00329 // Revision (1) + SubAuthorityCount (1) + IdentifierAuthority (6) + GUID (16) + AuthGruopGUID( 16)
00330 #define AFS_DACL_SID_LENGTH 40
00331 
00332 typedef
00333 NTSTATUS
00334 (*PAFSSetInformationToken) (
00335     __in HANDLE TokenHandle,
00336     __in TOKEN_INFORMATION_CLASS TokenInformationClass,
00337     __in_bcount(TokenInformationLength) PVOID TokenInformation,
00338     __in ULONG TokenInformationLength
00339     );
00340 
00341 #endif /* _AFS_DEFINES_H */
 All Data Structures Files Functions Variables