From: Keith Busch Date: Mon, 11 May 2015 20:44:05 +0000 (-0600) Subject: Fix f/w download X-Git-Tag: v0.1~44 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8b3d29ed3ad8113e54f5675b764f39a251d38ebd;p=users%2Fsagi%2Fnvme-cli.git Fix f/w download This needs to read the image file into it's buffer for this to work correctly, and use an appropriate default transfer size. Signed-off-by: Keith Busch --- diff --git a/nvme.c b/nvme.c index 8fea24ed..cfedcd5c 100644 --- a/nvme.c +++ b/nvme.c @@ -1156,7 +1156,7 @@ static int fw_download(int argc, char **argv) const struct config defaults = { .fw = "", - .xfer = 0, + .xfer = 4096, .offset = 0, }; @@ -1194,8 +1194,10 @@ static int fw_download(int argc, char **argv) fprintf(stderr, "No memory for f/w size:%d\n", fw_size); return ENOMEM; } - if (cfg.xfer % 4096) + if (cfg.xfer == 0 || cfg.xfer % 4096) cfg.xfer = 4096; + if (read(fw_fd, fw_buf, fw_size) != ((ssize_t)(fw_size))) + return EIO; while (fw_size > 0) { cfg.xfer = min(cfg.xfer, fw_size); @@ -1212,7 +1214,8 @@ static int fw_download(int argc, char **argv) perror("ioctl"); exit(errno); } else if (err != 0) { - fprintf(stderr, "NVME Admin command error:%d\n", err); + fprintf(stderr, "NVME Admin command error:%s(%x)\n", + nvme_status_to_string(err), err); break; } fw_buf += cfg.xfer;