]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Fixup Security send/recv to read data from disk
authorScott Bauer <scott.bauer@intel.com>
Thu, 16 Mar 2017 23:16:29 +0000 (17:16 -0600)
committerScott Bauer <scott.bauer@intel.com>
Thu, 16 Mar 2017 23:16:29 +0000 (17:16 -0600)
We forgot to actually read the data from the disk into the buffer.

Signed-off-by: Scott Bauer <scott.bauer@intel.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index 4b4d7faa804946b2daae5b197334b03f452df7d0..5fbb3630082a65cd5653557a9a6a1aaf43e5ab8e 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -1665,6 +1665,12 @@ static int sec_send(int argc, char **argv, struct command *cmd, struct plugin *p
                return ENOMEM;
        }
 
+       if (read(sec_fd, sec_buf, sec_size) < 0) {
+               fprintf(stderr, "Failed to read data from security file with %s\n",
+                       strerror(errno));
+               return EINVAL;
+       }
+
        err = nvme_sec_send(fd, cfg.namespace_id, cfg.nssf, cfg.spsp, cfg.secp,
                        cfg.tl, sec_size, sec_buf, &result);
        if (err < 0)