From 6151889dcdc08f5ed1c25d79f9ebfbba13f7738f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Mon, 10 Dec 2018 14:46:04 +0100 Subject: [PATCH] zpcictl: Add warning for unsupported operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- zpcictl/zpcictl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zpcictl/zpcictl.c b/zpcictl/zpcictl.c index 85dc9925..dfbbb78f 100644 --- a/zpcictl/zpcictl.c +++ b/zpcictl/zpcictl.c @@ -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); }