From 0ac956b3384842b3c60e72bde78a4baf58a5877f Mon Sep 17 00:00:00 2001 From: Steve McIntosh Date: Sat, 8 Nov 2008 15:58:06 +0000 Subject: [PATCH] salvager-no-chdir-20081108 LICENSE IPL10 FIXES 123577 make sure salvager cores don't get left in vice partitions --- src/vol/vol-info.c | 6 +----- src/vol/vol-salvage.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/vol/vol-info.c b/src/vol/vol-info.c index a4bea72..a00f370 100644 --- a/src/vol/vol-info.c +++ b/src/vol/vol-info.c @@ -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); } diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index 463aa55..ee9b8f1 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -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 /* -- 1.9.4