[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] Fix broken --major/--minor (RHBZ 801205)



Petr Rockai <prockai redhat com> writes:
> These two changes are responsible for RHBZ 801205, since we use
> arg_int_value on the major/minor _ARG in lvchange/lvcreate etc., but it
> won't work with groupable options.
>
> - add a new first_grouped_arg_int_value and use that

The patch to do the latter, including a regression test for the bug:

Index: tools/lvchange.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/lvchange.c,v
retrieving revision 1.140
diff -u -p -r1.140 lvchange.c
--- tools/lvchange.c	6 Mar 2012 02:30:50 -0000	1.140
+++ tools/lvchange.c	15 Mar 2012 17:46:21 -0000
@@ -488,8 +488,8 @@ static int lvchange_persistent(struct cm
 			return 0;
 		}
 		lv->status |= FIXED_MINOR;
-		lv->minor = arg_int_value(cmd, minor_ARG, lv->minor);
-		lv->major = arg_int_value(cmd, major_ARG, lv->major);
+		lv->minor = first_grouped_arg_int_value(cmd, minor_ARG, lv->minor);
+		lv->major = first_grouped_arg_int_value(cmd, major_ARG, lv->major);
 		log_verbose("Setting persistent device number to (%d, %d) "
 			    "for \"%s\"", lv->major, lv->minor, lv->name);
 
Index: tools/lvcreate.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/lvcreate.c,v
retrieving revision 1.263
diff -u -p -r1.263 lvcreate.c
--- tools/lvcreate.c	6 Mar 2012 09:22:03 -0000	1.263
+++ tools/lvcreate.c	15 Mar 2012 17:46:22 -0000
@@ -597,8 +597,8 @@ static int _read_activation_params(struc
 		return 0;
 	}
 
-	lp->minor = arg_int_value(cmd, minor_ARG, -1);
-	lp->major = arg_int_value(cmd, major_ARG, -1);
+	lp->minor = first_grouped_arg_int_value(cmd, minor_ARG, -1);
+	lp->major = first_grouped_arg_int_value(cmd, major_ARG, -1);
 
 	/* Persistent minor */
 	if (arg_count(cmd, persistent_ARG)) {
Index: tools/lvmcmdline.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/lvmcmdline.c,v
retrieving revision 1.154
diff -u -p -r1.154 lvmcmdline.c
--- tools/lvmcmdline.c	12 Mar 2012 14:15:04 -0000	1.154
+++ tools/lvmcmdline.c	15 Mar 2012 17:46:23 -0000
@@ -94,6 +94,15 @@ int32_t grouped_arg_int_value(const stru
 	return grouped_arg_count(av, a) ? av[a].i_value : def;
 }
 
+int32_t first_grouped_arg_int_value(struct cmd_context *cmd, int a, const int32_t def)
+{
+	struct arg_value_group_list *current_group;
+	dm_list_iterate_items(current_group, &cmd->arg_value_groups) {
+		return grouped_arg_int_value(current_group->arg_values, a, def);
+	}
+	return def;
+}
+
 int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def)
 {
 	return arg_count(cmd, a) ? cmd->arg_values[a].i_value : def;
Index: tools/tools.h
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/tools.h,v
retrieving revision 1.80
diff -u -p -r1.80 tools.h
--- tools/tools.h	6 Mar 2012 02:30:50 -0000	1.80
+++ tools/tools.h	15 Mar 2012 17:46:23 -0000
@@ -162,6 +162,7 @@ unsigned arg_is_set(const struct cmd_con
 const char *arg_value(struct cmd_context *cmd, int a);
 const char *arg_str_value(struct cmd_context *cmd, int a, const char *def);
 int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def); 
+int32_t first_grouped_arg_int_value(struct cmd_context *cmd, int a, const int32_t def); 
 uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def);
 int64_t arg_int64_value(struct cmd_context *cmd, int a, const int64_t def);
 uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def);
Index: test/shell/activate-minor.sh
===================================================================
RCS file: test/shell/activate-minor.sh
diff -N test/shell/activate-minor.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ test/shell/activate-minor.sh	15 Mar 2012 17:46:24 -0000
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+. lib/test
+
+aux prepare_vg 2
+lvcreate -a n --zero n -l 1 -n foo $vg
+lvchange $vg/foo -My --major=255 --minor=123
+lvchange $vg/foo -a y
+dmsetup info $vg-foo | tee info
+grep "254, 123" info
-- 
id' Ash = Ash; id' Dust = Dust; id' _ = undefined

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]