From ffdd90522aacaf19914c673f15e50f52137ada75 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 25 Feb 2022 01:09:03 +0100 Subject: mtab: turn part:x:device:y into /dev/ysx This is needed when using a rumpdisk-based root disk. Otherwise fsck does not properly detect when it is mounted. --- trans/mtab.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'trans/mtab.c') diff --git a/trans/mtab.c b/trans/mtab.c index f21377b7..caff3385 100644 --- a/trans/mtab.c +++ b/trans/mtab.c @@ -562,8 +562,24 @@ looks_like_block_device (const char *s) error_t map_device_to_path (const char *device, char **path) { + int part = -1; + if (strncmp (device, "part:", 5) == 0) + { + const char *next = strchr(device + 5, ':'); + + if (next) + { + part = atoi(device + 5); + device = next + 1; + } + } if (strncmp (device, "device:", 7) == 0) - asprintf (path, "/dev/%s", &device[7]); + { + if (part >= 0) + asprintf (path, "/dev/%ss%u", &device[7], part); + else + asprintf (path, "/dev/%s", &device[7]); + } else if (strncmp (device, "/dev/", 5) == 0) *path = strdup (device); else if (looks_like_block_device (device)) -- cgit v1.2.3