]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: expect p<N> suffix for partitions
authorKarel Zak <kzak@redhat.com>
Mon, 13 Aug 2012 19:11:37 +0000 (21:11 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Aug 2012 19:11:37 +0000 (21:11 +0200)
 ... so for example lsblk(8) will see partitioned loop devices

loop0       7:0    0    80G  0 loop
├─loop0p1 259:0    0   100M  0 loop
└─loop0p2 259:1    0  79.9G  0 loop

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/sysfs.c

index 7455a30f7c085ec359b4efb2610dc1d48b5703d4..92e7b0e137f9c23637df68013ed26e9713f2ceba 100644 (file)
@@ -306,9 +306,12 @@ int sysfs_is_partition_dirent(DIR *dir, struct dirent *d, const char *parent_nam
                if (strlen(d->d_name) <= len)
                        return 0;
 
-               /* partitions subdir name is "<parent>[:digit:]" */
-               return strncmp(p, d->d_name, len) == 0
-                      && isdigit(*(d->d_name + len));
+               /* partitions subdir name is
+                *      "<parent>[:digit:]" or "<parent>p[:digit:]"
+                */
+               return strncmp(p, d->d_name, len) == 0 &&
+                      ((*(d->d_name + len) == 'p' && isdigit(*(d->d_name + len + 1)))
+                       || isdigit(*(d->d_name + len)));
        }
 
        /* Cannot use /partition file, not supported on old sysfs */