From: Alex Hornung Date: Sat, 14 Aug 2010 08:37:54 +0000 (+0100) Subject: libdm/lvm - Fix bugs X-Git-Tag: v2.9.0~536 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/b060a5b0d718699ca45a07a72aa67f18fa62e0f0 libdm/lvm - Fix bugs * 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@) --- diff --git a/contrib/lvm2/dist/lib/device/dev-cache.c b/contrib/lvm2/dist/lib/device/dev-cache.c index 403ae213f4..78e8698267 100644 --- a/contrib/lvm2/dist/lib/device/dev-cache.c +++ b/contrib/lvm2/dist/lib/device/dev-cache.c @@ -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; diff --git a/contrib/lvm2/dist/lib/dragonfly/dev.c b/contrib/lvm2/dist/lib/dragonfly/dev.c index 93eedebf73..96eea9d6b0 100644 --- a/contrib/lvm2/dist/lib/dragonfly/dev.c +++ b/contrib/lvm2/dist/lib/dragonfly/dev.c @@ -4,6 +4,7 @@ #include #include +#include #include @@ -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/"); } diff --git a/contrib/lvm2/dist/libdm/libdm-deptree.c b/contrib/lvm2/dist/libdm/libdm-deptree.c index b30e856c2b..711512b3ac 100644 --- a/contrib/lvm2/dist/libdm/libdm-deptree.c +++ b/contrib/lvm2/dist/libdm/libdm-deptree.c @@ -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