summaryrefslogtreecommitdiffstats
path: root/lib/sysfs.c
diff options
context:
space:
mode:
authorBernhard Voelker2012-08-14 09:01:45 +0200
committerKarel Zak2012-08-14 18:22:04 +0200
commitf31322a28922d51e8b32e7e9107ed403b8f2e359 (patch)
tree228e9b30222b74085567e7b3cc72b2b95db2c585 /lib/sysfs.c
parentlsblk: add WWN, improve udev support (diff)
downloadkernel-qcow2-util-linux-f31322a28922d51e8b32e7e9107ed403b8f2e359.tar.gz
kernel-qcow2-util-linux-f31322a28922d51e8b32e7e9107ed403b8f2e359.tar.xz
kernel-qcow2-util-linux-f31322a28922d51e8b32e7e9107ed403b8f2e359.zip
lib/sysfs: make sysfs_partno_to_devno better readable
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
Diffstat (limited to 'lib/sysfs.c')
-rw-r--r--lib/sysfs.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/sysfs.c b/lib/sysfs.c
index b468e8840..7b2c5f7b1 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -321,8 +321,8 @@ int sysfs_is_partition_dirent(DIR *dir, struct dirent *d, const char *parent_nam
}
/*
- * Copnverts @partno (partition number) to devno of the partition. The @cxt
- * handles wholedisk device.
+ * Converts @partno (partition number) to devno of the partition.
+ * The @cxt handles wholedisk device.
*
* Note that this code does not expect any special format of the
* partitions devnames.
@@ -345,13 +345,15 @@ dev_t sysfs_partno_to_devno(struct sysfs_cxt *cxt, int partno)
continue;
snprintf(path, sizeof(path), "%s/partition", d->d_name);
- if (sysfs_read_int(cxt, path, &n) || n != partno)
+ if (sysfs_read_int(cxt, path, &n))
continue;
- snprintf(path, sizeof(path), "%s/dev", d->d_name);
- if (sysfs_scanf(cxt, path, "%d:%d", &maj, &min) == 2)
- devno = makedev(maj, min);
- break;
+ if (n == partno) {
+ snprintf(path, sizeof(path), "%s/dev", d->d_name);
+ if (sysfs_scanf(cxt, path, "%d:%d", &maj, &min) == 2)
+ devno = makedev(maj, min);
+ break;
+ }
}
closedir(dir);