Always check VInitVolumePackage2 return code

Some programs were not checking the return code of VInitVolumePackage2.
Although some programs do not care so much if we fail to properly init
the volume package (SYNC debug tools), at the very least log/print an
error, so it doesn't silently fail.

Other programs are changed to exit when VInitVolumePackage2 fail, so
e.g. salvages don't accidentally cause corruption on 'logging'-mounted
UFS partitions.

In any case, ensure the return code is always checked anywhere it is
called.

Change-Id: I164d5920a5ea2dd7e5ed9ad4ccc578e9bdf0db0b
Reviewed-on: http://gerrit.openafs.org/1090
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Andrew Deason 2010-01-11 13:36:32 -06:00 committed by Derrick Brashear
parent 9b23804a82
commit 1544243167
7 changed files with 41 additions and 8 deletions

View File

@ -186,7 +186,13 @@ common_prolog(struct cmd_syndesc * as, struct state * state)
#endif
VOptDefaults(debugUtility, &opts);
VInitVolumePackage2(debugUtility, &opts);
if (VInitVolumePackage2(debugUtility, &opts)) {
/* VInitVolumePackage2 can fail on e.g. partition attachment errors,
* but we don't really care, since all we're doing is trying to use
* SALVSYNC */
fprintf(stderr, "errors encountered initializing volume package, but "
"trying to continue anyway\n");
}
DInit(1);
if ((ti = as->parms[COMMON_PARMS_OFFSET].items)) { /* -reason */

View File

@ -232,7 +232,13 @@ common_prolog(struct cmd_syndesc * as, struct state * state)
#endif
VOptDefaults(debugUtility, &opts);
VInitVolumePackage2(debugUtility, &opts);
if (VInitVolumePackage2(debugUtility, &opts)) {
/* VInitVolumePackage2 can fail on e.g. partition attachment errors,
* but we don't really care, since all we're doing is trying to use
* FSSYNC */
fprintf(stderr, "errors encountered initializing volume package, but "
"trying to continue anyway\n");
}
DInit(1);
if ((ti = as->parms[COMMON_PARMS_OFFSET].items)) { /* -reason */

View File

@ -423,7 +423,13 @@ SalvageClient(VolumeId vid, char * pname)
VolumePackageOptions opts;
VOptDefaults(volumeUtility, &opts);
VInitVolumePackage2(volumeUtility, &opts);
if (VInitVolumePackage2(volumeUtility, &opts)) {
/* VInitVolumePackage2 can fail on e.g. partition attachment errors,
* but we don't really care, since all we're doing is trying to use
* SALVSYNC */
fprintf(stderr, "errors encountered initializing volume package, but "
"trying to continue anyway\n");
}
SALVSYNC_clientInit();
code = SALVSYNC_SalvageVolume(vid, pname, SALVSYNC_SALVAGE, SALVSYNC_OPERATOR, 0, NULL);
@ -511,7 +517,10 @@ SalvageServer(void)
/* initialize things */
VOptDefaults(salvageServer, &opts);
VInitVolumePackage2(salvageServer, &opts);
if (VInitVolumePackage2(salvageServer, &opts)) {
Log("Shutting down: errors encountered initializing volume package\n");
Exit(1);
}
DInit(10);
queue_Init(&pending_q);
queue_Init(&log_cleanup_queue);

View File

@ -324,7 +324,10 @@ handleit(struct cmd_syndesc *as, void *arock)
}
VOptDefaults(pt, &opts);
VInitVolumePackage2(pt, &opts);
if (VInitVolumePackage2(pt, &opts)) {
Log("errors encountered initializing volume package; salvage aborted\n");
Exit(1);
}
DInit(10);
#ifdef AFS_NT40_ENV
if (myjob.cj_number != NOT_CHILD) {

View File

@ -41,7 +41,10 @@ main(argc, argv)
VolumePackageOptions opts;
VOptDefaults(1, &opts);
VInitVolumePackage2(1, &opts);
if (VInitVolumePackage2(1, &opts)) {
printf("errors encountered initializing volume package\n");
exit(-1);
}
VPrintDiskStats();
}

View File

@ -302,7 +302,10 @@ main(int argc, char **argv)
VolumePackageOptions opts;
VOptDefaults(volumeUtility, &opts);
VInitVolumePackage2(volumeUtility, &opts);
if (VInitVolumePackage2(volumeUtility, &opts)) {
fprintf(stderr, "errors encountered initializing volume package, but "
"trying to continue anyway\n");
}
ts = cmd_CreateSyntax(NULL, handleit, NULL,
"Dump a volume to a 'vos dump' format file without using volserver");

View File

@ -426,7 +426,10 @@ main(int argc, char **argv)
OpenLog(AFSDIR_SERVER_VOLSERLOG_FILEPATH);
VOptDefaults(volumeServer, &opts);
VInitVolumePackage2(volumeServer, &opts);
if (VInitVolumePackage2(volumeServer, &opts)) {
Log("Shutting down: errors encountered initializing volume package\n");
exit(1);
}
/* For nuke() */
Lock_Init(&localLock);
DInit(40);