]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: make sysfs_partno_to_devno better readable
authorBernhard Voelker <mail@bernhard-voelker.de>
Tue, 14 Aug 2012 07:01:45 +0000 (09:01 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Aug 2012 16:22:04 +0000 (18:22 +0200)
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
lib/sysfs.c

index b468e884014575f14319f33f20a66a6139cb615d..7b2c5f7b149db403c535a9d2764b49b385c4b905 100644 (file)
@@ -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);