summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-02-25 01:09:03 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-02-25 01:09:03 +0100
commitffdd90522aacaf19914c673f15e50f52137ada75 (patch)
tree0c064bea4fb7fc6440236ce09b2ec4a78f4d966e
parent499dea307cb900d53beed8c119cd7d8e76a530eb (diff)
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.
-rw-r--r--trans/mtab.c18
1 files changed, 17 insertions, 1 deletions
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))