1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Strictly require libudev if udev_sync is used.

This prevents some confusion when libudev was not found so udev_sync was disabled
automatically. Configure was successful though giving only a tiny warning.

Also, if "dmsetup udevcreatecookie" is used, never return 0x000000 as a result if
udev is not running and keep the output blank.
This commit is contained in:
Peter Rajnoha 2010-03-23 14:43:18 +00:00
parent ac3691f70e
commit 91345610f8
5 changed files with 9 additions and 42 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.46 - Version 1.02.46 -
================================ ================================
Strictly require libudev if udev_sync is used.
Add support for ioctl's DM_UEVENT_GENERATED_FLAG. Add support for ioctl's DM_UEVENT_GENERATED_FLAG.
Version 1.02.45 - 9th March 2010 Version 1.02.45 - 9th March 2010

View File

@ -650,6 +650,7 @@ UDEV_SYNC=$enableval, UDEV_SYNC=no)
AC_MSG_RESULT($UDEV_SYNC) AC_MSG_RESULT($UDEV_SYNC)
if test x$UDEV_SYNC = xyes; then if test x$UDEV_SYNC = xyes; then
AC_CHECK_LIB(udev, udev_queue_get_udev_is_active, UDEV_LIBS="-ludev", AC_MSG_ERROR(bailing out... libudev library is required))
AC_DEFINE([UDEV_SYNC_SUPPORT], 1, [Define to 1 to enable synchronisation with udev processing.]) AC_DEFINE([UDEV_SYNC_SUPPORT], 1, [Define to 1 to enable synchronisation with udev processing.])
fi fi
@ -659,23 +660,6 @@ AC_ARG_ENABLE(udev_rules, [ --enable-udev_rules Install rule files needed f
UDEV_RULES=$enableval, UDEV_RULES=$UDEV_SYNC) UDEV_RULES=$enableval, UDEV_RULES=$UDEV_SYNC)
AC_MSG_RESULT($UDEV_RULES) AC_MSG_RESULT($UDEV_RULES)
################################################################################
dnl -- Check for libudev's udev_queue_get_udev_is_active function when udev synchronisation is enabled
if test x$UDEV_SYNC = xyes; then
AC_CHECK_LIB(udev, udev_queue_get_udev_is_active, HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE=yes,
HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE=no)
if test x$HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE = xyes; then
AC_DEFINE([HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE], 1,
[Define to 1 if libudev's udev_queue_get_udev_is_active function is available.])
UDEV_LIBS="-ludev"
else
UDEV_LIBS=
AC_MSG_WARN(It won't be possible to get udev state. We will assume that udev is not running.)
fi
fi
################################################################################ ################################################################################
dnl -- Compatibility mode dnl -- Compatibility mode
AC_ARG_ENABLE(compat, [ --enable-compat Enable support for old device-mapper versions], AC_ARG_ENABLE(compat, [ --enable-compat Enable support for old device-mapper versions],

View File

@ -29,11 +29,9 @@
# include <sys/types.h> # include <sys/types.h>
# include <sys/ipc.h> # include <sys/ipc.h>
# include <sys/sem.h> # include <sys/sem.h>
#ifdef HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE
# define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE # define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
# include <libudev.h> # include <libudev.h>
#endif #endif
#endif
#ifdef linux #ifdef linux
# include <linux/fs.h> # include <linux/fs.h>
@ -922,16 +920,6 @@ int dm_udev_wait(uint32_t cookie)
static int _check_udev_is_running(void) static int _check_udev_is_running(void)
{ {
# ifndef HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE
log_debug("Could not get udev state because libudev library "
"was not found and it was not compiled in. "
"Assuming udev is not running.");
return 0;
# else /* HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE */
struct udev *udev; struct udev *udev;
struct udev_queue *udev_queue; struct udev_queue *udev_queue;
int r; int r;
@ -956,9 +944,6 @@ static int _check_udev_is_running(void)
bad: bad:
log_error("Could not get udev state. Assuming udev is not running."); log_error("Could not get udev state. Assuming udev is not running.");
return 0; return 0;
# endif /* HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE */
} }
void dm_udev_set_sync_support(int sync_with_udev) void dm_udev_set_sync_support(int sync_with_udev)
@ -1170,8 +1155,10 @@ int dm_udev_create_cookie(uint32_t *cookie)
{ {
int semid; int semid;
if (!dm_udev_get_sync_support()) if (!dm_udev_get_sync_support()) {
*cookie = 0;
return 1; return 1;
}
return _udev_notify_sem_create(cookie, &semid); return _udev_notify_sem_create(cookie, &semid);
} }

View File

@ -45,11 +45,9 @@
# include <sys/types.h> # include <sys/types.h>
# include <sys/ipc.h> # include <sys/ipc.h>
# include <sys/sem.h> # include <sys/sem.h>
#ifdef HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE
# define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE # define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
# include <libudev.h> # include <libudev.h>
#endif #endif
#endif
/* FIXME Unused so far */ /* FIXME Unused so far */
#undef HAVE_SYS_STATVFS_H #undef HAVE_SYS_STATVFS_H
@ -931,12 +929,10 @@ static int _udevcookies(int argc __attribute((unused)), char **argv __attribute(
#else /* UDEV_SYNC_SUPPORT */ #else /* UDEV_SYNC_SUPPORT */
static int _set_up_udev_support(const char *dev_dir) static int _set_up_udev_support(const char *dev_dir)
{ {
#ifdef HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE
struct udev *udev; struct udev *udev;
const char *udev_dev_dir; const char *udev_dev_dir;
size_t udev_dev_dir_len; size_t udev_dev_dir_len;
int dirs_diff; int dirs_diff;
#endif
const char *env; const char *env;
if (_switches[NOUDEVSYNC_ARG]) if (_switches[NOUDEVSYNC_ARG])
@ -955,7 +951,6 @@ static int _set_up_udev_support(const char *dev_dir)
" defined by --udevcookie option.", " defined by --udevcookie option.",
_udev_cookie); _udev_cookie);
#ifdef HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE
if (!(udev = udev_new()) || if (!(udev = udev_new()) ||
!(udev_dev_dir = udev_get_dev_path(udev)) || !(udev_dev_dir = udev_get_dev_path(udev)) ||
!*udev_dev_dir) { !*udev_dev_dir) {
@ -995,7 +990,6 @@ static int _set_up_udev_support(const char *dev_dir)
} }
udev_unref(udev); udev_unref(udev);
#endif
return 1; return 1;
} }
@ -1007,6 +1001,7 @@ static int _udevcreatecookie(int argc, char **argv,
if (!dm_udev_create_cookie(&cookie)) if (!dm_udev_create_cookie(&cookie))
return 0; return 0;
if (cookie)
printf("0x%08" PRIX32 "\n", cookie); printf("0x%08" PRIX32 "\n", cookie);
return 1; return 1;

View File

@ -42,7 +42,7 @@ extern char *optarg;
# define OPTIND_INIT 1 # define OPTIND_INIT 1
#endif #endif
#ifdef HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE #ifdef UDEV_SYNC_SUPPORT
# define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE # define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
# include <libudev.h> # include <libudev.h>
#endif #endif
@ -919,7 +919,7 @@ static void _apply_settings(struct cmd_context *cmd)
static int _set_udev_checking(struct cmd_context *cmd) static int _set_udev_checking(struct cmd_context *cmd)
{ {
#ifdef HAVE_UDEV_QUEUE_GET_UDEV_IS_ACTIVE #ifdef UDEV_SYNC
struct udev *udev; struct udev *udev;
const char *udev_dev_dir; const char *udev_dev_dir;
size_t udev_dev_dir_len; size_t udev_dev_dir_len;