public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 daemons/clvmd/lvm-functions.c lib/command ...
@ 2008-12-17 16:46 wysochanski
  0 siblings, 0 replies; 3+ messages in thread
From: wysochanski @ 2008-12-17 16:46 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-12-17 16:46:45

Modified files:
	daemons/clvmd  : lvm-functions.c 
	lib/commands   : toolcontext.c toolcontext.h 
	lib            : lvm2.h 
	tools          : lvmcmdline.c 

Log message:
	Remove struct arg * from struct cmd_context and create_toolcontext().
	
	This allows us to remove one argument from create_toolcontext() and
	moves it closer to a generic library init function.
	
	In the arg_*() functions, we just use _the_args() directly.
	For now we leave the first parameter to these
	arg_*() functions (struct cmd_context *) because
	of the number of files involved in removing the
	parameter.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/lvm2.h.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89

--- LVM2/daemons/clvmd/lvm-functions.c	2008/12/11 03:34:12	1.53
+++ LVM2/daemons/clvmd/lvm-functions.c	2008/12/17 16:46:45	1.54
@@ -724,7 +724,7 @@
 /* Called to initialise the LVM context of the daemon */
 int init_lvm(int using_gulm)
 {
-	if (!(cmd = create_toolcontext(NULL, 0, 1))) {
+	if (!(cmd = create_toolcontext(0, 1))) {
 		log_error("Failed to allocate command context");
 		return 0;
 	}
--- LVM2/lib/commands/toolcontext.c	2008/12/12 03:30:41	1.70
+++ LVM2/lib/commands/toolcontext.c	2008/12/17 16:46:45	1.71
@@ -998,7 +998,7 @@
 }
 
 /* Entry point */
-struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static,
+struct cmd_context *create_toolcontext(unsigned is_static,
 				       unsigned is_long_lived)
 {
 	struct cmd_context *cmd;
@@ -1021,7 +1021,6 @@
 		return NULL;
 	}
 	memset(cmd, 0, sizeof(*cmd));
-	cmd->args = the_args;
 	cmd->is_static = is_static;
 	cmd->is_long_lived = is_long_lived;
 	cmd->handles_missing_pvs = 0;
--- LVM2/lib/commands/toolcontext.h	2008/12/07 04:27:56	1.28
+++ LVM2/lib/commands/toolcontext.h	2008/12/17 16:46:45	1.29
@@ -65,7 +65,6 @@
 	unsigned rand_seed;
 	char *cmd_line;
 	struct command *command;
-	struct arg *args;
 	char **argv;
 	unsigned is_static:1;	/* Static binary? */
 	unsigned is_long_lived:1;	/* Optimises persistent_filter handling */
@@ -96,7 +95,7 @@
 	char sysfs_dir[PATH_MAX];
 };
 
-struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static, unsigned is_long_lived);
+struct cmd_context *create_toolcontext(unsigned is_static, unsigned is_long_lived);
 void destroy_toolcontext(struct cmd_context *cmd);
 int refresh_toolcontext(struct cmd_context *cmd);
 int config_files_changed(struct cmd_context *cmd);
--- LVM2/lib/lvm2.h	2008/12/07 19:37:07	1.1
+++ LVM2/lib/lvm2.h	2008/12/17 16:46:45	1.2
@@ -24,7 +24,7 @@
  */
 struct arg;
 struct cmd_context;
-struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static, unsigned is_long_lived);
+struct cmd_context *create_toolcontext(unsigned is_static, unsigned is_long_lived);
 void destroy_toolcontext(struct cmd_context *cmd);
 
 /*
@@ -37,7 +37,7 @@
  * NULL: Fail - unable to initialise handle.
  * non-NULL: Success - valid LVM2 handle returned
  */
-#define lvm2_create(X) create_toolcontext(NULL,0,1)
+#define lvm2_create(X) create_toolcontext(0,1)
 
 /*
  * lvm2_destroy
--- LVM2/tools/lvmcmdline.c	2008/12/17 16:45:32	1.88
+++ LVM2/tools/lvmcmdline.c	2008/12/17 16:46:45	1.89
@@ -54,59 +54,68 @@
 static struct cmdline_context _cmdline;
 
 /* Command line args */
