Refactor efi_parse_dev_path()

I have refactored efi_parse_dev_path to reduce code duplication and
avoid the use of constants. The latter was a criticism by ilovezfs of my
patch to fix the bug he reported during his review of it.

The previous code suffered from theoretical buffer overflows in strcpy()
and sscanf(). For instance, /dev/sdaaaaaaaaaaaaaa1 would cause an
overflow, despite being valid. The new code replaces strcpy() with
strlcpy() to truncate instead of overflowing, returns EINVAL on
truncation, and does a calculation to prove that the scanf() has enough
room to operate without overflowing, returning EINVAL otherwise.

This does not properly handle names where the partition number exceeds
the precision of an ushort_t. An example would be /dev/sda100000.
Should we ever encounter a situation where the partition number exceeds
the precision of an ushort_t, ZFS' internal partition number for this
device will be incorrect, but it should still operate. As such, the cost
to benefit ratio of handling this case to be too low to merit a fix
unless an attempt is made to produce a formally verified codebase.

Reviewed-by: ilovezfs <ilovezfs@icloud.com>
Signed-off-by: Richard Yao <ryao@gentoo.org>