Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 424810
Collapse All | Expand All

(-)a/lib/commands/toolcontext.c (-12 / +16 lines)
Lines 650-658 static int _init_dev_cache(struct cmd_context *cmd) Link Here
650
{
650
{
651
	const struct dm_config_node *cn;
651
	const struct dm_config_node *cn;
652
	const struct dm_config_value *cv;
652
	const struct dm_config_value *cv;
653
	size_t uninitialized_var(udev_dir_len), len;
653
	size_t len, udev_dir_len = strlen(DM_UDEV_DEV_DIR);
654
	int len_diff;
654
	int device_list_from_udev;
655
	int device_list_from_udev;
655
	const char *uninitialized_var(udev_dir);
656
656
657
	init_dev_disable_after_error_count(
657
	init_dev_disable_after_error_count(
658
		find_config_tree_int(cmd, "devices/disable_after_error_count",
658
		find_config_tree_int(cmd, "devices/disable_after_error_count",
Lines 661-673 static int _init_dev_cache(struct cmd_context *cmd) Link Here
661
	if (!dev_cache_init(cmd))
661
	if (!dev_cache_init(cmd))
662
		return_0;
662
		return_0;
663
663
664
	if ((device_list_from_udev = udev_is_running() ?
664
	device_list_from_udev = udev_is_running() ?
665
		find_config_tree_bool(cmd, "devices/obtain_device_list_from_udev",
665
		find_config_tree_bool(cmd, "devices/obtain_device_list_from_udev",
666
				      DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV) : 0)) {
666
				      DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV) : 0;
667
		if (!(udev_dir = udev_get_dev_dir()))
668
			stack;
669
		udev_dir_len = (udev_dir) ? strlen(udev_dir) : 0;
670
	}
671
	init_obtain_device_list_from_udev(device_list_from_udev);
667
	init_obtain_device_list_from_udev(device_list_from_udev);
672
668
673
	if (!(cn = find_config_tree_node(cmd, "devices/scan"))) {
669
	if (!(cn = find_config_tree_node(cmd, "devices/scan"))) {
Lines 688-698 static int _init_dev_cache(struct cmd_context *cmd) Link Here
688
			return 0;
684
			return 0;
689
		}
685
		}
690
686
691
		if (device_list_from_udev && udev_dir) {
687
		if (device_list_from_udev) {
692
			len = strlen(cv->v.str);
688
			len = strlen(cv->v.str);
693
			len = udev_dir_len > len ? len : udev_dir_len;
689
694
			if (strncmp(udev_dir, cv->v.str, len) ||
690
			/*
695
			    udev_dir[len] != cv->v.str[len]) {
691
			 * DM_UDEV_DEV_DIR always has '/' at its end.
692
			 * If the item in the conf does not have it, be sure
693
			 * to make the right comparison without the '/' char!
694
			 */
695
			len_diff = len && cv->v.str[len - 1] != '/' ?
696
					udev_dir_len - 1 != len :
697
					udev_dir_len != len;
698
699
			if (len_diff || strncmp(DM_UDEV_DEV_DIR, cv->v.str, len)) {
696
				device_list_from_udev = 0;
700
				device_list_from_udev = 0;
697
				init_obtain_device_list_from_udev(0);
701
				init_obtain_device_list_from_udev(0);
698
			}
702
			}
(-)a/lib/misc/lvm-wrappers.c (-14 lines)
Lines 65-80 bad: Link Here
65
	return 0;
65
	return 0;
66
}
66
}
67
67
68
const char *udev_get_dev_dir(void)
69
{
70
	if (!_udev) {
71
		log_debug(_no_context_msg);
72
		return NULL;
73
	}
74
75
	return udev_get_dev_path(_udev);
76
}
77
78
struct udev* udev_get_library_context(void)
68
struct udev* udev_get_library_context(void)
79
{
69
{
80
	return _udev;
70
	return _udev;
Lines 96-105 int udev_is_running(void) Link Here
96
	return 0;
86
	return 0;
97
}
87
}
98
88
99
const char *udev_get_dev_dir(void)
100
{
101
	return NULL;
102
}
103
#endif
89
#endif
104
90
105
int lvm_getpagesize(void)
91
int lvm_getpagesize(void)
(-)a/lib/misc/lvm-wrappers.h (-1 lines)
Lines 24-30 struct udev *udev_get_library_context(void); Link Here
24
int udev_init_library_context(void);
24
int udev_init_library_context(void);
25
void udev_fin_library_context(void);
25
void udev_fin_library_context(void);
26
int udev_is_running(void);
26
int udev_is_running(void);
27
const char *udev_get_dev_dir(void);
28
27
29
int lvm_getpagesize(void);
28
int lvm_getpagesize(void);
30
29
(-)a/libdm/libdevmapper.h (+3 lines)
Lines 1500-1505 struct dm_config_node *dm_config_clone_node(struct dm_config_tree *cft, const st Link Here
1500
1500
1501
struct dm_pool *dm_config_memory(struct dm_config_tree *cft);
1501
struct dm_pool *dm_config_memory(struct dm_config_tree *cft);
1502
1502
1503
/* Udev device directory. */
1504
#define DM_UDEV_DEV_DIR "/dev/"
1505
1503
/* Cookie prefixes.
1506
/* Cookie prefixes.
1504
 *
1507
 *
1505
 * The cookie value consists of a prefix (16 bits) and a base (16 bits).
1508
 * The cookie value consists of a prefix (16 bits) and a base (16 bits).
(-)a/tools/dmsetup.c (-18 / +12 lines)
Lines 1008-1018 static int _udevcookies(CMD_ARGS) Link Here
1008
#else	/* UDEV_SYNC_SUPPORT */
1008
#else	/* UDEV_SYNC_SUPPORT */
1009
static int _set_up_udev_support(const char *dev_dir)
1009
static int _set_up_udev_support(const char *dev_dir)
1010
{
1010
{
1011
	struct udev *udev;
1012
	const char *udev_dev_dir;
1013
	size_t udev_dev_dir_len;
1014
	int dirs_diff;
1011
	int dirs_diff;
1015
	const char *env;
1012
	const char *env;
1013
	size_t len = strlen(dev_dir), udev_dir_len = strlen(DM_UDEV_DEV_DIR);
1016
1014
1017
	if (_switches[NOUDEVSYNC_ARG])
1015
	if (_switches[NOUDEVSYNC_ARG])
1018
		dm_udev_set_sync_support(0);
1016
		dm_udev_set_sync_support(0);
Lines 1030-1043 static int _set_up_udev_support(const char *dev_dir) Link Here
1030
			  " defined by --udevcookie option.",
1028
			  " defined by --udevcookie option.",
1031
			  _udev_cookie);
1029
			  _udev_cookie);
1032
1030
1033
	if (!(udev = udev_new()) ||
1034
	    !(udev_dev_dir = udev_get_dev_path(udev)) ||
1035
	    !*udev_dev_dir) {
1036
		log_error("Could not get udev dev path.");
1037
		return 0;
1038
	}
1039
	udev_dev_dir_len = strlen(udev_dev_dir);
1040
1041
	/*
1031
	/*
1042
	 * Normally, there's always a fallback action by libdevmapper if udev
1032
	 * Normally, there's always a fallback action by libdevmapper if udev
1043
	 * has not done its job correctly, e.g. the nodes were not created.
1033
	 * has not done its job correctly, e.g. the nodes were not created.
Lines 1049-1060 static int _set_up_udev_support(const char *dev_dir) Link Here
1049
	 * is the same as "dev path" used by libdevmapper.
1039
	 * is the same as "dev path" used by libdevmapper.
1050
	 */
1040
	 */
1051
1041
1052
	/* There's always a slash at the end of dev_dir. But check udev_dev_dir! */
1053
	if (udev_dev_dir[udev_dev_dir_len - 1] != '/')
1054
		dirs_diff = strncmp(dev_dir, udev_dev_dir, udev_dev_dir_len);
1055
	else
1056
		dirs_diff = strcmp(dev_dir, udev_dev_dir);
1057
1042
1043
	/*
1044
	 * DM_UDEV_DEV_DIR always has '/' at its end.
1045
	 * If the dev_dir does not have it, be sure
1046
	 * to make the right comparison without the '/' char!
1047
	 */
1048
	if (dev_dir[len - 1] != '/')
1049
		udev_dir_len--;
1050
1051
	dirs_diff = udev_dir_len != len ||
1052
		    strncmp(DM_UDEV_DEV_DIR, dev_dir, len);
1058
	_udev_only = !dirs_diff && (_udev_cookie || !_switches[VERIFYUDEV_ARG]);
1053
	_udev_only = !dirs_diff && (_udev_cookie || !_switches[VERIFYUDEV_ARG]);
1059
1054
1060
	if (dirs_diff) {
1055
	if (dirs_diff) {
Lines 1064-1074 static int _set_up_udev_support(const char *dev_dir) Link Here
1064
			  "about udev not working correctly while processing "
1059
			  "about udev not working correctly while processing "
1065
			  "particular nodes will be suppressed. These nodes "
1060
			  "particular nodes will be suppressed. These nodes "
1066
			  "and symlinks will be managed in each directory "
1061
			  "and symlinks will be managed in each directory "
1067
			  "separately.", dev_dir, udev_dev_dir);
1062
			  "separately.", dev_dir, DM_UDEV_DEV_DIR);
1068
		dm_udev_set_checking(0);
1063
		dm_udev_set_checking(0);
1069
	}
1064
	}
1070
1065
1071
	udev_unref(udev);
1072
	return 1;
1066
	return 1;
1073
}
1067
}
1074
1068

Return to bug 424810