vos: Fix vos dump and restore dump file close error messages

The file handle close error messages in the vos dump and restore
commands have "STDIN" and "STDOUT" swapped.  Just remove the filename or
"STDIN"/"STDOUT" from those messages.

Remove the extra flag to indicate if we have a file handle and just
initialize the usd file handles to NULL.

This is a clean up in preparation for other changes.

Change-Id: I97bf5a8177269331e4060746736a882892b9062e
Reviewed-on: https://gerrit.openafs.org/14756
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Michael Meffie 2021-08-16 14:14:11 -04:00 committed by Andrew Deason
parent c0ff0c7f42
commit 1b826118fd

View File

@ -354,24 +354,20 @@ static afs_int32
WriteData(struct rx_call *call, void *rock)
{
char *filename = (char *) rock;
usd_handle_t ufd;
usd_handle_t ufd = NULL;
long blksize;
afs_int32 error, code;
int ufdIsOpen = 0;
afs_int32 error = 0;
afs_int32 code;
afs_int64 currOffset;
afs_uint32 buffer;
afs_uint32 got;
error = 0;
if (!filename || !*filename) {
usd_StandardInput(&ufd);
blksize = 4096;
ufdIsOpen = 1;
} else {
code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
if (code == 0) {
ufdIsOpen = 1;
code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
}
if (code) {
@ -397,11 +393,10 @@ WriteData(struct rx_call *call, void *rock)
goto wfail;
}
wfail:
if (ufdIsOpen) {
if (ufd != NULL) {
code = USD_CLOSE(ufd);
if (code) {
fprintf(STDERR, "Could not close dump file %s\n",
(filename && *filename) ? filename : "STDOUT");
fprintf(STDERR, "Could not close dump file handle; code=%d\n", code);
if (!error)
error = code;
}
@ -458,22 +453,20 @@ static afs_int32
DumpFunction(struct rx_call *call, void *rock)
{
char *filename = (char *)rock;
usd_handle_t ufd; /* default is to stdout */
afs_int32 error = 0, code;
usd_handle_t ufd = NULL;
afs_int32 error = 0;
afs_int32 code;
afs_int64 size;
long blksize;
int ufdIsOpen = 0;
/* Open the output file */
if (!filename || !*filename) {
usd_StandardOutput(&ufd);
blksize = 4096;
ufdIsOpen = 1;
} else {
code =
usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
if (code == 0) {
ufdIsOpen = 1;
size = 0;
code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
}
@ -492,12 +485,10 @@ DumpFunction(struct rx_call *call, void *rock)
ERROR_EXIT(code);
error_exit:
/* Close the output file */
if (ufdIsOpen) {
if (ufd != NULL) {
code = USD_CLOSE(ufd);
if (code) {
fprintf(STDERR, "Could not close dump file %s\n",
(filename && *filename) ? filename : "STDIN");
fprintf(STDERR, "Could not close dump file handle; code=%d\n", code);
if (!error)
error = code;
}