[fstab] Recognize mmc and nvme disks correctly

- basename() returns the last path component, so never includes
  the leading '/dev/'
- the check for mmc and nvme looked for device names starting
  with '/dev/mmc' .. but '/dev/' has just been stripped away
  by the call to basename, so this never matched
- stripped the trailing digits rather than trailing 'p[0-9]',
  so 'nvme0n1p2' became 'nvme0n1p' which isn't a useful
  device name.

FIXES #1883
This commit is contained in:
Adriaan de Groot 2022-02-21 14:56:45 +01:00
parent 92f4ab30ea
commit 23f501c071

View File

@ -92,7 +92,8 @@ def disk_name_for_partition(partition):
"""
name = os.path.basename(partition["device"])
if name.startswith("/dev/mmcblk") or name.startswith("/dev/nvme"):
if name.startswith("mmcblk") or name.startswith("nvme"):
# Typical mmc device is mmcblk0p1, nvme looks like nvme0n1p2
return re.sub("p[0-9]+$", "", name)
return re.sub("[0-9]+$", "", name)