libdm/lvm - Fix bugs
authorAlex Hornung <ahornung@gmail.com>
Sat, 14 Aug 2010 08:37:54 +0000 (09:37 +0100)
committerAlex Hornung <ahornung@gmail.com>
Sat, 14 Aug 2010 08:39:56 +0000 (09:39 +0100)
* Allow adding symlinks to lvm's dev-cache by translating the symlink
  for udev/libdevattr.

* Don't include kdev_t.h in libdm since it has the wrong macros for
  MAJOR and MINOR; instead include netbsd's version.

Reported-by: Matt Dillon (dillon@)
contrib/lvm2/dist/lib/device/dev-cache.c
contrib/lvm2/dist/lib/dragonfly/dev.c
contrib/lvm2/dist/libdm/libdm-deptree.c

index 403ae21..78e8698 100644 (file)
@@ -450,9 +450,6 @@ static int _insert(const char *path, int rec)
                        return_0;
                }
 #elif defined(__DragonFly__)
-               /*
-                * This never happens, but oh well...
-                */
                if (dragonfly_check_dev(MAJOR(info.st_rdev),path) < 0) {
                        log_debug("%s: Device not added to cache", path);
                        return_0;
index 93eedeb..96eea9d 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <sys/param.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 
 #include <sys/sysctl.h>
 
@@ -29,6 +30,7 @@ dragonfly_check_dev(int major, const char *path)
        struct udev_list_entry *udev_le, *udev_le_first;
        struct udev_monitor *udev_monitor;
        struct udev_device *udev_dev;
+       struct stat sb;
        const char *subsystem;
        const char *driver;
        const char *type;
@@ -36,6 +38,14 @@ dragonfly_check_dev(int major, const char *path)
 
        result = LVM_FAILURE;
 
+       /*
+        * We do the stat & devname dance to get around paths that are
+        * symlinks. udev will only find devices by their real name or
+        * devfs alias.
+        */
+       stat(path, &sb);
+       path = devname(sb.st_rdev, S_IFCHR);
+
        if (!strncmp(path, "/dev/", strlen("/dev/"))) {
                path += strlen("/dev/");
        }
index b30e856..711512b 100644 (file)
@@ -17,7 +17,7 @@
 #include "dmlib.h"
 #include "libdm-targets.h"
 #include "libdm-common.h"
-#include "kdev_t.h"
+#include "libdm-netbsd.h"
 #include "dm-ioctl.h"
 
 #include <stdarg.h>