Windows: Store OS version as a global
[openafs.git] / src / WINNT / afsrdr / kernel / lib / AFSInit.cpp
index b2a1df0..f25f5d5 100644 (file)
@@ -60,11 +60,9 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
 
     NTSTATUS ntStatus = STATUS_SUCCESS;
     AFSDeviceExt    *pDeviceExt;
-    ULONG ulTimeIncrement = 0;
     UNICODE_STRING uniDeviceName;
     ULONG ulIndex = 0;
     UNICODE_STRING uniRoutine;
-    RTL_OSVERSIONINFOW sysVersion;
 
     BOOLEAN bExit = FALSE;
 
@@ -117,12 +115,12 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
                        RegistryPath->Buffer,
                        RegistryPath->Length);
 
-        RtlZeroMemory( &sysVersion,
+       RtlZeroMemory( &AFSRtlSysVersion,
                        sizeof( RTL_OSVERSIONINFOW));
 
-        sysVersion.dwOSVersionInfoSize = sizeof( RTL_OSVERSIONINFOW);
+       AFSRtlSysVersion.dwOSVersionInfoSize = sizeof( RTL_OSVERSIONINFOW);
 
-        RtlGetVersion( &sysVersion);
+       RtlGetVersion( &AFSRtlSysVersion);
 
 #if 0
         //
@@ -140,7 +138,7 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
         // Mandatory Labels only exist on those operating systems.
         //
 
-        if( sysVersion.dwMajorVersion >= 6)
+       if( AFSRtlSysVersion.dwMajorVersion >= 6)
         {
             RtlInitUnicodeString( &uniRoutine,
                                   L"RtlSetSaclSecurityDescriptor");
@@ -148,6 +146,13 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
             AFSRtlSetSaclSecurityDescriptor = (PAFSRtlSetSaclSecurityDescriptor)MmGetSystemRoutineAddress( &uniRoutine);
         }
 
+#endif
+
+        RtlInitUnicodeString( &uniRoutine,
+                              L"RtlSetGroupSecurityDescriptor");
+
+        AFSRtlSetGroupSecurityDescriptor = (PAFSRtlSetGroupSecurityDescriptor)MmGetSystemRoutineAddress( &uniRoutine);
+
         ntStatus = AFSCreateDefaultSecurityDescriptor();
 
         if( !NT_SUCCESS( ntStatus))
@@ -157,9 +162,9 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
 
             ntStatus = STATUS_SUCCESS;
         }
-#endif
+
         //
-        // Initilize the control device
+        // Initialize the control device
         //
 
         RtlInitUnicodeString( &uniDeviceName,
@@ -168,7 +173,7 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
         ntStatus = IoCreateDevice( DriverObject,
                                    sizeof( AFSDeviceExt),
                                    &uniDeviceName,
-                                   FILE_DEVICE_DISK_FILE_SYSTEM,
+                                   FILE_DEVICE_NETWORK_FILE_SYSTEM,
                                    0,
                                    FALSE,
                                    &AFSLibraryDeviceObject);
@@ -200,18 +205,12 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
         }
 
         //
-        // Initialize the worker thread pool
+        // Initialize the worker thread pool counts.
         //
 
-        ntStatus = AFSInitializeWorkerPool();
+        pDeviceExt->Specific.Library.WorkerCount = 0;
 
-        if( !NT_SUCCESS( ntStatus))
-        {
-
-            AFSPrint("AFS DriverEntry Failed to initialize worker pool Status %08lX\n", ntStatus);
-
-            try_return( ntStatus);
-        }
+        pDeviceExt->Specific.Library.IOWorkerCount = 0;
 
         //
         // Fill in the dispatch table
@@ -258,16 +257,11 @@ try_exit:
 
             AFSPrint("AFSLibrary DriverEntry failed to initialize %08lX\n", ntStatus);
 
-            if( AFSLibraryDeviceObject != NULL)
-            {
-
-                AFSRemoveWorkerPool();
-            }
-
             if( AFSRegistryPath.Buffer != NULL)
             {
 
-                ExFreePool( AFSRegistryPath.Buffer);
+               AFSLibExFreePoolWithTag( AFSRegistryPath.Buffer,
+                                        AFS_GENERIC_MEMORY_13_TAG);
             }
 
             if( AFSLibraryDeviceObject != NULL)
@@ -279,10 +273,12 @@ try_exit:
             }
         }
     }
-    __except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
+    __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
     {
 
         AFSPrint( "EXCEPTION - AFS DriverEntry\n");
+
+        AFSDumpTraceFilesFnc();
     }
 
     return ntStatus;
@@ -292,6 +288,7 @@ void
 AFSUnload( IN PDRIVER_OBJECT DriverObject)
 {
 
+    UNREFERENCED_PARAMETER(DriverObject);
     if( AFSGlobalRoot != NULL)
     {
 
@@ -312,14 +309,17 @@ AFSUnload( IN PDRIVER_OBJECT DriverObject)
     if( AFSRegistryPath.Buffer != NULL)
     {
 
-        ExFreePool( AFSRegistryPath.Buffer);
+       AFSLibExFreePoolWithTag( AFSRegistryPath.Buffer,
+                                AFS_GENERIC_MEMORY_13_TAG);
     }
 
     AFSCloseLibrary();
 
     if( AFSDefaultSD != NULL)
     {
-        ExFreePool( AFSDefaultSD);
+
+       AFSLibExFreePoolWithTag( AFSDefaultSD,
+                                AFS_GENERIC_MEMORY_27_TAG);
     }
 
     if( AFSLibraryDeviceObject != NULL)