zpcictl: Add warning for unsupported operations

There are several reasons why an operation might fail. Either the
running kernel, the PCI function itself, or the hypervisor lacks support
for a certain operation. In such cases the kernel returns either with
EIO or EOPNOTSUPP.
The corresponding warning, however, just says the file couldn't be
closed. Display a warning for EIO and EOPNOTSUPP to tell the user about
the missing support.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Jan Höppner
2018-12-10 14:46:04 +01:00
parent 224dc2e414
commit 6151889dcd

View File

@@ -171,8 +171,12 @@ static void sysfs_write_data(struct zpci_report_error *report, char *slot)
fopen_err(path);
if (fwrite(report, 1, r_size, fp) != r_size)
warnx("Could not write to file: %s: %s", path, strerror(errno));
if (fclose(fp))
warnx("Could not close file: %s: %s", path, strerror(errno));
if (fclose(fp)) {
if (errno == EIO || errno == EOPNOTSUPP)
warnx("Unsupported operation: %s: %s", path, strerror(errno));
else
warnx("Could not close file: %s: %s", path, strerror(errno));
}
free(path);
}