IoShutdownRegisteredFileSystems(): Protected against broken filesystems
authorshort <>
Mon, 10 Feb 2003 10:08:15 +0000 (10:08 +0000)
committershort <>
Mon, 10 Feb 2003 10:08:15 +0000 (10:08 +0000)
 - such as ext2fsd.sys not calling IoUnregisterFileSystem()

ntoskrnl/io/fs.c

index b96750b..fa340d8 100644 (file)
@@ -180,7 +180,7 @@ IoShutdownRegisteredFileSystems(VOID)
 {
    KIRQL oldlvl;
    PLIST_ENTRY current_entry;
-   FILE_SYSTEM_OBJECT* current;
+   FILE_SYSTEM_OBJECT* current,*current_last=NULL;
    PIRP Irp;
    KEVENT Event;
    IO_STATUS_BLOCK IoStatusBlock;
@@ -195,10 +195,12 @@ IoShutdownRegisteredFileSystems(VOID)
    KeInitializeEvent(&Event,NotificationEvent,FALSE);
 
    /* '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);
+       if (current==current_last)
+           KeBugCheck(0);      /* filesystem forgot to call IoUnregisterFileSystem() */
+       current_last=current;
 
        /* send IRP_MJ_SHUTDOWN */
        Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN,