public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 lib/commands/toolcontext.c tools/lvmcmdline.c
@ 2011-06-27 23:43 agk
0 siblings, 0 replies; 4+ messages in thread
From: agk @ 2011-06-27 23:43 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-06-27 23:43:04
Modified files:
lib/commands : toolcontext.c
tools : lvmcmdline.c
Log message:
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.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.143&r2=1.144
--- LVM2/lib/commands/toolcontext.c 2011/06/27 21:43:59 1.121
+++ LVM2/lib/commands/toolcontext.c 2011/06/27 23:43:04 1.122
@@ -200,6 +200,51 @@
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)
{
mode_t old_umask;
@@ -285,20 +330,23 @@
"activation/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
* nodes and symlinks! However, we can disable the synchronization itself
* in runtime and still have only udev to create the nodes and symlinks
* without any fallback.
*/
- cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ?
- find_config_tree_int(cmd, "activation/verify_udev_operations",
- DEFAULT_VERIFY_UDEV_OPERATIONS) : 1;
- #else
+ if ((cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ?
+ find_config_tree_int(cmd, "activation/verify_udev_operations",
+ DEFAULT_VERIFY_UDEV_OPERATIONS) : 1) &&
+ !_enforce_udev_fallback(cmd))
+ return_0;
+
+#else
/* We must use old node/symlink creation code if not compiled with udev support at all! */
cmd->default_settings.udev_fallback = 1;
- #endif
+#endif
cmd->stripe_filler = find_config_tree_str(cmd,
"activation/missing_stripe_filler",
--- LVM2/tools/lvmcmdline.c 2011/06/17 14:50:54 1.143
+++ LVM2/tools/lvmcmdline.c 2011/06/27 23:43:04 1.144
@@ -42,10 +42,6 @@
# define OPTIND_INIT 1
#endif
-#ifdef UDEV_SYNC_SUPPORT
-# include <libudev.h>
-#endif
-
/*
* Table of valid switches
*/
@@ -864,8 +860,10 @@
} else
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_fallback = 1;
+ }
/* Handle synonyms */
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
@@ -952,47 +950,6 @@
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)
{
int i, space;
@@ -1091,9 +1048,6 @@
log_debug("O_DIRECT will be used");
#endif
- if (!_set_udev_fallback(cmd))
- goto_out;
-
if ((ret = _process_common_commands(cmd))) {
if (ret != ECMD_PROCESSED)
stack;
^ permalink raw reply [flat|nested] 4+ messages in thread
* LVM2 lib/commands/toolcontext.c tools/lvmcmdline.c
@ 2008-12-12 3:30 wysochanski
0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2008-12-12 3:30 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2008-12-12 03:30:41
Modified files:
lib/commands : toolcontext.c
tools : lvmcmdline.c
Log message:
Create _init_globals() and call from bottom of create_toolcontext().
Move init_full_scan_done(0) and init_mirror_in_sync(0) from init_lvm()
after call to create_toolcontext() to _init_globals(), called from bottom
of create_toolcontext(). No functional change.
Author: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: James Cameron <james.cameron@hp.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87
--- LVM2/lib/commands/toolcontext.c 2008/12/11 03:36:16 1.69
+++ LVM2/lib/commands/toolcontext.c 2008/12/12 03:30:41 1.70
@@ -990,6 +990,13 @@
cmd->rand_seed = (unsigned) time(NULL) + (unsigned) getpid();
}
+static void _init_globals(struct cmd_context *cmd)
+{
+ init_full_scan_done(0);
+ init_mirror_in_sync(0);
+
+}
+
/* Entry point */
struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static,
unsigned is_long_lived)
@@ -1090,6 +1097,8 @@
_init_rand(cmd);
+ _init_globals(cmd);
+
cmd->default_settings.cache_vgmetadata = 1;
cmd->current_settings = cmd->default_settings;
--- LVM2/tools/lvmcmdline.c 2008/12/11 03:36:16 1.86
+++ LVM2/tools/lvmcmdline.c 2008/12/12 03:30:41 1.87
@@ -1091,9 +1091,6 @@
if (!(cmd = create_toolcontext(_cmdline.the_args, is_static, 0)))
return_NULL;
- init_full_scan_done(0);
- init_mirror_in_sync(0);
-
return cmd;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* LVM2 lib/commands/toolcontext.c tools/lvmcmdline.c
@ 2008-12-11 3:36 wysochanski
0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2008-12-11 3:36 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2008-12-11 03:36:16
Modified files:
lib/commands : toolcontext.c
tools : lvmcmdline.c
Log message:
Move initialization of cmd->fmt into init_formats().
init_formats() sets up the command formats, and currently sets cmd->fmt_backup
but does not set cmd->fmt to a default value. This seems incorrect so we
set it to cmd->default_settings.fmt before returning.
The call we remove here may set cmd->fmt based on a command line setting.
But it is safe to remove this, because the only caller of init_lvm() that
cares about the cmdline override is the cmdline tools (clvmd does not care),
called from lvm2_main(). After lvm2_main() calls init_lvm(), it later calls
lvm_run_command(). In lvm_run_command(), we have a call to _apply_settings(),
which has the identical assignment of cmd->fmt that this patch removes.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86
--- LVM2/lib/commands/toolcontext.c 2008/12/11 03:33:35 1.68
+++ LVM2/lib/commands/toolcontext.c 2008/12/11 03:36:16 1.69
@@ -784,6 +784,7 @@
if (!strcasecmp(fmt->name, format) ||
(fmt->alias && !strcasecmp(fmt->alias, format))) {
cmd->default_settings.fmt = fmt;
+ cmd->fmt = cmd->default_settings.fmt;
return 1;
}
}
--- LVM2/tools/lvmcmdline.c 2008/12/11 03:34:43 1.85
+++ LVM2/tools/lvmcmdline.c 2008/12/11 03:36:16 1.86
@@ -1094,9 +1094,6 @@
init_full_scan_done(0);
init_mirror_in_sync(0);
- cmd->fmt = arg_ptr_value(cmd, metadatatype_ARG,
- cmd->current_settings.fmt);
-
return cmd;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* LVM2 lib/commands/toolcontext.c tools/lvmcmdline.c
@ 2008-12-11 3:31 wysochanski
0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2008-12-11 3:31 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2008-12-11 03:31:47
Modified files:
lib/commands : toolcontext.c
tools : lvmcmdline.c
Log message:
Move init_test() from _apply_settings into _init_logging().
This one we actually need to move. _init_logging() is called from
create_toolcontext(), which makes this call:
/* Test mode */
cmd->default_settings.test =
find_config_tree_int(cmd, "global/test", 0);
But it does not call init_test(). So we need an init_test() somewhere.
The most logical place is to put it inside _init_logging(), since this
is where the config value is read and default_settings are set. Placing
the init_test() call here matches what is done with other variables and
seems to make sense.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81
--- LVM2/lib/commands/toolcontext.c 2008/12/07 04:27:56 1.65
+++ LVM2/lib/commands/toolcontext.c 2008/12/11 03:31:47 1.66
@@ -162,6 +162,7 @@
/* Test mode */
cmd->default_settings.test =
find_config_tree_int(cmd, "global/test", 0);
+ init_test(cmd->default_settings.test);
/* Settings for logging to file */
if (find_config_tree_int(cmd, "log/overwrite", DEFAULT_OVERWRITE))
--- LVM2/tools/lvmcmdline.c 2008/12/11 03:31:10 1.80
+++ LVM2/tools/lvmcmdline.c 2008/12/11 03:31:47 1.81
@@ -1091,7 +1091,6 @@
if (!(cmd = create_toolcontext(_cmdline.the_args, is_static, 0)))
return_NULL;
- init_test(cmd->current_settings.test);
init_full_scan_done(0);
init_mirror_in_sync(0);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-27 23:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-27 23:43 LVM2 lib/commands/toolcontext.c tools/lvmcmdline.c agk
-- strict thread matches above, loose matches on Subject: below --
2008-12-12 3:30 wysochanski
2008-12-11 3:36 wysochanski
2008-12-11 3:31 wysochanski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).