-unsigned arg_count(const struct cmd_context *cmd, int a)
+/* FIXME: struct cmd_context * is unnecessary (large # files ) */
+unsigned arg_count(const struct cmd_context *cmd __attribute((unused)), int a)
 {
-	return cmd->args[a].count;
+	return _the_args[a].count;
 }
 
-const char *arg_value(struct cmd_context *cmd, int a)
+const char *arg_value(struct cmd_context *cmd __attribute((unused)), int a)
 {
-	return cmd->args[a].value;
+	return _the_args[a].value;
 }
 
-const char *arg_str_value(struct cmd_context *cmd, int a, const char *def)
+const char *arg_str_value(struct cmd_context *cmd __attribute((unused)),
+			  int a, const char *def)
 {
-	return arg_count(cmd, a) ? cmd->args[a].value : def;
+	return arg_count(cmd, a) ? _the_args[a].value : def;
 }
 
-int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def)
+int32_t arg_int_value(struct cmd_context *cmd __attribute((unused)),
+		      int a, const int32_t def)
 {
-	return arg_count(cmd, a) ? cmd->args[a].i_value : def;
+	return arg_count(cmd, a) ? _the_args[a].i_value : def;
 }
 
-uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def)
+uint32_t arg_uint_value(struct cmd_context *cmd __attribute((unused)),
+			int a, const uint32_t def)
 {
-	return arg_count(cmd, a) ? cmd->args[a].ui_value : def;
+	return arg_count(cmd, a) ? _the_args[a].ui_value : def;
 }
 
-int64_t arg_int64_value(struct cmd_context *cmd, int a, const int64_t def)
+int64_t arg_int64_value(struct cmd_context *cmd __attribute((unused)),
+			int a, const int64_t def)
 {
-	return arg_count(cmd, a) ? cmd->args[a].i64_value : def;
+	return arg_count(cmd, a) ? _the_args[a].i64_value : def;
 }
 
-uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def)
+uint64_t arg_uint64_value(struct cmd_context *cmd __attribute((unused)),
+			  int a, const uint64_t def)
 {
-	return arg_count(cmd, a) ? cmd->args[a].ui64_value : def;
+	return arg_count(cmd, a) ? _the_args[a].ui64_value : def;
 }
 
-const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def)
+const void *arg_ptr_value(struct cmd_context *cmd __attribute((unused)),
+			  int a, const void *def)
 {
-	return arg_count(cmd, a) ? cmd->args[a].ptr : def;
+	return arg_count(cmd, a) ? _the_args[a].ptr : def;
 }
 
-sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def)
+sign_t arg_sign_value(struct cmd_context *cmd __attribute((unused)),
+		      int a, const sign_t def)
 {
-	return arg_count(cmd, a) ? cmd->args[a].sign : def;
+	return arg_count(cmd, a) ? _the_args[a].sign : def;
 }
 
-percent_t arg_percent_value(struct cmd_context *cmd, int a, const percent_t def)
+percent_t arg_percent_value(struct cmd_context *cmd __attribute((unused)),
+			    int a, const percent_t def)
 {
-	return arg_count(cmd, a) ? cmd->args[a].percent : def;
+	return arg_count(cmd, a) ? _the_args[a].percent : def;
 }
 
-int arg_count_increment(struct cmd_context *cmd, int a)
+int arg_count_increment(struct cmd_context *cmd __attribute((unused)), int a)
 {
-	return cmd->args[a].count++;
+	return _the_args[a].count++;
 }
 
 int yes_no_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
@@ -1144,7 +1153,7 @@
 
 	_cmdline.the_args = &_the_args[0];
 
-	if (!(cmd = create_toolcontext(_cmdline.the_args, is_static, 0)))
+	if (!(cmd = create_toolcontext(is_static, 0)))
 		return_NULL;
 
 	return cmd;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* LVM2 daemons/clvmd/lvm-functions.c lib/command ...
@ 2008-12-11  3:33 wysochanski
  0 siblings, 0 replies; 3+ messages in thread
From: wysochanski @ 2008-12-11  3:33 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-12-11 03:33:35

Modified files:
	daemons/clvmd  : lvm-functions.c 
	lib/commands   : toolcontext.c 
	lib/format_text: archiver.c archiver.h 
	tools          : lvmcmdline.c 

