+general captive shutdown
authorshort <>
Sat, 1 Feb 2003 00:07:01 +0000 (00:07 +0000)
committershort <>
Sat, 1 Feb 2003 00:07:01 +0000 (00:07 +0000)
 - +IoShutdownRegisteredFileSystems()
IoShutdownRegisteredFileSystems(): Fixed 'FileSystemListHead' walk corruption
+IoUnregisterFileSystem()

ntoskrnl/io/fs.c

index 26947a8..b96750b 100644 (file)
@@ -174,7 +174,6 @@ IoInitFileSystemImplementation(VOID)
 #endif /* LIBCAPTIVE */
 }
 
-#ifndef LIBCAPTIVE
 
 VOID
 IoShutdownRegisteredFileSystems(VOID)
@@ -189,11 +188,15 @@ IoShutdownRegisteredFileSystems(VOID)
 
    DPRINT("IoShutdownRegisteredFileSystems()\n");
 
+#ifndef LIBCAPTIVE
+   /* filesystems cannot be called at DISPATCH_LEVEL */
    KeAcquireSpinLock(&FileSystemListLock,&oldlvl);
+#endif /* LIBCAPTIVE */
    KeInitializeEvent(&Event,NotificationEvent,FALSE);
 
-   current_entry = FileSystemListHead.Flink;
-   while (current_entry!=(&FileSystemListHead))
+   /* 'current' will get IoDeleteDevice()ed by IRP_MJ_SHUTDOWN! */
+   /* FIXME: deadlock loop detection */
+   while ((current_entry = FileSystemListHead.Flink)!=(&FileSystemListHead))
      {
        current = CONTAINING_RECORD(current_entry,FILE_SYSTEM_OBJECT,Entry);
 
@@ -211,14 +214,14 @@ IoShutdownRegisteredFileSystems(VOID)
          {
             KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
          }
-
-       current_entry = current_entry->Flink;
      }
 
+#ifndef LIBCAPTIVE
+   /* filesystems cannot be called at DISPATCH_LEVEL */
    KeReleaseSpinLock(&FileSystemListLock,oldlvl);
+#endif /* LIBCAPTIVE */
 }
 
-#endif /* LIBCAPTIVE */
 
 static NTSTATUS
 IopMountFileSystem(PDEVICE_OBJECT DeviceObject,
@@ -587,7 +590,6 @@ IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
 #endif /* LIBCAPTIVE */
 }
 
-#ifndef LIBCAPTIVE
 
 VOID STDCALL
 IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
@@ -608,7 +610,9 @@ IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
          RemoveEntryList(current_entry);
          ExFreePool(current);
          KeReleaseSpinLock(&FileSystemListLock,oldlvl);
+#ifndef LIBCAPTIVE
          IopNotifyFileSystemChange(DeviceObject, FALSE);
+#endif /* LIBCAPTIVE */
          return;
        }
       current_entry = current_entry->Flink;
@@ -617,6 +621,8 @@ IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
 }
 
 
+#ifndef LIBCAPTIVE
+
 /**********************************************************************
  * NAME                                                        EXPORTED
  *     IoGetBaseFileSystemDeviceObject@4