Fix linux virtual root device parsing #188
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.
When some Samsung NVMe devices have mutlipath mode enabled, that
switches which kind of NVMe device shows up in sysfs, and we get a
path link that's like
"../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1". The first
part of that, "../../devices/virtual/nvme-subsystem/", is supposed to be
consumed by the parser in linux-virtual-root.c. Unfortunately, that
parse loop incorrectly expects that sscanf will return nonzero when it
parses the format string "%n../../devices/virtual/%n", but libc does not
consider %n to be a conversion, and does not count it. In the log, we
see it find the string and set pos, but rc is 0, and "current" is not
advanced:
linux-virtual-root.c:47 parse_virtual_root(): searching for ../../devices/virtual
linux-virtual-root.c:50 parse_virtual_root(): current:'../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1' rc:0 pos0:0 pos1:22
linux-virtual-root.c:51 parse_virtual_root(): ^^^^^^^^^^^^^^^^^^^^^^
linux-virtual-root.c:47 parse_virtual_root(): searching for nvme-subsystem/
linux-virtual-root.c:50 parse_virtual_root(): current:'../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1' rc:0 pos0:0 pos1:-1
This patch makes it expect rc == 0, in the same way parse_acpi_root() in
linux-acpi-root.c does.
Signed-off-by: Peter Jones pjones@redhat.com