Fix /sys/block sysfs parsing for eMMC-s #150
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commit 4718694 ("sysfs parsers: make all the /sys/block link
parsers work the same way") has broken sysfs parsing for eMMC-s when
the passed in path points to the whole block device.
In that case pos2 will stay at its -1 initializaton value, because we
only do 4 conversions; and when we then do:
current += pos2
We end up moving current one char position backwards and we end up
returning -1.
The correct position to use is always pos1 independent if we got
passed the whole disk; or a partition, as we always want to return
only the part which points to whole disk which ends at pos1.
Note that it seems that before commit 4718694, the case where
path points to the partition was likely broken as the old code then
would return the entire path including the partition element.
Also see: https://bugzilla.redhat.com/show_bug.cgi?id=1826864