From: Karel Zak Date: Mon, 13 Aug 2012 19:11:37 +0000 (+0200) Subject: lib/sysfs: expect p suffix for partitions X-Git-Tag: v2.22-rc2~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a3b780532f926bc027d812b5317eda727a866fea;p=thirdparty%2Futil-linux.git lib/sysfs: expect p suffix for partitions ... 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 --- 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 */