fs: Improve 'flush' errno handling

If an error is encountered, 'fs flush' and 'fs flushvolume' try to
print an error message using perror(), but do so after calling
fprintf(), which may change the value of errno.

Also, 'fs flushall' doesn't try to print a reason for an error at all;
it just shows that some kind of error happened.

Change all of these to print an errno-derived error message using
strerror().

Change-Id: I3d7983c6d48068d3b4cb11ae2e6a1d890f8b8ba7
Reviewed-on: https://gerrit.openafs.org/15392
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
Andrew Deason 2023-04-10 17:07:02 -05:00 committed by Michael Meffie
parent 986de6cfdc
commit 7d2ed6925b

View File

@ -1305,8 +1305,8 @@ FlushVolumeCmd(struct cmd_syndesc *as, void *arock)
blob.in_size = blob.out_size = 0;
code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
if (code) {
fprintf(stderr, "Error flushing volume ");
perror(ti->data);
fprintf(stderr, "Error flushing volume %s: %s\n", ti->data,
strerror(errno));
error = 1;
continue;
}
@ -1327,7 +1327,7 @@ FlushAllVolumesCmd(struct cmd_syndesc *as, void *arock)
code = pioctl(NULL, VIOC_FLUSHALL, &blob, 0);
if (code) {
fprintf(stderr, "Error flushing all volumes\n");
fprintf(stderr, "Error flushing all volumes: %s\n", strerror(errno));
error = 1;
}
return error;
@ -1454,8 +1454,8 @@ FlushCmd(struct cmd_syndesc *as, void *arock)
fprintf(stderr, "%s: Can't flush active file %s\n", pn,
ti->data);
} else {
fprintf(stderr, "%s: Error flushing file ", pn);
perror(ti->data);
fprintf(stderr, "%s: Error flushing file %s: %s\n", pn,
ti->data, strerror(errno));
}
error = 1;
continue;