Log message:
	Remove backup_enable() calls after create_toolcontext() calls.
	
	Identical argument to previous patch which removed archive_enable() calls.
	We add a new parameter to backup_init() which sets the enable value based
	on the cmd->default_settings.backup value.  This value was used to set
	cmd->current_settings.backup, used in the removed backup_enable() call.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83

--- LVM2/daemons/clvmd/lvm-functions.c	2008/12/11 03:32:56	1.51
+++ LVM2/daemons/clvmd/lvm-functions.c	2008/12/11 03:33:35	1.52
@@ -733,7 +733,6 @@
 	init_syslog(LOG_DAEMON);
 	openlog("clvmd", LOG_PID, LOG_DAEMON);
 	set_activation(cmd->current_settings.activation);
-	backup_enable(cmd, cmd->current_settings.backup);
 	cmd->cmd_line = (char *)"clvmd";
 
 	/* Check lvm.conf is setup for cluster-LVM */
--- LVM2/lib/commands/toolcontext.c	2008/12/11 03:32:57	1.67
+++ LVM2/lib/commands/toolcontext.c	2008/12/11 03:33:35	1.68
@@ -925,7 +925,7 @@
 
 	if (!cmd->sys_dir) {
 		log_warn("WARNING: Metadata changes will NOT be backed up");
-		backup_init(cmd, "");
+		backup_init(cmd, "", 0);
 		archive_init(cmd, "", 0, 0, 0);
 		return 1;
 	}
@@ -973,7 +973,7 @@
 
 	dir = find_config_tree_str(cmd, "backup/backup_dir", default_dir);
 
-	if (!backup_init(cmd, dir)) {
+	if (!backup_init(cmd, dir, cmd->default_settings.backup)) {
 		log_debug("backup_init failed.");
 		return 0;
 	}
--- LVM2/lib/format_text/archiver.c	2008/12/11 03:32:57	1.16
+++ LVM2/lib/format_text/archiver.c	2008/12/11 03:33:35	1.17
@@ -150,7 +150,8 @@
 	return r;
 }
 
-int backup_init(struct cmd_context *cmd, const char *dir)
+int backup_init(struct cmd_context *cmd, const char *dir,
+		int enabled)
 {
 	if (!(cmd->backup_params = dm_pool_zalloc(cmd->libmem,
 					       sizeof(*cmd->archive_params)))) {
@@ -166,6 +167,7 @@
 		log_error("Couldn't copy backup directory name.");
 		return 0;
 	}
+	backup_enable(cmd, enabled);
 
 	return 1;
 }
--- LVM2/lib/format_text/archiver.h	2008/12/11 03:32:57	1.5
+++ LVM2/lib/format_text/archiver.h	2008/12/11 03:33:35	1.6
@@ -41,7 +41,7 @@
 int archive_display(struct cmd_context *cmd, const char *vg_name);
 int archive_display_file(struct cmd_context *cmd, const char *file);
 
-int backup_init(struct cmd_context *cmd, const char *dir);
+int backup_init(struct cmd_context *cmd, const char *dir, int enabled);
 void backup_exit(struct cmd_context *cmd);
 
 void backup_enable(struct cmd_context *cmd, int flag);
--- LVM2/tools/lvmcmdline.c	2008/12/11 03:32:57	1.82
+++ LVM2/tools/lvmcmdline.c	2008/12/11 03:33:35	1.83
@@ -1097,8 +1097,6 @@
 	init_msg_prefix(cmd->default_settings.msg_prefix);
 	init_cmd_name(cmd->default_settings.cmd_name);
 
