From 14ef3681c6a505efff6d4efcb1d94a6531276a57 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 19 Jun 2019 10:09:54 -0700 Subject: [PATCH] nvme-cli: Skip properties that are not supported Instead of causing the show-regs command to fail if a property is encountered that is not supported by the target side, do not display the property. With this patch applied the following output is displayed for the Linux NVMf target: $ nvme show-regs /dev/nvme0 cap : f0003ff version : 10300 cc : 460001 csts : 1 Signed-off-by: Bart Van Assche --- nvme-ioctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nvme-ioctl.c b/nvme-ioctl.c index 0c8de074..57fae22e 100644 --- a/nvme-ioctl.c +++ b/nvme-ioctl.c @@ -614,7 +614,10 @@ int nvme_get_properties(int fd, void **pbar) memset(*pbar, 0xff, size); for (offset = NVME_REG_CAP; offset <= NVME_REG_CMBSZ;) { err = nvme_get_property(fd, offset, &value); - if (err) { + if (err > 0 && (err & 0xff) == NVME_SC_INVALID_FIELD) { + err = 0; + value = -1; + } else if (err) { free(*pbar); break; } -- 2.50.1