rootdev: Strip partitions less aggressively

In device names like dm-N or loopN, the N is not a partition number and
should not be stripped off.  These can arise for example if run inside a
chroot mounted on a loopback device.

BUG=chromium:748665, chromium:730144
TEST=New unit tests.

Change-Id: If7ecacbfcf00690376cb4ffc75baa45422579085
Reviewed-on: https://chromium-review.googlesource.com/585652
Commit-Ready: Benjamin Gordon <bmgordon@chromium.org>
Tested-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2 files changed