-	backup_enable(cmd, cmd->current_settings.backup);
-
 	set_activation(cmd->current_settings.activation);
 
 	cmd->fmt = arg_ptr_value(cmd, metadatatype_ARG,


^ permalink raw reply	[flat|nested] 3+ messages in thread

* LVM2 daemons/clvmd/lvm-functions.c lib/command ...
@ 2008-12-11  3:32 wysochanski
  0 siblings, 0 replies; 3+ messages in thread
From: wysochanski @ 2008-12-11  3:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-12-11 03:32:57

Modified files:
	daemons/clvmd  : lvm-functions.c 
	lib/commands   : toolcontext.c 
	lib/format_text: archiver.c archiver.h 
	tools          : lvmcmdline.c 

Log message:
	Remove archive_enable() calls after create_toolcontext() calls.
	
	_init_backup() calls archive_init(), which originally set 'enabled' to
	a hardcoded '1' value.  This seems incorrect based on my read of other
	areas of the code so here we add a 'enabled' paramter to archive_init().
	We pass in cmd->default_settings.archive, which is obtained from the
	config tree.  Later in create_toolcontext, cmd->current_settings is
	set to cmd->default_settings.  The archive_enable() call we remove
	here was using cmd->current_settings to set the 'archive' enable
	value.  The final value of cmd->archive_params->enabled should thus
	be equivalent to the original code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82

--- LVM2/daemons/clvmd/lvm-functions.c	2008/12/11 03:30:19	1.50
+++ LVM2/daemons/clvmd/lvm-functions.c	2008/12/11 03:32:56	1.51
@@ -733,7 +733,6 @@
 	init_syslog(LOG_DAEMON);
 	openlog("clvmd", LOG_PID, LOG_DAEMON);
 	set_activation(cmd->current_settings.activation);
-	archive_enable(cmd, cmd->current_settings.archive);
 	backup_enable(cmd, cmd->current_settings.backup);
 	cmd->cmd_line = (char *)"clvmd";
 
--- LVM2/lib/commands/toolcontext.c	2008/12/11 03:31:47	1.66
+++ LVM2/lib/commands/toolcontext.c	2008/12/11 03:32:57	1.67
@@ -926,7 +926,7 @@
 	if (!cmd->sys_dir) {
 		log_warn("WARNING: Metadata changes will NOT be backed up");
 		backup_init(cmd, "");
-		archive_init(cmd, "", 0, 0);
+		archive_init(cmd, "", 0, 0, 0);
 		return 1;
 	}
 
@@ -952,7 +952,8 @@
 	dir = find_config_tree_str(cmd, "backup/archive_dir",
 			      default_dir);
 
-	if (!archive_init(cmd, dir, days, min)) {
+	if (!archive_init(cmd, dir, days, min,
+			  cmd->default_settings.archive)) {
 		log_debug("backup_init failed.");
 		return 0;
 	}
--- LVM2/lib/format_text/archiver.c	2008/11/03 22:14:28	1.15
+++ LVM2/lib/format_text/archiver.c	2008/12/11 03:32:57	1.16
@@ -36,7 +36,8 @@
 };
 
 int archive_init(struct cmd_context *cmd, const char *dir,
-		 unsigned int keep_days, unsigned int keep_min)
+		 unsigned int keep_days, unsigned int keep_min,
+		 int enabled)
 {
 	if (!(cmd->archive_params = dm_pool_zalloc(cmd->libmem,
 						sizeof(*cmd->archive_params)))) {
@@ -56,7 +57,7 @@
 
 	cmd->archive_params->keep_days = keep_days;
 	cmd->archive_params->keep_number = keep_min;
-	cmd->archive_params->enabled = 1;
+	archive_enable(cmd, enabled);
 
 	return 1;
 }
--- LVM2/lib/format_text/archiver.h	2007/08/20 20:55:26	1.4
+++ LVM2/lib/format_text/archiver.h	2008/12/11 03:32:57	1.5
@@ -32,7 +32,8 @@
  */
 
 int archive_init(struct cmd_context *cmd, const char *dir,
-		 unsigned int keep_days, unsigned int keep_min);
+		 unsigned int keep_days, unsigned int keep_min,
+		 int enabled);
 void archive_exit(struct cmd_context *cmd);
 
 void archive_enable(struct cmd_context *cmd, int flag);
--- LVM2/tools/lvmcmdline.c	2008/12/11 03:31:47	1.81
+++ LVM2/tools/lvmcmdline.c	2008/12/11 03:32:57	1.82
@@ -1097,7 +1097,6 @@
 	init_msg_prefix(cmd->default_settings.msg_prefix);
 	init_cmd_name(cmd->default_settings.cmd_name);
 
-	archive_enable(cmd, cmd->current_settings.archive);
 	backup_enable(cmd, cmd->current_settings.backup);
 
 	set_activation(cmd->current_settings.activation);


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-17 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-17 16:46 LVM2 daemons/clvmd/lvm-functions.c lib/command wysochanski
  -- strict thread matches above, loose matches on Subject: below --
2008-12-11  3:33 wysochanski
2008-12-11  3:32 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).