Revert "block: resolve /dev/mapper/* name for /dev/dm-0 when hotplugging"
authorDaniel Golle <daniel@makrotopia.org>
Fri, 23 Jul 2021 21:30:56 +0000 (22:30 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 23 Jul 2021 21:31:03 +0000 (22:31 +0100)
Turns out using the device nodes /dev/mapper/* turns out to be a bad
idea to begin with. Will use /dev/dm-* instead.

This reverts commit 2f42515977adef7c026eb380ed2423c533cf8f3d.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
block.c

diff --git a/block.c b/block.c
index 4416c91a2517bcdf756a854229ea2ccb6eb253c6..5b0517eb95c8a22b928aedd06eb85b4fa8191c0e 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1171,28 +1171,7 @@ static int mount_action(char *action, char *device, int type)
 
 static int main_hotplug(int argc, char **argv)
 {
-       char *devname = getenv("DEVNAME");
-
-       /* resolve device mapper name for dm-* if possible */
-       if (devname && strlen(devname) >= 2 && !strncmp(devname, "dm-", 3)) {
-               char *dmdevnamep;
-               char dmname[256];
-
-               if (asprintf(&dmdevnamep, "/sys/%s/dm/name", getenv("DEVPATH")) == -1)
-                       exit(ENOMEM);
-
-               FILE *fp = fopen(dmdevnamep, "r");
-               free(dmdevnamep);
-
-               if (fp) {
-                       if (fgets(dmname, sizeof(dmname), fp))
-                               devname = dmname;
-
-                       fclose(fp);
-               }
-       }
-
-       return mount_action(getenv("ACTION"), devname, TYPE_HOTPLUG);
+       return mount_action(getenv("ACTION"), getenv("DEVNAME"), TYPE_HOTPLUG);
 }
 
 static int main_autofs(int argc, char **argv)