vmur/vmur.cpp: Fix error handling on transfer failure

The command

 # vmur punch -r rhcos-live-kernel-s390x -u etpgxku -N kernel.img
 Reader file with spoolid E YO created and transferred to ETPGXKU.
 #

did not indicate an error when executed. However the file was not
transferred and this error message went unnoticed:
RPIMGR032E YOU ARE NOT AUTHORIZED TO CLOSE TO TATAC05.ETPGXKU
HCPCSL007E Invalid userid - ETPGXKU

Fix this by checking the CP return code and print the error message
returned by CP. This is the behavior now:
 # vmur punch -r rhcos-live-kernel-s390x -u etpgxku -N kernel.img
 vmur: CP command failed with rc=7
 RPIMGR032E YOU ARE NOT AUTHORIZED TO CLOSE TO TATAC05.ETPGXKU
 HCPCSL007E Invalid userid - ETPGXKU
 #

Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/119
Reported-by: Vance Morris <vmorris@us.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Tested-by: Vance Morris <vmorris@us.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Thomas Richter
2021-08-04 12:06:32 +02:00
committed by Jan Höppner
parent 45e3f016f4
commit 35c97a07aa

View File

@@ -1863,7 +1863,6 @@ static void close_ur_device(struct vmur *info)
}
cpcmd_cs(cmd, &response, &cprc, 0);
memcpy(spoolid, &response[9], 4);
free(response);
if (cprc == 439) {
if (info->action == PUNCH)
sprintf(cmd, "PURGE * PUN %s", spoolid);
@@ -1872,7 +1871,10 @@ static void close_ur_device(struct vmur *info)
cpcmd(cmd, NULL, NULL, 0);
ERR_EXIT("User %s spool fileid limit exceeded.\n"
, info->user);
} else if (cprc) {
ERR_EXIT("CP command failed with rc=%i\n%s\n", cprc, response);
}
free(response);
if (info->rdr_specified) {
if (info->node_specified)
printf("Reader file with spoolid %s created and "