|
|
b15ea1 |
From 54dad567c41b57c4843329856ca5047e63325a9f Mon Sep 17 00:00:00 2001
|
|
|
b15ea1 |
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
b15ea1 |
Date: Wed, 22 Apr 2020 19:33:01 +0200
|
|
|
b15ea1 |
Subject: [PATCH] Fix /sys/block sysfs parsing for eMMC-s
|
|
|
b15ea1 |
|
|
|
b15ea1 |
Commit 471869409464 ("sysfs parsers: make all the /sys/block link
|
|
|
b15ea1 |
parsers work the same way") has broken sysfs parsing for eMMC-s when
|
|
|
b15ea1 |
the passed in path points to the whole block device.
|
|
|
b15ea1 |
|
|
|
b15ea1 |
In that case pos2 will stay at its -1 initializaton value, because we
|
|
|
b15ea1 |
only do 4 conversions; and when we then do:
|
|
|
b15ea1 |
|
|
|
b15ea1 |
current += pos2
|
|
|
b15ea1 |
|
|
|
b15ea1 |
We end up moving current one char position backwards and we end up
|
|
|
b15ea1 |
returning -1.
|
|
|
b15ea1 |
|
|
|
b15ea1 |
The correct positing to use is always pos1 independent if we got
|
|
|
b15ea1 |
passed the whole disk; or a parition, as we always want to return
|
|
|
b15ea1 |
only the part which points to whole disk which ends at pos1.
|
|
|
b15ea1 |
|
|
|
b15ea1 |
Note that it seems that before commit 471869409464, the case where
|
|
|
b15ea1 |
path points to the partition was likely broken as the old code then
|
|
|
b15ea1 |
would return the entire path including the partition element.
|
|
|
b15ea1 |
|
|
|
b15ea1 |
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1826864
|
|
|
b15ea1 |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
b15ea1 |
---
|
|
|
b15ea1 |
src/linux-emmc.c | 9 +++------
|
|
|
b15ea1 |
1 file changed, 3 insertions(+), 6 deletions(-)
|
|
|
b15ea1 |
|
|
|
b15ea1 |
diff --git a/src/linux-emmc.c b/src/linux-emmc.c
|
|
|
b15ea1 |
index 800dc14..65557b4 100644
|
|
|
b15ea1 |
--- a/src/linux-emmc.c
|
|
|
b15ea1 |
+++ b/src/linux-emmc.c
|
|
|
b15ea1 |
@@ -56,13 +56,10 @@ parse_emmc(struct device *dev, const char *path, const char *root UNUSED)
|
|
|
b15ea1 |
dev->emmc_info.slot_id = slot_id;
|
|
|
b15ea1 |
dev->interface_type = emmc;
|
|
|
b15ea1 |
|
|
|
b15ea1 |
- if (rc == 6) {
|
|
|
b15ea1 |
- if (dev->part == -1)
|
|
|
b15ea1 |
- dev->part = partition;
|
|
|
b15ea1 |
+ if (rc == 6 && dev->part == -1)
|
|
|
b15ea1 |
+ dev->part = partition;
|
|
|
b15ea1 |
|
|
|
b15ea1 |
- pos2 = pos1;
|
|
|
b15ea1 |
- }
|
|
|
b15ea1 |
- current += pos2;
|
|
|
b15ea1 |
+ current += pos1;
|
|
|
b15ea1 |
|
|
|
b15ea1 |
debug("current:'%s' sz:%zd", current, current - path);
|
|
|
b15ea1 |
return current - path;
|
|
|
b15ea1 |
--
|
|
|
b15ea1 |
2.26.0
|
|
|
b15ea1 |
|