From: Brandon Schulz Date: Fri, 4 Mar 2016 21:54:35 +0000 (-0600) Subject: Fixed option checking for format to match NVMe spec limits. X-Git-Tag: v0.5~16^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c8ec22c6584c93d6342692b4d67138732fe5ca5e;p=users%2Fsagi%2Fnvme-cli.git Fixed option checking for format to match NVMe spec limits. --- diff --git a/nvme.c b/nvme.c index 292fe7ba..6f4b905f 100644 --- a/nvme.c +++ b/nvme.c @@ -1339,8 +1339,8 @@ static int format(int argc, char **argv) const char *namespace_id = "name of desired namespace"; const char *lbaf = "LBA format to apply (req'd)"; const char *ses = "[0-2]: secure erase"; - const char *pil = "[0-3]: protection info location"; - const char *pi = "[0-1]: protection info off/on"; + const char *pil = "[0-1]: protection info location last/first 8 bytes of metadata"; + const char *pi = "[0-3]: protection info off/Type 1/Type 2/Type 3"; const char *ms = "[0-1]: extended format off/on"; const char *timeout = "timeout value"; int err; @@ -1388,7 +1388,7 @@ static int format(int argc, char **argv) get_dev(1, argc, argv); - if (cfg.ses > 7) { + if (cfg.ses > 2) { fprintf(stderr, "invalid secure erase settings:%d\n", cfg.ses); return EINVAL; } @@ -1396,10 +1396,18 @@ static int format(int argc, char **argv) fprintf(stderr, "invalid lbaf:%d\n", cfg.lbaf); return EINVAL; } - if (cfg.pi > 7) { + if (cfg.pi > 3) { fprintf(stderr, "invalid pi:%d\n", cfg.pi); return EINVAL; } + if (cfg.pil > 1) { + fprintf(stderr, "invalid pil:%d\n", cfg.pil); + return EINVAL; + } + if (cfg.ms > 1) { + fprintf(stderr, "invalid ms:%d\n", cfg.ms); + return EINVAL; + } if (S_ISBLK(nvme_stat.st_mode)) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) {