Fix a couple more unlink()s in vol-salvage.c
authorAndrew Deason <adeason@sinenomine.net>
Thu, 15 Oct 2009 18:15:44 +0000 (13:15 -0500)
committerDerrick Brashear <shadow|account-1000005@unknown>
Mon, 19 Oct 2009 21:48:20 +0000 (14:48 -0700)
There are a couple more unlink() calls in vol-salvage.c that were using
relative paths. Fix them to use absolute paths and to log a warning if
the unlink() fails.

Reviewed-on: http://gerrit.openafs.org/684
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/vol/vol-salvage.c

index 51003eb..f66ae82 100644 (file)
@@ -1269,9 +1269,12 @@ GetVolumeSummary(VolumeId singleVolumeNumber)
            if (error) {
                if (!singleVolumeNumber) {
                    if (!Showmode)
-                       Log("%s/%s is not a legitimate volume header file; %sdeleted\n", fileSysPathName, dp->d_name, (Testing ? "it would have been " : ""));
-                   if (!Testing)
-                       unlink(dp->d_name);
+                       Log("%s is not a legitimate volume header file; %sdeleted\n", name, (Testing ? "it would have been " : ""));
+                   if (!Testing) {
+                       if (unlink(name)) {
+                           Log("Unable to unlink %s (errno = %d)\n", name, errno);
+                       }
+                   }
                }
            } else {
                char nameShouldBe[64];
@@ -1306,9 +1309,12 @@ GetVolumeSummary(VolumeId singleVolumeNumber)
                        AskOffline(vsp->header.id, fileSysPartition->name);
                    if (strcmp(nameShouldBe, dp->d_name)) {
                        if (!Showmode)
-                           Log("Volume header file %s is incorrectly named; %sdeleted (it will be recreated later, if necessary)\n", dp->d_name, (Testing ? "it would have been " : ""));
-                       if (!Testing)
-                           unlink(dp->d_name);
+                           Log("Volume header file %s is incorrectly named; %sdeleted (it will be recreated later, if necessary)\n", name, (Testing ? "it would have been " : ""));
+                       if (!Testing) {
+                           if (unlink(name)) {
+                               Log("Unable to unlink %s (errno = %d)\n", name, errno);
+                           }
+                       }
                    } else {
                        vsp->fileName = ToString(dp->d_name);
                        nVolumes++;