Windows: addition debug for --validate-cache
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 4 Dec 2012 21:56:21 +0000 (16:56 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Wed, 5 Dec 2012 20:15:25 +0000 (12:15 -0800)
Print the value of the header size, the magic value and the
dirty flag.

Fail check if header size and magic do not match current
version of afsd_service.exe

Change-Id: I19c9a374a5f83dd9fcb37990c4dfbb97cf7f74a0
Reviewed-on: http://gerrit.openafs.org/8602
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsd/cm_memmap.c

index e9fc2e9..8eaf59e 100644 (file)
@@ -369,6 +369,24 @@ cm_ValidateMappedMemory(char * cachePath)
         return CM_ERROR_INVAL;
     }
 
+    if ( config_data_p->size != sizeof(cm_config_data_t) ) {
+        fprintf(stderr, "AFSCache Header Size 0x%08X != afsd_service Header Size 0x%08X\n",
+                config_data_p->size, sizeof(cm_config_data_t));
+        UnmapViewOfFile(config_data_p);
+        CloseHandle(hm);
+        CloseHandle(hf);
+        return CM_ERROR_INVAL;
+    }
+
+    if ( config_data_p->magic != CM_CONFIG_DATA_MAGIC ) {
+        fprintf(stderr, "AFSCache Magic 0x%08X != afsd_service Magic 0x%08X\n",
+                config_data_p->magic, CM_CONFIG_DATA_MAGIC);
+        UnmapViewOfFile(config_data_p);
+        CloseHandle(hm);
+        CloseHandle(hf);
+        return CM_ERROR_INVAL;
+    }
+
     if ( config_data_p->dirty ) {
         fprintf(stderr, "Previous session terminated prematurely\n");
         UnmapViewOfFile(config_data_p);
@@ -429,12 +447,15 @@ cm_ValidateMappedMemory(char * cachePath)
     config_data_p = (cm_config_data_t *) baseAddress;
 
     fprintf(stderr,"AFS Cache data:\n");
-    fprintf(stderr,"  Base Address   = %p\n",baseAddress);
+    fprintf(stderr,"  Header size    = %u\n", config_data_p->size);
+    fprintf(stderr,"  Magic          = %08x\n", config_data_p->magic);
+    fprintf(stderr,"  Base Address   = %p\n", baseAddress);
     fprintf(stderr,"  stats          = %u\n", config_data_p->stats);
     fprintf(stderr,"  chunkSize      = %u\n", config_data_p->chunkSize);
     fprintf(stderr,"  blockSize      = %u\n", config_data_p->blockSize);
     fprintf(stderr,"  bufferSize     = %I64u\n", config_data_p->bufferSize);
     fprintf(stderr,"  cacheType      = %u\n", config_data_p->cacheType);
+    fprintf(stderr,"  dirty          = %u\n", config_data_p->dirty);
     fprintf(stderr,"  volumeHashTableSize = %u\n", config_data_p->volumeHashTableSize);
     fprintf(stderr,"  currentVolumes = %u\n", config_data_p->currentVolumes);
     fprintf(stderr,"  maxVolumes     = %u\n", config_data_p->maxVolumes);