]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Fixed option checking for format to match NVMe spec limits.
authorBrandon Schulz <brandon.schulz@hgst.com>
Fri, 4 Mar 2016 21:54:35 +0000 (15:54 -0600)
committerBrandon Schulz <brandon.schulz@hgst.com>
Fri, 4 Mar 2016 21:54:35 +0000 (15:54 -0600)
nvme.c

diff --git a/nvme.c b/nvme.c
index 292fe7ba980d7e3c5d804b8ed4cd0ff1d4f2f540..6f4b905f837a90e3a112961cad5076af7714e1af 100644 (file)
--- 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) {