]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: Skip properties that are not supported
authorBart Van Assche <bvanassche@acm.org>
Wed, 19 Jun 2019 17:09:54 +0000 (10:09 -0700)
committerBart Van Assche <bvanassche@acm.org>
Wed, 19 Jun 2019 17:28:15 +0000 (10:28 -0700)
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 <bvanassche@acm.org>
nvme-ioctl.c

index 0c8de0748c18b83171231645f08964b4134ab976..57fae22e1e37e8f9905999aef58d988cb9ca15a3 100644 (file)
@@ -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;
                }