ubik-recovery-use-file-number-not-hardcoded-zero-20090319
authorDerrick Brashear <shadow@dementia.org>
Fri, 20 Mar 2009 03:48:52 +0000 (03:48 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 20 Mar 2009 03:48:52 +0000 (03:48 +0000)
LICENSE IPL10

don't hardcode DB0, use the file number which is being recovered

src/ubik/recovery.c
src/ubik/remote.c

index 2ef23f8..1d4aac7 100644 (file)
@@ -611,7 +611,7 @@ urecovery_Interact(void *dummy)
            }
 #ifndef OLD_URECOVERY
            flen = length;
-           afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+           afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
            fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
            if (fd < 0) {
                code = errno;
@@ -672,13 +672,13 @@ urecovery_Interact(void *dummy)
 #ifdef OLD_URECOVERY
                (*ubik_dbase->sync) (ubik_dbase, 0);    /* get data out first */
 #else
-               afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB0", ubik_dbase->pathName);
+               afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB%s%d", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #ifdef AFS_NT40_ENV
-               afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+               afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
                code = unlink(pbuffer);
                if (!code)
                    code = rename(tbuffer, pbuffer);
-               afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+               afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #endif
                if (!code) 
                    code = rename(pbuffer, tbuffer);
@@ -692,7 +692,7 @@ urecovery_Interact(void *dummy)
 #ifndef OLD_URECOVERY
                }
 #ifdef AFS_NT40_ENV
-               afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+               afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
                unlink(pbuffer);
 #endif
 #endif
index cd9786f..077a9ef 100644 (file)
@@ -533,7 +533,7 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
     (*dbase->setlabel) (dbase, file, &tversion);       /* setlabel does sync */
 #ifndef OLD_URECOVERY
     flen = length;
-    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
     fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
     if (fd < 0) {
        code = errno;
@@ -588,13 +588,13 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
 #ifdef OLD_URECOVERY
     (*ubik_dbase->sync) (dbase, file);
 #else
-    afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB0", ubik_dbase->pathName);
+    afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB%s%d", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #ifdef AFS_NT40_ENV
-    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
     code = unlink(pbuffer);
     if (!code)
        code = rename(tbuffer, pbuffer);
-    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #endif
     if (!code) 
        code = rename(pbuffer, tbuffer);
@@ -605,7 +605,7 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
 #ifndef OLD_URECOVERY
     }
 #ifdef AFS_NT40_ENV
-    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
     unlink(pbuffer);
 #endif
 #endif