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 <[email protected]>
Tested-by: Benjamin Gordon <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Reviewed-by: Mike Frysinger <[email protected]>
2 files changed