--- lilo-22.8/geometry.c 2006-12-17 01:46:17.000000000 -0200 +++ lilo-22.8-new/geometry.c 2009-12-18 02:09:54.000000000 -0200 @@ -903,24 +903,17 @@ void *next = NULL; char dmdev[PATH_MAX+1]; char buf[PATH_MAX+1]; - char *slash; int result; dev_open(&dev, device, -1); strncpy(dmdev, dev.name, PATH_MAX); dmdev[PATH_MAX] = 0; + do { memset(buf, 0, PATH_MAX + 1); if ((result = readlink(dmdev, buf, PATH_MAX)) < 0 && errno != EINVAL) die("device-mapper: readlink(\"%s\") failed with: %s",buf, strerror(errno)); - if (result >= 0) { - if (buf[0] != '/' && (slash = strrchr(dmdev, '/')) != NULL) - slash++; - else - slash = dmdev; - strncpy(slash, buf, PATH_MAX - (slash-dmdev)); - } if (realpath(dmdev, buf) == NULL) die("device-mapper: realpath(\"%s\") failed with: %s",dmdev, strerror(errno)); @@ -930,13 +923,11 @@ if (!(dmt = dm_task_create(DM_DEVICE_TABLE))) die("device-mapper: dm_task_create(DM_DEVICE_TABLE) failed"); - slash = strrchr(dmdev, '/'); - if (slash) - slash++; - else - slash = dmdev; - if (!dm_task_set_name(dmt, slash)) - die("device-mapper: dm_task_set_name(\"%s\") failed",dmdev); + // Using device name is flawed. Better to use device major and minor + if (!dm_task_set_major(dmt, MAJOR(device))) + die("device-mapper: dm_task_set_major(DM_DEVICE_TABLE) failed"); + if (!dm_task_set_minor(dmt, MINOR(device))) + die("device-mapper: dm_task_set_minor(DM_DEVICE_TABLE) failed"); if (!dm_task_run(dmt)) die("device-mapper: dm_task_run(DM_DEVICE_TABLE) failed");