From a3b780532f926bc027d812b5317eda727a866fea Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 13 Aug 2012 21:11:37 +0200 Subject: [PATCH] lib/sysfs: expect p suffix for partitions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ... 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 --- lib/sysfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/sysfs.c b/lib/sysfs.c index 7455a30f7c..92e7b0e137 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -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 "[:digit:]" */ - return strncmp(p, d->d_name, len) == 0 - && isdigit(*(d->d_name + len)); + /* partitions subdir name is + * "[:digit:]" or "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 */ -- 2.47.3