esac
fi
-# TODO remove devmapper from blkid
-#
-AC_ARG_ENABLE([blkid-devmapper],
- AS_HELP_STRING([--enable-blkid-devmapper], [build with device-mapper support]),
- [], with_blkid-devmapper=no
-)
-if test x$with_devmapper = xno; then
- AC_MSG_RESULT([Disabling device-mapper support])
- AM_CONDITIONAL(HAVE_DEVMAPPER, false)
- DEVMAPPER_LIBS_STATIC=''
- DEVMAPPER_REQ=''
- DEVMAPPER_PC_LIBS=''
- DEVMAPPER_LIBS=''
-else
- AC_MSG_RESULT([Enabling device-mapper support])
- UTIL_CHECK_LIB(devmapper, dm_tree_create)
- case $with_blkid-devmapper:$have_blkid-devmapper in
- yes:no) AC_MSG_ERROR([devmapper selected but libdevmapper not found]);;
- esac
- UTIL_PKG_STATIC([DEVMAPPER_LIBS_STATIC], [devmapper])
- DEVMAPPER_LIBS="-ldevmapper"
- DEVMAPPER_REQ="devmapper"
- DEVMAPPER_PC_LIBS="-ldevmapper"
-
- # work around stupid devmapper.pc bug in Debian
- case "$DEVMAPPER_LIBS_STATIC" in
- *pthread*)
- ;;
- *)
- AC_MSG_WARN([Working around Debian bug 390243...])
- DEVMAPPER_LIBS_STATIC="-pthread $DEVMAPPER_LIBS_STATIC"
- ;;
- esac
-fi
-
-AC_SUBST([DEVMAPPER_LIBS])
-AC_SUBST([DEVMAPPER_REQ])
-AC_SUBST([DEVMAPPER_PC_LIBS])
-AC_SUBST([DEVMAPPER_LIBS_STATIC])
-
-
AC_ARG_ENABLE([schedutils],
AS_HELP_STRING([--disable-schedutils], [do not build chrt, ionice, teskset]),
[], enable_schedutils=yes
#include "blkidP.h"
-#undef HAVE_DEVMAPPER
-
-#ifdef HAVE_DEVMAPPER
-#include <libdevmapper.h>
-#endif
-
/*
* Find a dev struct in the cache by device name, if available.
*
return dev;
}
-#ifdef HAVE_DEVMAPPER
-static int dm_device_is_leaf(const dev_t dev);
-#endif
-
/* Directories where we will try to search for device names */
static const char *dirlist[] = { "/dev", "/devfs", "/devices", NULL };
list_for_each_safe(p, pnext, &cache->bic_devs) {
blkid_dev tmp = list_entry(p, struct blkid_struct_dev,
bid_devs);
-#ifdef HAVE_DEVMAPPER
- if (!dm_device_is_leaf(devno))
- continue;
-#endif
if (tmp->bid_devno == devno) {
if (only_if_new && !access(tmp->bid_name, F_OK))
return;
return;
}
-#ifdef HAVE_DEVMAPPER
-static void dm_quiet_log(int level __BLKID_ATTR((unused)),
- const char *file __BLKID_ATTR((unused)),
- int line __BLKID_ATTR((unused)),
- const char *f __BLKID_ATTR((unused)), ...)
-{
- return;
-}
-
-/*
- * device-mapper support
- */
-static int dm_device_has_dep(const dev_t dev, const char *name)
-{
- struct dm_task *task;
- struct dm_deps *deps;
- struct dm_info info;
- unsigned int i;
- int ret = 0;
-
- task = dm_task_create(DM_DEVICE_DEPS);
- if (!task)
- goto out;
-
- if (!dm_task_set_name(task, name))
- goto out;
-
- if (!dm_task_run(task))
- goto out;
-
- if (!dm_task_get_info(task, &info))
- goto out;
-
- if (!info.exists)
- goto out;
-
- deps = dm_task_get_deps(task);
- if (!deps || deps->count == 0)
- goto out;
-
- for (i = 0; i < deps->count; i++) {
- dev_t dep_dev = deps->device[i];
-
- if (dev == dep_dev) {
- ret = 1;
- goto out;
- }
- }
-
-out:
- if (task)
- dm_task_destroy(task);
-
- return ret;
-}
-
-static int dm_device_is_leaf(const dev_t dev)
-{
- struct dm_task *task;
- struct dm_names *names;
- unsigned int next = 0;
- int n, ret = 1;
-
- dm_log_init(dm_quiet_log);
- task = dm_task_create(DM_DEVICE_LIST);
- if (!task)
- goto out;
-
- dm_log_init(0);
-
- if (!dm_task_run(task))
- goto out;
-
- names = dm_task_get_names(task);
- if (!names || !names->dev)
- goto out;
-
- n = 0;
- do {
- names = (struct dm_names *) ((char *)names + next);
-
- if (dm_device_has_dep(dev, names->name))
- ret = 0;
-
- next = names->next;
- } while (next);
-
-out:
- if (task)
- dm_task_destroy(task);
-
- return ret;
-}
-
-static dev_t dm_get_devno(const char *name)
-{
- struct dm_task *task;
- struct dm_info info;
- dev_t ret = 0;
-
- task = dm_task_create(DM_DEVICE_INFO);
- if (!task)
- goto out;
-
- if (!dm_task_set_name(task, name))
- goto out;
-
- if (!dm_task_run(task))
- goto out;
-
- if (!dm_task_get_info(task, &info))
- goto out;
-
- if (!info.exists)
- goto out;
-
- ret = makedev(info.major, info.minor);
-
-out:
- if (task)
- dm_task_destroy(task);
-
- return ret;
-}
-
-static void dm_probe_all(blkid_cache cache, int only_if_new)
-{
- struct dm_task *task;
- struct dm_names *names;
- unsigned int next = 0;
- int n;
-
- dm_log_init(dm_quiet_log);
- task = dm_task_create(DM_DEVICE_LIST);
- if (!task)
- goto out;
- dm_log_init(0);
-
- if (!dm_task_run(task))
- goto out;
-
- names = dm_task_get_names(task);
- if (!names || !names->dev)
- goto out;
-
- n = 0;
- do {
- int rc;
- char *device = NULL;
- dev_t dev = 0;
-
- names = (struct dm_names *) ((char *)names + next);
-
- rc = asprintf(&device, "mapper/%s", names->name);
- if (rc < 0)
- goto try_next;
-
- dev = dm_get_devno(names->name);
- if (dev == 0)
- goto try_next;
-
- if (!dm_device_is_leaf(dev))
- goto try_next;
-
- probe_one(cache, device, dev, BLKID_PRI_DM, only_if_new);
-
-try_next:
- free(device);
- next = names->next;
- } while (next);
-
-out:
- if (task)
- dm_task_destroy(task);
-}
-#endif /* HAVE_DEVMAPPER */
-
#define PROC_PARTITIONS "/proc/partitions"
#define VG_DIR "/proc/lvm/VGs"
return 0;
blkid_read_cache(cache);
-#ifdef HAVE_DEVMAPPER
- dm_probe_all(cache, only_if_new);
-#endif
evms_probe_all(cache, only_if_new);
#ifdef VG_DIR
lvm_probe_all(cache, only_if_new);