captive_shared_cache_map_data_validate_read(): Fixed validated mem to 'clean'.
authorshort <>
Sun, 5 Oct 2003 20:28:49 +0000 (20:28 +0000)
committershort <>
Sun, 5 Oct 2003 20:28:49 +0000 (20:28 +0000)
captive_shared_cache_map_purge(): Flush the buffers to disk.
 - Needed for FAT32 by fastfat.sys of NT-5.1sp1.

src/libcaptive/cc/sharedcachemap.c

index 6dec135..46440b9 100644 (file)
@@ -420,6 +420,7 @@ ULONG got;
                        g_assert(got<=PAGE_SIZE);
                after_eof=(got<PAGE_SIZE);
                captive_shared_cache_map_object->pages[now/PAGE_SIZE].data_valid=TRUE;
+               captive_shared_cache_map_object->pages[now/PAGE_SIZE].dirty=FALSE;
                }
 }
 
@@ -462,6 +463,7 @@ guint64 now;
 
        for (now=start;now<end;now+=PAGE_SIZE) {
                captive_shared_cache_map_object->pages[now/PAGE_SIZE].data_valid=TRUE;
+               /* .dirty is undefined */
                }
 }
 
@@ -532,11 +534,18 @@ CaptiveSharedCacheMapObject_page *page;
 
        g_signal_emit(captive_shared_cache_map_object,purge_signal,0);
 
+       /* Needed by fastfat.sys of NT-5.1sp1 during FAT32 unmount
+        * otherwise it fails on: g_assert(!page->dirty);
+        * It corrupts the disk if the buffer is dropped instead.
+        */
+       captive_shared_cache_map_flush(captive_shared_cache_map_object,
+                       0,CAPTIVE_ROUND_UP64(captive_shared_cache_map_object->AllocationSize,PAGE_SIZE));
+
        for (offset=0;offset<CAPTIVE_ROUND_UP64(captive_shared_cache_map_object->AllocationSize,PAGE_SIZE);offset+=PAGE_SIZE) {
                page=captive_shared_cache_map_object->pages+offset/PAGE_SIZE;
                if (!page->data_valid)
                        continue;
-               g_assert(!page->dirty); /* FIXME: Is it allowed by W32? */
+               g_assert(!page->dirty);
                page->data_valid=FALSE;
                }
 }