diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index ab755f67f0..65e0cf8626 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -872,7 +872,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) * If there is one here that is not in the inode volume list, * delete it now. */ for (; vsp < esp && (vsp->header.parent < rwvid); vsp++) { - if (vsp->fileName) + if (vsp->unused) DeleteExtraVolumeHeaderFile(salvinfo, vsp); } /* Now match up the volume summary info from the root directory with the @@ -881,7 +881,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) for (tsp = vsp; tsp < esp && (tsp->header.parent == rwvid); tsp++) { if (tsp->header.id == vid) { salvinfo->inodeSummary[j].volSummary = tsp; - tsp->fileName = 0; + tsp->unused = 0; break; } } @@ -899,7 +899,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) /* Delete any additional volumes that were listed in the partition but which didn't have any corresponding inodes */ for (; vsp < esp; vsp++) { - if (vsp->fileName) + if (vsp->unused) DeleteExtraVolumeHeaderFile(salvinfo, vsp); } @@ -958,7 +958,14 @@ void DeleteExtraVolumeHeaderFile(struct SalvInfo *salvinfo, struct VolumeSummary *vsp) { char path[64]; - sprintf(path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, vsp->fileName); + char filename[VMAXPATHLEN]; + + if (vsp->deleted) { + return; + } + + VolumeExternalName_r(vsp->header.id, filename, sizeof(filename)); + sprintf(path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, filename); if (!Showmode) Log("The volume header file %s is not associated with any actual data (%sdeleted)\n", path, (Testing ? "would have been " : "")); @@ -971,7 +978,7 @@ DeleteExtraVolumeHeaderFile(struct SalvInfo *salvinfo, struct VolumeSummary *vsp afs_printable_uint32_lu(vsp->header.id)); } - /* make sure we actually delete the fileName file; ENOENT + /* make sure we actually delete the header file; ENOENT * is fine, since VDestroyVolumeDiskHeader probably already * unlinked it */ if (unlink(path) && errno != ENOENT) { @@ -982,7 +989,6 @@ DeleteExtraVolumeHeaderFile(struct SalvInfo *salvinfo, struct VolumeSummary *vsp } vsp->deleted = 1; } - vsp->fileName = 0; } int @@ -1215,7 +1221,7 @@ GetInodeSummary(struct SalvInfo *salvinfo, FD_t inodeFile, VolumeId singleVolume GetVolumeSummary(salvinfo, singleVolumeNumber); for (i = 0, vsp = salvinfo->volumeSummaryp; i < salvinfo->nVolumes; i++) { - if (vsp->fileName) { + if (vsp->unused) { if (vsp->header.id == singleVolumeNumber) { foundSVN = 1; } @@ -1465,7 +1471,7 @@ AskVolumeSummary(struct SalvInfo *salvinfo, VolumeId singleVolumeNumber) DiskToVolumeHeader(&vsp->header, &diskHdr); VolumeExternalName_r(q_res.children[i], name, sizeof(name)); - vsp->fileName = ToString(name); + vsp->unused = 1; salvinfo->nVolumes++; vsp++; } @@ -1636,7 +1642,7 @@ RecordHeader(struct DiskPartition64 *dp, const char *name, return 1; } - summary.fileName = ToString(base); + summary.unused = 1; params->nVolumes++; if (params->nVolumes > params->totalVolumes) { @@ -2352,13 +2358,7 @@ SalvageVolumeHeaderFile(struct SalvInfo *salvinfo, struct InodeSummary *isp, if (memcmp (&isp->volSummary->header, &tempHeader, sizeof(struct VolumeHeader))) { - /* We often remove the name before calling us, so we make a fake one up */ - if (isp->volSummary->fileName) { - strcpy(headerName, isp->volSummary->fileName); - } else { - snprintf(headerName, sizeof headerName, VFORMAT, - afs_printable_uint32_lu(isp->volumeId)); - } + VolumeExternalName_r(isp->volumeId, headerName, sizeof(headerName)); snprintf(path, sizeof path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, headerName); @@ -4255,7 +4255,9 @@ MaybeZapVolume(struct SalvInfo *salvinfo, struct InodeSummary *isp, if (!Testing) { afs_int32 code; char path[64]; - sprintf(path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, isp->volSummary->fileName); + char filename[VMAXPATHLEN]; + VolumeExternalName_r(isp->volumeId, filename, sizeof(filename)); + sprintf(path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, filename); code = VDestroyVolumeDiskHeader(salvinfo->fileSysPartition, isp->volumeId, isp->RWvolumeId); if (code) { @@ -4264,7 +4266,7 @@ MaybeZapVolume(struct SalvInfo *salvinfo, struct InodeSummary *isp, afs_printable_uint32_lu(isp->volumeId)); } - /* make sure we actually delete the fileName file; ENOENT + /* make sure we actually delete the header file; ENOENT * is fine, since VDestroyVolumeDiskHeader probably already * unlinked it */ if (unlink(path) && errno != ENOENT) { diff --git a/src/vol/vol-salvage.h b/src/vol/vol-salvage.h index 21f7fb2a6d..e1f0875502 100644 --- a/src/vol/vol-salvage.h +++ b/src/vol/vol-salvage.h @@ -52,8 +52,6 @@ struct VolumeSummary { /* Volume summary an entry for each * volume in a volume directory. * Assumption: one volume directory per * partition */ - char *fileName; /* File name on the partition for the volume - * header */ struct VolumeHeader header; /* volume number, rw volume number, inode * numbers of each major component of @@ -63,6 +61,8 @@ struct VolumeSummary { /* Volume summary an entry for each byte wouldNeedCallback; /* set if the file server should issue * call backs for all the files in this volume when * the volume goes back on line */ + byte unused; /* is this volume 'extra'? i.e. not referenced + * by anything? */ }; struct VnodeInfo {