mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Move _set_lvm_fallback into toolcontext, fix string comparison (/devtest
matched /dev) and note that function should go anyway as it can be overriding a valid config.
This commit is contained in:
parent
9032898eb1
commit
55f83c4399
@ -200,6 +200,51 @@ static void _init_logging(struct cmd_context *cmd)
|
|||||||
reset_lvm_errno(1);
|
reset_lvm_errno(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prevent people disabling udev fallback if using a non-standard dev dir.
|
||||||
|
* FIXME: Remove this function. lvm.conf provides sufficient control.
|
||||||
|
*/
|
||||||
|
static int _enforce_udev_fallback(struct cmd_context *cmd)
|
||||||
|
{
|
||||||
|
#ifdef UDEV_SYNC_SUPPORT
|
||||||
|
const char *udev_dev_dir;
|
||||||
|
size_t udev_dev_dir_len;
|
||||||
|
unsigned dirs_match;
|
||||||
|
|
||||||
|
if (!(udev_dev_dir = udev_get_dev_dir()) ||
|
||||||
|
!*udev_dev_dir) {
|
||||||
|
log_error("Could not get udev dev path.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
udev_dev_dir_len = strlen(udev_dev_dir);
|
||||||
|
|
||||||
|
/* There's always a slash at the end of dev_dir. But check udev_dev_dir! */
|
||||||
|
if (udev_dev_dir[udev_dev_dir_len - 1] != '/')
|
||||||
|
dirs_match = (udev_dev_dir_len + 1 == strlen(cmd->dev_dir)) &&
|
||||||
|
!strncmp(cmd->dev_dir, udev_dev_dir, udev_dev_dir_len);
|
||||||
|
else
|
||||||
|
dirs_match = !strcmp(cmd->dev_dir, udev_dev_dir);
|
||||||
|
|
||||||
|
if (!dirs_match) {
|
||||||
|
log_debug("The path %s used for creating device nodes and "
|
||||||
|
"symlinks that is set in the configuration differs "
|
||||||
|
"from the path %s that is used by udev. All warnings "
|
||||||
|
"about udev not working correctly while processing "
|
||||||
|
"particular nodes and symlinks will be suppressed. "
|
||||||
|
"These nodes and symlinks will be managed in each "
|
||||||
|
"directory separately.",
|
||||||
|
cmd->dev_dir, udev_dev_dir);
|
||||||
|
dm_udev_set_checking(0);
|
||||||
|
init_udev_checking(0);
|
||||||
|
|
||||||
|
/* Device directories differ - we must use the fallback code! */
|
||||||
|
cmd->default_settings.udev_fallback = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int _process_config(struct cmd_context *cmd)
|
static int _process_config(struct cmd_context *cmd)
|
||||||
{
|
{
|
||||||
mode_t old_umask;
|
mode_t old_umask;
|
||||||
@ -285,20 +330,23 @@ static int _process_config(struct cmd_context *cmd)
|
|||||||
"activation/udev_sync",
|
"activation/udev_sync",
|
||||||
DEFAULT_UDEV_SYNC);
|
DEFAULT_UDEV_SYNC);
|
||||||
|
|
||||||
#ifdef UDEV_SYNC_SUPPORT
|
#ifdef UDEV_SYNC_SUPPORT
|
||||||
/*
|
/*
|
||||||
* We need udev rules to be applied, otherwise we would end up with no
|
* We need udev rules to be applied, otherwise we would end up with no
|
||||||
* nodes and symlinks! However, we can disable the synchronization itself
|
* nodes and symlinks! However, we can disable the synchronization itself
|
||||||
* in runtime and still have only udev to create the nodes and symlinks
|
* in runtime and still have only udev to create the nodes and symlinks
|
||||||
* without any fallback.
|
* without any fallback.
|
||||||
*/
|
*/
|
||||||
cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ?
|
if ((cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ?
|
||||||
find_config_tree_int(cmd, "activation/verify_udev_operations",
|
find_config_tree_int(cmd, "activation/verify_udev_operations",
|
||||||
DEFAULT_VERIFY_UDEV_OPERATIONS) : 1;
|
DEFAULT_VERIFY_UDEV_OPERATIONS) : 1) &&
|
||||||
#else
|
!_enforce_udev_fallback(cmd))
|
||||||
|
return_0;
|
||||||
|
|
||||||
|
#else
|
||||||
/* We must use old node/symlink creation code if not compiled with udev support at all! */
|
/* We must use old node/symlink creation code if not compiled with udev support at all! */
|
||||||
cmd->default_settings.udev_fallback = 1;
|
cmd->default_settings.udev_fallback = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cmd->stripe_filler = find_config_tree_str(cmd,
|
cmd->stripe_filler = find_config_tree_str(cmd,
|
||||||
"activation/missing_stripe_filler",
|
"activation/missing_stripe_filler",
|
||||||
|
@ -42,10 +42,6 @@ extern char *optarg;
|
|||||||
# define OPTIND_INIT 1
|
# define OPTIND_INIT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef UDEV_SYNC_SUPPORT
|
|
||||||
# include <libudev.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Table of valid switches
|
* Table of valid switches
|
||||||
*/
|
*/
|
||||||
@ -864,8 +860,10 @@ static int _get_settings(struct cmd_context *cmd)
|
|||||||
} else
|
} else
|
||||||
init_trust_cache(0);
|
init_trust_cache(0);
|
||||||
|
|
||||||
if (arg_count(cmd, noudevsync_ARG))
|
if (arg_count(cmd, noudevsync_ARG)) {
|
||||||
cmd->current_settings.udev_sync = 0;
|
cmd->current_settings.udev_sync = 0;
|
||||||
|
cmd->current_settings.udev_fallback = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle synonyms */
|
/* Handle synonyms */
|
||||||
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
|
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
|
||||||
@ -952,47 +950,6 @@ static void _apply_settings(struct cmd_context *cmd)
|
|||||||
cmd->handles_missing_pvs = 0;
|
cmd->handles_missing_pvs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _set_udev_fallback(struct cmd_context *cmd)
|
|
||||||
{
|
|
||||||
#ifdef UDEV_SYNC_SUPPORT
|
|
||||||
const char *udev_dev_dir;
|
|
||||||
size_t udev_dev_dir_len;
|
|
||||||
int dirs_diff;
|
|
||||||
|
|
||||||
if (!(udev_dev_dir = udev_get_dev_dir()) ||
|
|
||||||
!*udev_dev_dir) {
|
|
||||||
log_error("Could not get udev dev path.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
udev_dev_dir_len = strlen(udev_dev_dir);
|
|
||||||
|
|
||||||
/* There's always a slash at the end of dev_dir. But check udev_dev_dir! */
|
|
||||||
if (udev_dev_dir[udev_dev_dir_len - 1] != '/')
|
|
||||||
dirs_diff = strncmp(cmd->dev_dir, udev_dev_dir,
|
|
||||||
udev_dev_dir_len);
|
|
||||||
else
|
|
||||||
dirs_diff = strcmp(cmd->dev_dir, udev_dev_dir);
|
|
||||||
|
|
||||||
if (dirs_diff) {
|
|
||||||
log_debug("The path %s used for creating device nodes and "
|
|
||||||
"symlinks that is set in the configuration differs "
|
|
||||||
"from the path %s that is used by udev. All warnings "
|
|
||||||
"about udev not working correctly while processing "
|
|
||||||
"particular nodes and symlinks will be suppressed. "
|
|
||||||
"These nodes and symlinks will be managed in each "
|
|
||||||
"directory separately.",
|
|
||||||
cmd->dev_dir, udev_dev_dir);
|
|
||||||
dm_udev_set_checking(0);
|
|
||||||
init_udev_checking(0);
|
|
||||||
|
|
||||||
/* Device directories differ - we must use the fallback code! */
|
|
||||||
cmd->current_settings.udev_fallback = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
|
static const char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, space;
|
int i, space;
|
||||||
@ -1091,9 +1048,6 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
log_debug("O_DIRECT will be used");
|
log_debug("O_DIRECT will be used");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!_set_udev_fallback(cmd))
|
|
||||||
goto_out;
|
|
||||||
|
|
||||||
if ((ret = _process_common_commands(cmd))) {
|
if ((ret = _process_common_commands(cmd))) {
|
||||||
if (ret != ECMD_PROCESSED)
|
if (ret != ECMD_PROCESSED)
|
||||||
stack;
|
stack;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user