From a2b1aecb9075c7a8f9bad627fc45171bb533c8bd Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 9 Apr 2024 15:03:43 +0200 Subject: [PATCH] logging: fix error handling for ioctl passthru wrappers libnvme fixed the error handling for the passthru commands. Update the nvme-cli version accordingly. Signed-off-by: Daniel Wagner --- util/logging.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/util/logging.c b/util/logging.c index c26d9e228e..8a39bbac49 100644 --- a/util/logging.c +++ b/util/logging.c @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -104,8 +105,14 @@ int nvme_submit_passthru(int fd, unsigned long ioctl_cmd, nvme_show_latency(start, end); } - if (err >= 0 && result) - *result = cmd->result; + if (err >= 0) { + if (result) + *result = cmd->result; + if (cmd->result) { + errno = EPROTO; + err = -1; + } + } return err; } @@ -131,8 +138,14 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd, nvme_show_latency(start, end); } - if (err >= 0 && result) - *result = cmd->result; + if (err >= 0) { + if (result) + *result = cmd->result; + if (cmd->result) { + errno = EPROTO; + err = -1; + } + } return err; }