salvager-no-chdir-20081108
authorSteve McIntosh <stevemac@endpoint.com>
Sat, 8 Nov 2008 15:58:06 +0000 (15:58 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sat, 8 Nov 2008 15:58:06 +0000 (15:58 +0000)
LICENSE IPL10
FIXES 123577

make sure salvager cores don't get left in vice partitions

src/vol/vol-info.c
src/vol/vol-salvage.c

index a4bea72..a00f370 100644 (file)
@@ -413,11 +413,7 @@ HandlePart(struct DiskPartition64 *partP)
     char *p = VPartitionPath(partP);
 #endif
 
-    if (chdir(p) == -1) {
-       printf("Can't chdir to partition %s; giving up\n", p);
-       exit(1);
-    }
-    if ((dirp = opendir(".")) == NULL) {
+    if ((dirp = opendir(p)) == NULL) {
        printf("Can't read directory %s; giving up\n", p);
        exit(1);
     }
index 463aa55..ee9b8f1 100644 (file)
@@ -1204,7 +1204,8 @@ GetVolumeSummary(VolumeId singleVolumeNumber)
     struct dirent *dp;
 
     /* Get headers from volume directory */
-    if (chdir(fileSysPath) == -1 || (dirp = opendir(".")) == NULL)
+    dirp = opendir(fileSysPath);
+    if (dirp  == NULL)
        Abort("Can't read directory %s; not salvaged\n", fileSysPath);
     if (!singleVolumeNumber) {
        while ((dp = readdir(dirp))) {
@@ -3543,16 +3544,18 @@ ToString(char *s)
     assert(p != NULL);
     strcpy(p, s);
     return p;
-
 }
 
 /* Remove the FORCESALVAGE file */
 void
 RemoveTheForce(char *path)
 {
+    char target[1024];
+    struct afs_stat force; // so we can use afs_stat to find it
+    strcpy(target,path);
+    strcat(target,"/FORCESALVAGE");
     if (!Testing && ForceSalvage) {
-       if (chdir(path) == 0)
-           unlink("FORCESALVAGE");
+        if (afs_stat(target,&force) == 0)  unlink(target);
     }
 }
 
@@ -3564,10 +3567,11 @@ int
 UseTheForceLuke(char *path)
 {
     struct afs_stat force;
+    char target[1024];
+    strcpy(target,path);
+    strcat(target,"/FORCESALVAGE");
 
-    assert(chdir(path) != -1);
-
-    return (afs_stat("FORCESALVAGE", &force) == 0);
+    return (afs_stat(target, &force) == 0);
 }
 #else
 /*