diff options
author | Karel Zak | 2012-08-13 21:11:37 +0200 |
---|---|---|
committer | Karel Zak | 2012-08-13 21:11:37 +0200 |
commit | a3b780532f926bc027d812b5317eda727a866fea (patch) | |
tree | 5527cf497594c353f839efe058caac6d6dbfcee2 /lib | |
parent | libmount: fix unmangle code (diff) | |
download | kernel-qcow2-util-linux-a3b780532f926bc027d812b5317eda727a866fea.tar.gz kernel-qcow2-util-linux-a3b780532f926bc027d812b5317eda727a866fea.tar.xz kernel-qcow2-util-linux-a3b780532f926bc027d812b5317eda727a866fea.zip |
lib/sysfs: expect p<N> 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 <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sysfs.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/sysfs.c b/lib/sysfs.c index 7455a30f7..92e7b0e13 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 "<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 */ |