flushonhibernate-registry-20041017
authorAsanka Herath <asanka@mit.edu>
Sun, 17 Oct 2004 22:02:01 +0000 (22:02 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 17 Oct 2004 22:02:01 +0000 (22:02 +0000)
Add a new FlushOnHibernate registry option to allow users to disable
the Power Management Flush support

src/WINNT/afsd/afsd_service.c
src/WINNT/afsd/cm_freelance.h

index c69da65..e260347 100644 (file)
@@ -55,6 +55,8 @@ jmp_buf notifier_jmp;
 extern int traceOnPanic;
 extern HANDLE afsi_file;
 
+int powerEventsRegsitered = 0;
+
 /*
  * Notifier function for use by osi_panic
  */
@@ -271,6 +273,7 @@ afsd_ServiceControlHandlerEx(
             ** Return any error code to deny request,                                        
             ** i.e. as if returning BROADCAST_QUERY_DENY                                     
             */                                                                                
+            if(powerEventsRegsitered) {
             switch((int) dwEventType)                                                         
             {                                                                               
             case PBT_APMQUERYSUSPEND:                                                         
@@ -492,8 +495,30 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
     }
 
 #ifdef REGISTER_POWER_NOTIFICATIONS
+    {
+        HKEY hkParm;
+        DWORD code;
+        DWORD dummyLen;
+        int bpower = TRUE;
+
+        /* see if we should handle power notifications */
+        code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, 0, KEY_QUERY_VALUE, &hkParm);
+        if(code == ERROR_SUCCESS) {
+            dummyLen = sizeof(bpower);
+            code = RegQueryValueEx(hkParm, "FlushOnHibernate", NULL, NULL,
+                (BYTE *) &bpower, &dummyLen);      
+
+            if(code != ERROR_SUCCESS)
+                bpower = TRUE;
+
+           RegCloseKey(hkParm);
+        }
     /* create thread used to flush cache */
+        if(bpower) {
     PowerNotificationThreadCreate();
+            powerEventsRegsitered = 1;
+        }
+    }
 #endif
 
     /* allow an exit to be called prior to any initialization */
@@ -609,6 +634,7 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
 
 #ifdef REGISTER_POWER_NOTIFICATIONS
     /* terminate thread used to flush cache */
+    if(powerEventsRegsitered)
     PowerNotificationThreadExit();
 #endif
 
index 33874a2..3d02b9e 100644 (file)
@@ -17,7 +17,7 @@ extern void cm_InitFreelance();
 extern long cm_FreelanceRemoveMount(char *toremove);
 extern long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp);
 extern int cm_clearLocalMountPointChange();
-
+extern int cm_FakeRootFid(cm_fid_t *fidp);
 
 #define AFS_FREELANCE_INI "afs_freelance.ini"
 #define AFS_FAKE_ROOT_CELL_ID 0xFFFFFFFF