From 93b2877cd30cb444f6082010e8a8c9ede44c075e Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Fri, 12 Apr 2024 13:04:05 +0200 Subject: [PATCH] Revert "ioctl: return EPROTO when an NVMe status occurred" This reverts commit 3089da58d2c35b3b700c1eb88540f96cfe0e87ad. The result field is undefined for many commands and thus can have random values. Thus we can't blindly evaluate these for all commands. Signed-off-by: Daniel Wagner --- src/nvme/ioctl.c | 20 ++++---------------- test/ioctl/features.c | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/nvme/ioctl.c b/src/nvme/ioctl.c index fa7d70d8..ce5a911a 100644 --- a/src/nvme/ioctl.c +++ b/src/nvme/ioctl.c @@ -85,14 +85,8 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd, { int err = ioctl(fd, ioctl_cmd, cmd); - if (err >= 0) { - if (result) - *result = cmd->result; - if (cmd->result) { - errno = EPROTO; - err = -1; - } - } + if (err >= 0 && result) + *result = cmd->result; return err; } @@ -102,14 +96,8 @@ int nvme_submit_passthru(int fd, unsigned long ioctl_cmd, { int err = ioctl(fd, ioctl_cmd, cmd); - if (err >= 0) { - if (result) - *result = cmd->result; - if (cmd->result) { - errno = EPROTO; - err = -1; - } - } + if (err >= 0 && result) + *result = cmd->result; return err; } diff --git a/test/ioctl/features.c b/test/ioctl/features.c index 3c452100..73864979 100644 --- a/test/ioctl/features.c +++ b/test/ioctl/features.c @@ -17,7 +17,7 @@ #define TEST_CDW15 0x15151515 #define TEST_UUIDX 0b1001110 #define TEST_FID 0xFE -#define TEST_RESULT 0x0 +#define TEST_RESULT 0x12345678 #define TEST_SEL NVME_GET_FEATURES_SEL_SAVED #define TEST_SC NVME_SC_INVALID_FIELD