]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Skip partitions
authorKeith Busch <keith.busch@intel.com>
Wed, 14 Sep 2016 19:23:57 +0000 (13:23 -0600)
committerKeith Busch <keith.busch@intel.com>
Wed, 14 Sep 2016 19:25:06 +0000 (13:25 -0600)
We don't need to list partitions as it is redundant information with
the original namespace data.

Signed-off-by: Keith Busch <keith.busch@intel.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index 39b03f1010632fa3ae94f0e94e296854605d390e..9bd953b946e1d031273d6b2582ab9384dd369fec 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -666,13 +666,16 @@ static char *nvme_char_from_block(char *block)
 {
        char slen[16];
        unsigned len;
+
        if (strncmp("nvme", block, 4)) {
-               fprintf(stderr,"Device %s is not a nvme device.", block);
+               fprintf(stderr, "Device %s is not a nvme device.", block);
                exit(-1);
        }
-       sscanf(block,"nvme%d", &len);
-       sprintf(slen,"%d", len);
-       block[4+strlen(slen)] = 0;
+
+       sscanf(block, "nvme%d", &len);
+       sprintf(slen, "%d", len);
+       block[4 + strlen(slen)] = 0;
+
        return block;
 }
 
@@ -778,6 +781,7 @@ static int scan_dev_filter(const struct dirent *d)
 {
        char path[256];
        struct stat bd;
+       int ctrl, ns, part;
 
        if (d->d_name[0] == '.')
                return 0;
@@ -786,8 +790,11 @@ static int scan_dev_filter(const struct dirent *d)
                snprintf(path, sizeof(path), "%s%s", dev, d->d_name);
                if (stat(path, &bd))
                        return 0;
-               if (S_ISBLK(bd.st_mode))
-                       return 1;
+               if (!S_ISBLK(bd.st_mode))
+                       return 0;
+               if (sscanf(d->d_name, "nvme%dn%dp%d", &ctrl, &ns, &part) == 3)
+                       return 0;
+               return 1;
        }
        return 0;
 }