public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2012-04-24  8:00 prajnoha
  0 siblings, 0 replies; 18+ messages in thread
From: prajnoha @ 2012-04-24  8:00 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-04-24 08:00:56

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Rename (Blk)DevNames header to (Blk)DevNamesUsed in dmsetup info -c output.
	
	Just to make it clearer since there is the "dmsetup info -c -o blkdevname"
	as well that shows the "block device name for this mapping", having a
	"BlkDevName" header on output.
	
	It's a bit confusing then if the "dmsetup info -c -o devs_used,blkdevs_used"
	is named with a plural "DevNames"/"BlkDevNames" but at the same time having
	a totally different meaning than the singular form "BlkDevName".
	
	DevNames --> DevNamesUsed
	BlkDevNames --> BlkDevNamesUsed
	
	...makes it much more comprehensible.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.597&r2=1.598
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.187&r2=1.188

--- LVM2/WHATS_NEW_DM	2012/03/24 01:59:59	1.597
+++ LVM2/WHATS_NEW_DM	2012/04/24 08:00:55	1.598
@@ -1,5 +1,6 @@
 Version 1.02.75 - 
 ================================
+  Rename (Blk)DevNames header to (Blk)DevNamesUsed in dmsetup info -c output.
   Add configure --with-veritysetup for independent veritysetup tool.
   Properly support passed in dmevent path in dm_event_register_handler().
   Remove dmeventd fifos on exit if they are not managed by systemd.
--- LVM2/tools/dmsetup.c	2012/03/06 02:42:31	1.187
+++ LVM2/tools/dmsetup.c	2012/04/24 08:00:56	1.188
@@ -2759,9 +2759,9 @@
 FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "events", "Number of most recent event.")
 
 FIELD_O(DEPS, dm_deps, NUM, "#Devs", count, 5, int32, "device_count", "Number of devices used by this one.")
-FIELD_F(TREE, STR, "DevNames", 8, dm_deps_names, "devs_used", "List of names of mapped devices used by this one.")
+FIELD_F(TREE, STR, "DevNamesUsed", 16, dm_deps_names, "devs_used", "List of names of mapped devices used by this one.")
 FIELD_F(DEPS, STR, "DevNos", 6, dm_deps, "devnos_used", "List of device numbers of devices used by this one.")
-FIELD_F(DEPS, STR, "BlkDevNames", 16, dm_deps_blk_names, "blkdevs_used", "List of names of block devices used by this one.")
+FIELD_F(DEPS, STR, "BlkDevNamesUsed", 16, dm_deps_blk_names, "blkdevs_used", "List of names of block devices used by this one.")
 
 FIELD_F(TREE, NUM, "#Refs", 5, dm_tree_parents_count, "device_ref_count", "Number of mapped devices referencing this one.")
 FIELD_F(TREE, STR, "RefNames", 8, dm_tree_parents_names, "names_using_dev", "List of names of mapped devices using this one.")


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2012-04-24  8:24 prajnoha
  0 siblings, 0 replies; 18+ messages in thread
From: prajnoha @ 2012-04-24  8:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-04-24 08:24:37

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Also rename DevNos header to DevNosUsed in dmsetup info -c output.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.598&r2=1.599
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.188&r2=1.189

--- LVM2/WHATS_NEW_DM	2012/04/24 08:00:55	1.598
+++ LVM2/WHATS_NEW_DM	2012/04/24 08:24:36	1.599
@@ -1,6 +1,6 @@
 Version 1.02.75 - 
 ================================
-  Rename (Blk)DevNames header to (Blk)DevNamesUsed in dmsetup info -c output.
+  Rename (Blk)DevNames/DevNos dmsetup header to (Blk)DevNamesUsed/DevNosUsed.
   Add configure --with-veritysetup for independent veritysetup tool.
   Properly support passed in dmevent path in dm_event_register_handler().
   Remove dmeventd fifos on exit if they are not managed by systemd.
--- LVM2/tools/dmsetup.c	2012/04/24 08:00:56	1.188
+++ LVM2/tools/dmsetup.c	2012/04/24 08:24:36	1.189
@@ -2760,7 +2760,7 @@
 
 FIELD_O(DEPS, dm_deps, NUM, "#Devs", count, 5, int32, "device_count", "Number of devices used by this one.")
 FIELD_F(TREE, STR, "DevNamesUsed", 16, dm_deps_names, "devs_used", "List of names of mapped devices used by this one.")
-FIELD_F(DEPS, STR, "DevNos", 6, dm_deps, "devnos_used", "List of device numbers of devices used by this one.")
+FIELD_F(DEPS, STR, "DevNosUsed", 16, dm_deps, "devnos_used", "List of device numbers of devices used by this one.")
 FIELD_F(DEPS, STR, "BlkDevNamesUsed", 16, dm_deps_blk_names, "blkdevs_used", "List of names of block devices used by this one.")
 
 FIELD_F(TREE, NUM, "#Refs", 5, dm_tree_parents_count, "device_ref_count", "Number of mapped devices referencing this one.")


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2012-03-01 21:56 zkabelac
  0 siblings, 0 replies; 18+ messages in thread
From: zkabelac @ 2012-03-01 21:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-01 21:56:44

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Add some more pointer validation
	
	Ensure _display_name() and _add_dep() would not deref NULL names.
	Switch to use internal dm_basename().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.578&r2=1.579
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.184&r2=1.185

--- LVM2/WHATS_NEW_DM	2012/03/01 10:07:38	1.578
+++ LVM2/WHATS_NEW_DM	2012/03/01 21:56:44	1.579
@@ -1,5 +1,6 @@
 Version 1.02.73 - 
 ====================================
+  Add few pointer validation in dmsetup.
   Support dm_task_get_driver_version() query without version string.
   Log failure of pthread_join when cleaning unused threads in dmeventd.
   Fix empty string warning logic in _find_config_str. (1.02.68)
--- LVM2/tools/dmsetup.c	2012/03/01 21:50:35	1.184
+++ LVM2/tools/dmsetup.c	2012/03/01 21:56:44	1.185
@@ -1869,6 +1869,9 @@
 {
 	char dev_name[PATH_MAX];
 
+	if (!names)
+		return 1;
+
 	if ((_dev_name_type == DN_BLK || _dev_name_type == DN_MAP) &&
 	    dm_device_get_name((int) MAJOR(names->dev), (int) MINOR(names->dev),
 			       _dev_name_type == DN_BLK, dev_name, PATH_MAX))
@@ -2203,7 +2206,8 @@
 
 static int _add_dep(CMD_ARGS)
 {
-	if (!dm_tree_add_dev(_dtree, (unsigned) MAJOR(names->dev), (unsigned) MINOR(names->dev)))
+	if (names &&
+	    !dm_tree_add_dev(_dtree, (unsigned) MAJOR(names->dev), (unsigned) MINOR(names->dev)))
 		return 0;
 
 	return 1;
@@ -3417,7 +3421,8 @@
 
 static int _process_switches(int *argc, char ***argv, const char *dev_dir)
 {
-	char *base, *namebase, *s;
+	const char *base;
+	char *namebase, *s;
 	static int ind;
 	int c, r;
 
@@ -3482,7 +3487,7 @@
 		fprintf(stderr, "Failed to duplicate name.\n");
 		return 0;
 	}
-	base = basename(namebase);
+	base = dm_basename(namebase);
 
 	if (!strcmp(base, "devmap_name")) {
 		free(namebase);


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2012-02-15 12:08 prajnoha
  0 siblings, 0 replies; 18+ messages in thread
From: prajnoha @ 2012-02-15 12:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-02-15 12:08:57

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Add mangle command to dmsetup to provide renaming to correct mangled form.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.562&r2=1.563
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.178&r2=1.179

--- LVM2/WHATS_NEW_DM	2012/02/15 12:06:17	1.562
+++ LVM2/WHATS_NEW_DM	2012/02/15 12:08:57	1.563
@@ -1,5 +1,6 @@
 Version 1.02.71 - 
 ====================================
+  Add mangle command to dmsetup to provide renaming to correct mangled form.
   Add 'mangled_name' and 'unmangled_name' fields to dmsetup info -c -o.
   Add --manglename option to dmsetup to select the name mangling mode.
   Add dm_task_get_name_mangled/unmangled to libdevmapper.
--- LVM2/tools/dmsetup.c	2012/02/15 12:06:17	1.178
+++ LVM2/tools/dmsetup.c	2012/02/15 12:08:57	1.179
@@ -699,8 +699,7 @@
 	return r;
 }
 
-static int _rename(CMD_ARGS)
-{
+static int _do_rename(const char *name, const char *new_name, const char *new_uuid) {
 	int r = 0;
 	struct dm_task *dmt;
 	uint32_t cookie = 0;
@@ -710,13 +709,13 @@
 		return 0;
 
 	/* FIXME Kernel doesn't support uuid or device number here yet */
-	if (!_set_task_device(dmt, (argc == 3) ? argv[1] : NULL, 0))
+	if (!_set_task_device(dmt, name, 0))
 		goto out;
 
-	if (_switches[SETUUID_ARG]) {
-		if  (!dm_task_set_newuuid(dmt, argv[argc - 1]))
+	if (new_uuid) {
+		if (!dm_task_set_newuuid(dmt, new_uuid))
 			goto out;
-	} else if (!dm_task_set_newname(dmt, argv[argc - 1]))
+	} else if (!dm_task_set_newname(dmt, new_name))
 		goto out;
 
 	if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
@@ -753,6 +752,15 @@
 	return r;
 }
 
+static int _rename(CMD_ARGS)
+{
+	const char *name = (argc == 3) ? argv[1] : NULL;
+
+	return _switches[SETUUID_ARG] ? _do_rename(name, NULL, argv[argc - 1]) :
+					_do_rename(name, argv[argc - 1], NULL);
+
+}
+
 static int _message(CMD_ARGS)
 {
 	int r = 0, i;
@@ -2895,6 +2903,66 @@
 		return _process_all(cmd, argc, argv, 0, _display_name);
 }
 
+static int _mangle(CMD_ARGS)
+{
+	char *name;
+	char *new_name = NULL;
+	struct dm_task *dmt;
+	struct dm_info info;
+	int r = 0;
+	int target_format;
+
+	if (names)
+		name = names->name;
+	else {
+		if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
+			return _process_all(cmd, argc, argv, 0, _mangle);
+		name = argv[1];
+	}
+
+	if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
+		return 0;
+
+	if (!(_set_task_device(dmt, name, 0)))
+		goto out;
+
+	if (!_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
+		goto out;
+
+	if (!dm_task_run(dmt))
+		goto out;
+
+	if (!dm_task_get_info(dmt, &info) || !info.exists)
+		goto out;
+
+	target_format = _switches[MANGLENAME_ARG] ? _int_args[MANGLENAME_ARG]
+						  : DEFAULT_DM_NAME_MANGLING;
+
+	if (target_format == DM_STRING_MANGLING_NONE) {
+		if (!(new_name = dm_task_get_name_unmangled(dmt)))
+			goto out;
+	}
+	else if (!(new_name = dm_task_get_name_mangled(dmt)))
+		goto out;
+
+	/* Nothing to do if the name is in correct form already. */
+	if (!strcmp(name, new_name)) {
+		log_print("%s: name already in correct form", name);
+		r = 1;
+		goto out;
+	}
+	else
+		log_print("%s: renaming to %s", name, new_name);
+
+	/* Rename to correct form of the name. */
+	r = _do_rename(name, new_name, NULL);
+
+out:
+	dm_free(new_name);
+	dm_task_destroy(dmt);
+	return r;
+}
+
 static int _help(CMD_ARGS);
 
 /*
@@ -2924,6 +2992,7 @@
 	{"table", "[<device>] [--target <target_type>] [--showkeys]", 0, -1, 1, _status},
 	{"wait", "<device> [<event_nr>]", 0, 2, 0, _wait},
 	{"mknodes", "[<device>]", 0, -1, 1, _mknodes},
+	{"mangle", "[<device>]", 0, -1, 1, _mangle},
 	{"udevcreatecookie", "", 0, 0, 0, _udevcreatecookie},
 	{"udevreleasecookie", "[<cookie>]", 0, 1, 0, _udevreleasecookie},
 	{"udevflags", "<cookie>", 1, 1, 0, _udevflags},
@@ -3677,6 +3746,9 @@
 	if (!_switches[COLS_ARG] && !strcmp(cmd->name, "splitname"))
 		_switches[COLS_ARG]++;
 
+	if (!strcmp(cmd->name, "mangle"))
+		dm_set_name_mangling_mode(DM_STRING_MANGLING_NONE);
+
 	if (_switches[COLS_ARG]) {
 		if (!_report_init(cmd))
 			goto out;


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2012-02-15 12:06 prajnoha
  0 siblings, 0 replies; 18+ messages in thread
From: prajnoha @ 2012-02-15 12:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-02-15 12:06:17

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Add 'mangled_name' and 'unmangled_name' fields to dmsetup info -c -o.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.561&r2=1.562
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.177&r2=1.178

--- LVM2/WHATS_NEW_DM	2012/02/15 12:02:58	1.561
+++ LVM2/WHATS_NEW_DM	2012/02/15 12:06:17	1.562
@@ -1,5 +1,6 @@
 Version 1.02.71 - 
 ====================================
+  Add 'mangled_name' and 'unmangled_name' fields to dmsetup info -c -o.
   Add --manglename option to dmsetup to select the name mangling mode.
   Add dm_task_get_name_mangled/unmangled to libdevmapper.
   Mangle device name on dm_task_set_name/newname call if necessary.
--- LVM2/tools/dmsetup.c	2012/02/15 12:02:59	1.177
+++ LVM2/tools/dmsetup.c	2012/02/15 12:06:17	1.178
@@ -2262,6 +2262,38 @@
 	return dm_report_field_string(rh, field, &name);
 }
 
+static int _dm_mangled_name_disp(struct dm_report *rh,
+				 struct dm_pool *mem __attribute__((unused)),
+				 struct dm_report_field *field, const void *data,
+				 void *private __attribute__((unused)))
+{
+	char *name;
+	int r = 0;
+
+	if ((name = dm_task_get_name_mangled((const struct dm_task *) data))) {
+		r = dm_report_field_string(rh, field, (const char **) &name);
+		dm_free(name);
+	}
+
+	return r;
+}
+
+static int _dm_unmangled_name_disp(struct dm_report *rh,
+				   struct dm_pool *mem __attribute__((unused)),
+				   struct dm_report_field *field, const void *data,
+				   void *private __attribute__((unused)))
+{
+	char *name;
+	int r = 0;
+
+	if ((name = dm_task_get_name_unmangled((const struct dm_task *) data))) {
+		r = dm_report_field_string(rh, field, (const char **) &name);
+		dm_free(name);
+	}
+
+	return r;
+}
+
 static int _dm_uuid_disp(struct dm_report *rh,
 			 struct dm_pool *mem __attribute__((unused)),
 			 struct dm_report_field *field,
@@ -2693,6 +2725,8 @@
 static const struct dm_report_field_type _report_fields[] = {
 /* *INDENT-OFF* */
 FIELD_F(TASK, STR, "Name", 16, dm_name, "name", "Name of mapped device.")
+FIELD_F(TASK, STR, "MangledName", 16, dm_mangled_name, "mangled_name", "Mangled name of mapped device.")
+FIELD_F(TASK, STR, "UnmangledName", 16, dm_unmangled_name, "unmangled_name", "Unmangled name of mapped device.")
 FIELD_F(TASK, STR, "UUID", 32, dm_uuid, "uuid", "Unique (optional) identifier for mapped device.")
 
 /* FIXME Next one should be INFO */


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2012-02-15 12:03 prajnoha
  0 siblings, 0 replies; 18+ messages in thread
From: prajnoha @ 2012-02-15 12:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-02-15 12:02:59

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Add --manglename option to dmsetup to select the name mangling mode.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.560&r2=1.561
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.176&r2=1.177

--- LVM2/WHATS_NEW_DM	2012/02/15 11:39:38	1.560
+++ LVM2/WHATS_NEW_DM	2012/02/15 12:02:58	1.561
@@ -1,5 +1,6 @@
 Version 1.02.71 - 
 ====================================
+  Add --manglename option to dmsetup to select the name mangling mode.
   Add dm_task_get_name_mangled/unmangled to libdevmapper.
   Mangle device name on dm_task_set_name/newname call if necessary.
   Add dm_set/get_name_mangling_mode to set/get name mangling in libdevmapper.
--- LVM2/tools/dmsetup.c	2012/02/13 12:06:40	1.176
+++ LVM2/tools/dmsetup.c	2012/02/15 12:02:59	1.177
@@ -126,6 +126,7 @@
 	GID_ARG,
 	HELP_ARG,
 	INACTIVE_ARG,
+	MANGLENAME_ARG,
 	MAJOR_ARG,
 	MINOR_ARG,
 	MODE_ARG,
@@ -2908,7 +2909,7 @@
 
 	fprintf(out, "Usage:\n\n");
 	fprintf(out, "dmsetup [--version] [-h|--help [-c|-C|--columns]]\n"
-		"        [--checks] [-v|--verbose [-v|--verbose ...]]\n"
+		"        [--checks] [--manglename <mangling_mode>] [-v|--verbose [-v|--verbose ...]]\n"
 		"        [-r|--readonly] [--noopencount] [--nolockfs] [--inactive]\n"
 		"        [--udevcookie [cookie]] [--noudevrules] [--noudevsync] [--verifyudev]\n"
 		"        [-y|--yes] [--readahead [+]<sectors>|auto|none] [--retry]\n"
@@ -2918,6 +2919,7 @@
 		fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
 	fprintf(out, "\n<device> may be device name or -u <uuid> or "
 		     "-j <major> -m <minor>\n");
+	fprintf(out, "<mangling_mode> is one of 'none', 'auto' and 'hex'.\n");
 	fprintf(out, "<fields> are comma-separated.  Use 'help -c' for list.\n");
 	fprintf(out, "Table_file contents may be supplied on stdin.\n");
 	fprintf(out, "Options are: devno, devname, blkdevname.\n");
@@ -3322,6 +3324,7 @@
 		{"gid", 1, &ind, GID_ARG},
 		{"help", 0, &ind, HELP_ARG},
 		{"inactive", 0, &ind, INACTIVE_ARG},
+		{"manglename", 1, &ind, MANGLENAME_ARG},
 		{"major", 1, &ind, MAJOR_ARG},
 		{"minor", 1, &ind, MINOR_ARG},
 		{"mode", 1, &ind, MODE_ARG},
@@ -3494,6 +3497,20 @@
 		}
 		if (ind == INACTIVE_ARG)
 		       _switches[INACTIVE_ARG]++;
+		if ((ind == MANGLENAME_ARG)) {
+			_switches[MANGLENAME_ARG]++;
+			if (!strcasecmp(optarg, "none"))
+				_int_args[MANGLENAME_ARG] = DM_STRING_MANGLING_NONE;
+			else if (!strcasecmp(optarg, "auto"))
+				_int_args[MANGLENAME_ARG] = DM_STRING_MANGLING_AUTO;
+			else if (!strcasecmp(optarg, "hex"))
+				_int_args[MANGLENAME_ARG] = DM_STRING_MANGLING_HEX;
+			else {
+				log_error("Unknown name mangling mode");
+				return 0;
+			}
+			dm_set_name_mangling_mode(_int_args[MANGLENAME_ARG]);
+		}
 		if (ind == NAMEPREFIXES_ARG)
 			_switches[NAMEPREFIXES_ARG]++;
 		if (ind == NOFLUSH_ARG)


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2012-02-13 12:06 zkabelac
  0 siblings, 0 replies; 18+ messages in thread
From: zkabelac @ 2012-02-13 12:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-13 12:06:40

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Ensure allocated device does not leak on error path
	
	For unimplementd canonicalize_file_name set to NULL

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.555&r2=1.556
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.175&r2=1.176

--- LVM2/WHATS_NEW_DM	2012/02/13 11:24:09	1.555
+++ LVM2/WHATS_NEW_DM	2012/02/13 12:06:39	1.556
@@ -1,5 +1,6 @@
 Version 1.02.71 - 
 ====================================
+  Fix memory leak in fail path of parse_loop_device_name() in dmsetup.
   Check for missing reply_uuid in dm_event_get_registered_device().
   Check for allocation failure in dmeventd restart().
   Add few missing allocation failures tests in dmsetup.
--- LVM2/tools/dmsetup.c	2012/02/13 11:13:44	1.175
+++ LVM2/tools/dmsetup.c	2012/02/13 12:06:40	1.176
@@ -3043,6 +3043,8 @@
 	_path = canonicalize_file_name(path);
 #else
 	/* FIXME Provide alternative */
+	log_error(INTERNAL_ERROR "Unimplemented _get_abspath.");
+	_path = NULL;
 #endif
 	return _path;
 }
@@ -3050,7 +3052,7 @@
 static char *parse_loop_device_name(const char *dev, const char *dev_dir)
 {
 	char *buf;
-	char *device;
+	char *device = NULL;
 
 	if (!(buf = dm_malloc(PATH_MAX)))
 		return NULL;
@@ -3083,7 +3085,9 @@
 	return buf;
 
 error:
+	dm_free(device);
 	dm_free(buf);
+
 	return NULL;
 }
 


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2011-08-11 17:06 mbroz
  0 siblings, 0 replies; 18+ messages in thread
From: mbroz @ 2011-08-11 17:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-08-11 17:06:24

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Remove dev name prefix from dmsetup line output if major and minor is used.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.487&r2=1.488
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.166&r2=1.167

--- LVM2/WHATS_NEW_DM	2011/08/09 17:56:47	1.487
+++ LVM2/WHATS_NEW_DM	2011/08/11 17:06:24	1.488
@@ -1,5 +1,6 @@
 Version 1.02.66 - 
 ===============================
+  Remove dev name prefix from dmsetup line output if major and minor is used.
   Remove support for the original version 1 dm ioctls.
   Add missing check for allocation failure _create_dir_recursive().
   Add support for systemd file descriptor handover in dmeventd.
--- LVM2/tools/dmsetup.c	2011/08/04 12:40:24	1.166
+++ LVM2/tools/dmsetup.c	2011/08/11 17:06:24	1.167
@@ -3478,7 +3478,8 @@
 	#endif
 
       doit:
-	multiple_devices = (argc != 2 && cmd->repeatable_cmd);
+	multiple_devices = (cmd->repeatable_cmd && argc != 2 &&
+			   (argc != 1 || (!_switches[UUID_ARG] && !_switches[MAJOR_ARG])));
 	do {
 		if (!cmd->fn(cmd, argc--, argv++, NULL, multiple_devices)) {
 			fprintf(stderr, "Command failed\n");


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2011-07-08 17:08 agk
  0 siblings, 0 replies; 18+ messages in thread
From: agk @ 2011-07-08 17:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-07-08 17:08:19

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Remove dev name prefix from dmsetup line output if exactly one dev requested.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.478&r2=1.479
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.164&r2=1.165

--- LVM2/WHATS_NEW_DM	2011/07/02 01:17:09	1.478
+++ LVM2/WHATS_NEW_DM	2011/07/08 17:08:19	1.479
@@ -1,5 +1,6 @@
 Version 1.02.65 - 
 ==================================
+  Remove dev name prefix from dmsetup line output if exactly one dev requested.
   Report internal error if suspending a device using an already-suspended dev.
   Add dmsetup --checks and dm_task_enable_checks framework to validate ioctls.
   Add age_in_minutes parameter to dmsetup udevcomplete_all.
--- LVM2/tools/dmsetup.c	2011/07/01 14:09:20	1.164
+++ LVM2/tools/dmsetup.c	2011/07/08 17:08:19	1.165
@@ -1413,10 +1413,7 @@
 	uint64_t size;
 	int r = 0;
 
-	if (names)
-		name = names->name;
-	else
-		name = argv[1];
+	name = names ? names->name : argv[1];
 
 	size = _get_device_size(name);
 
@@ -1592,8 +1589,7 @@
 	else {
 		if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
 			return _process_all(cmd, argc, argv, 0, _status);
-		if (multiple_devices)
-			name = argv[1];
+		name = argv[1];
 	}
 
 	if (!strcmp(cmd->name, "table"))
@@ -1729,8 +1725,7 @@
 	else {
 		if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
 			return _process_all(cmd, argc, argv, 0, _info);
-		if (multiple_devices)
-			name = argv[1];
+		name = argv[1];
 	}
 
 	if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
@@ -1772,8 +1767,7 @@
 	else {
 		if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
 			return _process_all(cmd, argc, argv, 0, _deps);
-		if (multiple_devices)
-			name = argv[1];
+		name = argv[1];
 	}
 
 	if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
@@ -3482,7 +3476,7 @@
 	#endif
 
       doit:
-	multiple_devices = (argc > 1);
+	multiple_devices = (argc != 2 && cmd->repeatable_cmd);
 	do {
 		if (!cmd->fn(cmd, argc--, argv++, NULL, multiple_devices)) {
 			fprintf(stderr, "Command failed\n");


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2011-06-17 14:55 prajnoha
  0 siblings, 0 replies; 18+ messages in thread
From: prajnoha @ 2011-06-17 14:55 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-06-17 14:55:51

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Disable udev fallback and add --udevfallback option to dmsetup.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.472&r2=1.473
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.160&r2=1.161

--- LVM2/WHATS_NEW_DM	2011/06/13 03:32:45	1.472
+++ LVM2/WHATS_NEW_DM	2011/06/17 14:55:51	1.473
@@ -1,5 +1,6 @@
 Version 1.02.65 - 
 ==================================
+  Disable udev fallback by default and add --udevfallback option to dmsetup.
   Warn if a table is loaded while a device is known to be in suspended state.
   Add dm_get_suspended_counter() for number of devs in suspended state by lib.
   Fix "all" report field prefix matching to include label fields with pv_all.
--- LVM2/tools/dmsetup.c	2011/04/22 11:56:41	1.160
+++ LVM2/tools/dmsetup.c	2011/06/17 14:55:51	1.161
@@ -135,6 +135,7 @@
 	UDEVCOOKIE_ARG,
 	NOUDEVRULES_ARG,
 	NOUDEVSYNC_ARG,
+	UDEVFALLBACK_ARG,
 	OPTIONS_ARG,
 	READAHEAD_ARG,
 	ROWS_ARG,
@@ -648,11 +649,11 @@
 	if (!_set_task_add_node(dmt))
                 goto out;
 
-	if (_udev_cookie) {
+	if (_udev_cookie)
 		cookie = _udev_cookie;
-		if (_udev_only)
-			udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
-	}
+
+	if (_udev_only)
+		udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
 
 	if (!dm_task_set_cookie(dmt, &cookie, udev_flags) ||
 	    !dm_task_run(dmt))
@@ -702,11 +703,11 @@
 		udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG |
 			      DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG;
 
-	if (_udev_cookie) {
+	if (_udev_cookie)
 		cookie = _udev_cookie;
-		if (_udev_only)
-			udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
-	}
+
+	if (_udev_only)
+		udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
 
 	if (!dm_task_set_cookie(dmt, &cookie, udev_flags) ||
 	    !dm_task_run(dmt))
@@ -1006,7 +1007,7 @@
 	else
 		dirs_diff = strcmp(dev_dir, udev_dev_dir);
 
-	_udev_only = _udev_cookie && !dirs_diff;
+	_udev_only = !dirs_diff && (_udev_cookie || !_switches[UDEVFALLBACK_ARG]);
 
 	if (dirs_diff) {
 		log_debug("The path %s used for creating device nodes that is "
@@ -1225,11 +1226,11 @@
 		udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG |
 			      DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG;
 
-	if (_udev_cookie) {
+	if (_udev_cookie)
 		cookie = _udev_cookie;
-		if (_udev_only)
-			udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
-	}
+
+	if (_udev_only)
+		udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
 
 	if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie, udev_flags))
 		goto out;
@@ -2744,8 +2745,8 @@
 	fprintf(out, "dmsetup [--version] [-h|--help [-c|-C|--columns]]\n"
 		"        [-v|--verbose [-v|--verbose ...]]\n"
 		"        [-r|--readonly] [--noopencount] [--nolockfs] [--inactive]\n"
-		"        [--udevcookie] [--noudevrules] [--noudevsync] [-y|--yes]\n"
-		"        [--readahead [+]<sectors>|auto|none]\n"
+		"        [--udevcookie] [--noudevrules] [--noudevsync] [--udevfallback]\n"
+		"        [-y|--yes] [--readahead [+]<sectors>|auto|none]\n"
 		"        [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
 		"        [--nameprefixes] [--noheadings] [--separator <separator>]\n\n");
 	for (i = 0; _commands[i].name; i++)
@@ -3115,6 +3116,7 @@
 		{"udevcookie", 1, &ind, UDEVCOOKIE_ARG},
 		{"noudevrules", 0, &ind, NOUDEVRULES_ARG},
 		{"noudevsync", 0, &ind, NOUDEVSYNC_ARG},
+		{"udevfallback", 0, &ind, UDEVFALLBACK_ARG},
 		{"options", 1, &ind, OPTIONS_ARG},
 		{"readahead", 1, &ind, READAHEAD_ARG},
 		{"rows", 0, &ind, ROWS_ARG},
@@ -3243,6 +3245,8 @@
 			_switches[NOUDEVRULES_ARG]++;
 		if (ind == NOUDEVSYNC_ARG)
 			_switches[NOUDEVSYNC_ARG]++;
+		if (ind == UDEVFALLBACK_ARG)
+			_switches[UDEVFALLBACK_ARG]++;
 		if (c == 'G' || ind == GID_ARG) {
 			_switches[GID_ARG]++;
 			_int_args[GID_ARG] = atoi(optarg);


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2011-03-29 21:49 zkabelac
  0 siblings, 0 replies; 18+ messages in thread
From: zkabelac @ 2011-03-29 21:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-29 21:49:18

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Const warning fixes
	
	With recent update of dm_report_field_string() API call to accept
	completely const objects - we no longer need loose constness here
	and keep it forwarding.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.458&r2=1.459
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.156&r2=1.157

--- LVM2/WHATS_NEW_DM	2011/03/25 23:50:35	1.458
+++ LVM2/WHATS_NEW_DM	2011/03/29 21:49:18	1.459
@@ -1,5 +1,6 @@
 Version 1.02.64 - 
 ===================================
+  Fix const cast in dmsetup calls of dm_report_field_string().
   Streamline /dev/mapper/control node code for common cases.
   Use hard-coded dm control node device number for 2.6.36 kernels and above.
   Improve stack debug reporting in dm_task_create().
--- LVM2/tools/dmsetup.c	2011/03/02 02:44:56	1.156
+++ LVM2/tools/dmsetup.c	2011/03/29 21:49:18	1.157
@@ -2455,7 +2455,7 @@
 			       struct dm_report_field *field, const void *data,
 			       void *private __attribute__((unused)))
 {
-	return dm_report_field_string(rh, field, (const char **) data);
+	return dm_report_field_string(rh, field, (const char *const *) data);
 }
 
 static int _dm_vg_name_disp(struct dm_report *rh,
@@ -2464,7 +2464,7 @@
 			     void *private __attribute__((unused)))
 {
 
-	return dm_report_field_string(rh, field, (const char **) data);
+	return dm_report_field_string(rh, field, (const char *const *) data);
 }
 
 static int _dm_lv_name_disp(struct dm_report *rh,
@@ -2473,7 +2473,7 @@
 			     void *private __attribute__((unused)))
 
 {
-	return dm_report_field_string(rh, field, (const char **) data);
+	return dm_report_field_string(rh, field, (const char *const *) data);
 }
 
 static int _dm_lv_layer_name_disp(struct dm_report *rh,
@@ -2482,7 +2482,7 @@
 				   void *private __attribute__((unused)))
 
 {
-	return dm_report_field_string(rh, field, (const char **) data);
+	return dm_report_field_string(rh, field, (const char *const *) data);
 }
 
 static void *_task_get_obj(void *obj)


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2011-03-02  2:44 agk
  0 siblings, 0 replies; 18+ messages in thread
From: agk @ 2011-03-02  2:44 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-03-02 02:44:56

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Accept multiple mapped device names on many dmsetup command lines.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.451&r2=1.452
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.155&r2=1.156

--- LVM2/WHATS_NEW_DM	2011/03/02 00:29:57	1.451
+++ LVM2/WHATS_NEW_DM	2011/03/02 02:44:56	1.452
@@ -1,5 +1,6 @@
 Version 1.02.64 - 
 ===================================
+  Accept multiple mapped device names on many dmsetup command lines.
   Fix dm_udev_wait calls in dmsetup to occur before readahead display not after.
   Include an implicit dm_task_update_nodes() within dm_udev_wait().
   Fix _create_and_load_v4 not to lose the --addnodeoncreate setting (1.02.62).
--- LVM2/tools/dmsetup.c	2011/03/02 00:29:58	1.155
+++ LVM2/tools/dmsetup.c	2011/03/02 02:44:56	1.156
@@ -185,13 +185,16 @@
  * Commands
  */
 
-typedef int (*command_fn) (int argc, char **argv, void *data);
+struct command;
+#define CMD_ARGS const struct command *cmd, int argc, char **argv, struct dm_names *names, int multiple_devices
+typedef int (*command_fn) (CMD_ARGS);
 
 struct command {
 	const char *name;
 	const char *help;
 	int min_args;
 	int max_args;
+	int repeatable_cmd;	/* Repeat to process device list? */
 	command_fn fn;
 };
 
@@ -523,7 +526,7 @@
 	return 1;
 }
 
-static int _load(int argc, char **argv, void *data __attribute__((unused)))
+static int _load(CMD_ARGS)
 {
 	int r = 0;
 	struct dm_task *dmt;
@@ -583,7 +586,7 @@
 	return r;
 }
 
-static int _create(int argc, char **argv, void *data __attribute__((unused)))
+static int _create(CMD_ARGS)
 {
 	int r = 0;
 	struct dm_task *dmt;
@@ -670,7 +673,7 @@
 	return r;
 }
 
-static int _rename(int argc, char **argv, void *data __attribute__((unused)))
+static int _rename(CMD_ARGS)
 {
 	int r = 0;
 	struct dm_task *dmt;
@@ -721,7 +724,7 @@
 	return r;
 }
 
-static int _message(int argc, char **argv, void *data __attribute__((unused)))
+static int _message(CMD_ARGS)
 {
 	int r = 0, i;
 	size_t sz = 1;
@@ -786,7 +789,7 @@
 	return r;
 }
 
-static int _setgeometry(int argc, char **argv, void *data __attribute__((unused)))
+static int _setgeometry(CMD_ARGS)
 {
 	int r = 0;
 	struct dm_task *dmt;
@@ -825,7 +828,7 @@
 	return r;
 }
 
-static int _splitname(int argc, char **argv, void *data __attribute__((unused)))
+static int _splitname(CMD_ARGS)
 {
 	struct dmsetup_report_obj obj;
 	int r = 1;
@@ -859,7 +862,7 @@
 		return (uint32_t) value;
 }
 
-static int _udevflags(int args, char **argv, void *data __attribute__((unused)))
+static int _udevflags(CMD_ARGS)
 {
 	uint32_t cookie;
 	uint16_t flags;
@@ -901,7 +904,7 @@
 	return 1;
 }
 
-static int _udevcomplete(int argc, char **argv, void *data __attribute__((unused)))
+static int _udevcomplete(CMD_ARGS)
 {
 	uint32_t cookie;
 
@@ -926,30 +929,28 @@
 #ifndef UDEV_SYNC_SUPPORT
 static const char _cmd_not_supported[] = "Command not supported. Recompile with \"--enable-udev-sync\" to enable.";
 
-static int _udevcreatecookie(int argc, char **argv,
-				  void *data __attribute__((unused)))
+static int _udevcreatecookie(CMD_ARGS)
 {
 	log_error(_cmd_not_supported);
 
 	return 0;
 }
 
-static int _udevreleasecookie(int argc, char **argv,
-				void *data __attribute__((unused)))
+static int _udevreleasecookie(CMD_ARGS)
 {
 	log_error(_cmd_not_supported);
 
 	return 0;
 }
 
-static int _udevcomplete_all(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data __attribute__((unused)))
+static int _udevcomplete_all(CMD_ARGS)
 {
 	log_error(_cmd_not_supported);
 
 	return 0;
 }
 
-static int _udevcookies(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data __attribute__((unused)))
+static int _udevcookies(CMD_ARGS)
 {
 	log_error(_cmd_not_supported);
 
@@ -1023,8 +1024,7 @@
 	return 1;
 }
 
-static int _udevcreatecookie(int argc, char **argv,
-				  void *data __attribute__((unused)))
+static int _udevcreatecookie(CMD_ARGS)
 {
 	uint32_t cookie;
 
@@ -1037,8 +1037,7 @@
 	return 1;
 }
 
-static int _udevreleasecookie(int argc, char **argv,
-				void *data __attribute__((unused)))
+static int _udevreleasecookie(CMD_ARGS)
 {
 	if (argv[1] && !(_udev_cookie = _get_cookie_value(argv[1])))
 		return 0;
@@ -1079,7 +1078,7 @@
 	return ret;
 }
 
-static int _udevcomplete_all(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data __attribute__((unused)))
+static int _udevcomplete_all(CMD_ARGS)
 {
 	int max_id, id, sid;
 	struct seminfo sinfo;
@@ -1128,7 +1127,7 @@
 	return 1;
 }
 
-static int _udevcookies(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data __attribute__((unused)))
+static int _udevcookies(CMD_ARGS)
 {
 	int max_id, id, sid;
 	struct seminfo sinfo;
@@ -1167,7 +1166,7 @@
 }
 #endif	/* UDEV_SYNC_SUPPORT */
 
-static int _version(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data __attribute__((unused)))
+static int _version(CMD_ARGS)
 {
 	char version[80];
 
@@ -1249,22 +1248,22 @@
 	return r;
 }
 
-static int _suspend(int argc, char **argv, void *data __attribute__((unused)))
+static int _suspend(CMD_ARGS)
 {
 	return _simple(DM_DEVICE_SUSPEND, argc > 1 ? argv[1] : NULL, 0, 1);
 }
 
-static int _resume(int argc, char **argv, void *data __attribute__((unused)))
+static int _resume(CMD_ARGS)
 {
 	return _simple(DM_DEVICE_RESUME, argc > 1 ? argv[1] : NULL, 0, 1);
 }
 
-static int _clear(int argc, char **argv, void *data __attribute__((unused)))
+static int _clear(CMD_ARGS)
 {
 	return _simple(DM_DEVICE_CLEAR, argc > 1 ? argv[1] : NULL, 0, 1);
 }
 
-static int _wait(int argc, char **argv, void *data __attribute__((unused)))
+static int _wait(CMD_ARGS)
 {
 	const char *name = NULL;
 
@@ -1281,8 +1280,8 @@
 		       (argc > 1) ? (uint32_t) atoi(argv[argc - 1]) : 0, 1);
 }
 
-static int _process_all(int argc, char **argv, int silent,
-			int (*fn) (int argc, char **argv, void *data))
+static int _process_all(const struct command *cmd, int argc, char **argv, int silent,
+			int (*fn) (CMD_ARGS))
 {
 	int r = 1;
 	struct dm_names *names;
@@ -1311,7 +1310,7 @@
 
 	do {
 		names = (struct dm_names *)((char *) names + next);
-		if (!fn(argc, argv, names))
+		if (!fn(cmd, argc, argv, names, 1))
 			r = 0;
 		next = names->next;
 	} while (next);
@@ -1358,15 +1357,14 @@
 	return size;
 }
 
-static int _error_device(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data)
+static int _error_device(CMD_ARGS)
 {
-	struct dm_names *names = (struct dm_names *) data;
 	struct dm_task *dmt;
 	const char *name;
 	uint64_t size;
 	int r = 0;
 
-	if (data)
+	if (names)
 		name = names->name;
 	else
 		name = argv[1];
@@ -1406,22 +1404,22 @@
 	return r;
 }
 
-static int _remove(int argc, char **argv, void *data __attribute__((unused)))
+static int _remove(CMD_ARGS)
 {
 	if (_switches[FORCE_ARG] && argc > 1)
-		(void) _error_device(argc, argv, NULL);
+		(void) _error_device(cmd, argc, argv, NULL, 0);
 
 	return _simple(DM_DEVICE_REMOVE, argc > 1 ? argv[1] : NULL, 0, 0);
 }
 
-static int _count_devices(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data __attribute__((unused)))
+static int _count_devices(CMD_ARGS)
 {
 	_num_devices++;
 
 	return 1;
 }
 
-static int _remove_all(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data __attribute__((unused)))
+static int _remove_all(CMD_ARGS)
 {
 	int r;
 
@@ -1432,17 +1430,17 @@
 		return r;
 
 	_num_devices = 0;
-	r |= _process_all(argc, argv, 1, _count_devices);
+	r |= _process_all(cmd, argc, argv, 1, _count_devices);
 
 	/* No devices left? */
 	if (!_num_devices)
 		return r;
 
-	r |= _process_all(argc, argv, 1, _error_device);
+	r |= _process_all(cmd, argc, argv, 1, _error_device);
 	r |= _simple(DM_DEVICE_REMOVE_ALL, "", 0, 0) | dm_mknodes(NULL);
 
 	_num_devices = 0;
-	r |= _process_all(argc, argv, 1, _count_devices);
+	r |= _process_all(cmd, argc, argv, 1, _count_devices);
 	if (!_num_devices)
 		return r;
 
@@ -1459,7 +1457,7 @@
 		printf("%s\t(%u, %u)\n", name, info.major, info.minor);
 }
 
-static int _mknodes(int argc, char **argv, void *data __attribute__((unused)))
+static int _mknodes(CMD_ARGS)
 {
 	return dm_mknodes(argc > 1 ? argv[1] : NULL);
 }
@@ -1523,7 +1521,7 @@
 	return 1;
 }
 
-static int _status(int argc, char **argv, void *data)
+static int _status(CMD_ARGS)
 {
 	int r = 0;
 	struct dm_task *dmt;
@@ -1531,31 +1529,30 @@
 	uint64_t start, length;
 	char *target_type = NULL;
 	char *params, *c;
-	int cmd;
-	struct dm_names *names = (struct dm_names *) data;
+	int cmdno;
 	const char *name = NULL;
 	int matched = 0;
 	int ls_only = 0;
 	struct dm_info info;
 
-	if (data)
+	if (names)
 		name = names->name;
 	else {
 		if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
-			return _process_all(argc, argv, 0, _status);
-		if (argc == 2)
+			return _process_all(cmd, argc, argv, 0, _status);
+		if (multiple_devices)
 			name = argv[1];
 	}
 
-	if (!strcmp(argv[0], "table"))
-		cmd = DM_DEVICE_TABLE;
+	if (!strcmp(cmd->name, "table"))
+		cmdno = DM_DEVICE_TABLE;
 	else
-		cmd = DM_DEVICE_STATUS;
+		cmdno = DM_DEVICE_STATUS;
 
-	if (!strcmp(argv[0], "ls"))
+	if (!strcmp(cmd->name, "ls"))
 		ls_only = 1;
 
-	if (!(dmt = dm_task_create(cmd)))
+	if (!(dmt = dm_task_create(cmdno)))
 		return 0;
 
 	if (!_set_task_device(dmt, name, 0))
@@ -1593,12 +1590,12 @@
 			   _switches[VERBOSE_ARG]) {
 			if (!matched && _switches[VERBOSE_ARG])
 				_display_info(dmt);
-			if (data && !_switches[VERBOSE_ARG])
+			if (multiple_devices && !_switches[VERBOSE_ARG])
 				printf("%s: ", name);
 			if (target_type) {
 				/* Suppress encryption key */
 				if (!_switches[SHOWKEYS_ARG] &&
-				    cmd == DM_DEVICE_TABLE &&
+				    cmdno == DM_DEVICE_TABLE &&
 				    !strcmp(target_type, "crypt")) {
 					c = params;
 					while (*c && *c != ' ')
@@ -1616,7 +1613,7 @@
 		matched = 1;
 	} while (next);
 
-	if (data && _switches[VERBOSE_ARG] && matched && !ls_only)
+	if (multiple_devices && _switches[VERBOSE_ARG] && matched && !ls_only)
 		printf("\n");
 
 	if (matched && _switches[EXEC_ARG] && _command && !_exec_command(name))
@@ -1630,7 +1627,7 @@
 }
 
 /* Show target names and their version numbers */
-static int _targets(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data __attribute__((unused)))
+static int _targets(CMD_ARGS)
 {
 	int r = 0;
 	struct dm_task *dmt;
@@ -1662,20 +1659,19 @@
 	return r;
 }
 
-static int _info(int argc, char **argv, void *data)
+static int _info(CMD_ARGS)
 {
 	int r = 0;
 
 	struct dm_task *dmt;
-	struct dm_names *names = (struct dm_names *) data;
 	char *name = NULL;
 
-	if (data)
+	if (names)
 		name = names->name;
 	else {
 		if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
-			return _process_all(argc, argv, 0, _info);
-		if (argc == 2)
+			return _process_all(cmd, argc, argv, 0, _info);
+		if (multiple_devices)
 			name = argv[1];
 	}
 
@@ -1701,22 +1697,21 @@
 	return r;
 }
 
-static int _deps(int argc, char **argv, void *data)
+static int _deps(CMD_ARGS)
 {
 	int r = 0;
 	uint32_t i;
 	struct dm_deps *deps;
 	struct dm_task *dmt;
 	struct dm_info info;
-	struct dm_names *names = (struct dm_names *) data;
 	char *name = NULL;
 
-	if (data)
+	if (names)
 		name = names->name;
 	else {
 		if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
-			return _process_all(argc, argv, 0, _deps);
-		if (argc == 2)
+			return _process_all(cmd, argc, argv, 0, _deps);
+		if (multiple_devices)
 			name = argv[1];
 	}
 
@@ -1750,7 +1745,7 @@
 	if (_switches[VERBOSE_ARG])
 		_display_info(dmt);
 
-	if (data && !_switches[VERBOSE_ARG])
+	if (multiple_devices && !_switches[VERBOSE_ARG])
 		printf("%s: ", name);
 	printf("%d dependencies\t:", deps->count);
 
@@ -1760,7 +1755,7 @@
 		       (int) MINOR(deps->device[i]));
 	printf("\n");
 
-	if (data && _switches[VERBOSE_ARG])
+	if (multiple_devices && _switches[VERBOSE_ARG])
 		printf("\n");
 
 	r = 1;
@@ -1770,10 +1765,8 @@
 	return r;
 }
 
-static int _display_name(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data)
+static int _display_name(CMD_ARGS)
 {
-	struct dm_names *names = (struct dm_names *) data;
-
 	printf("%s\t(%d, %d)\n", names->name,
 	       (int) MAJOR(names->dev), (int) MINOR(names->dev));
 
@@ -2085,10 +2078,8 @@
 	}
 }
 
-static int _add_dep(int argc __attribute__((unused)), char **argv __attribute__((unused)), void *data)
+static int _add_dep(CMD_ARGS)
 {
-	struct dm_names *names = (struct dm_names *) data;
-
 	if (!dm_tree_add_dev(_dtree, (unsigned) MAJOR(names->dev), (unsigned) MINOR(names->dev)))
 		return 0;
 
@@ -2098,7 +2089,7 @@
 /*
  * Create and walk dependency tree
  */
-static int _build_whole_deptree(void)
+static int _build_whole_deptree(const struct command *cmd)
 {
 	if (_dtree)
 		return 1;
@@ -2106,17 +2097,15 @@
 	if (!(_dtree = dm_tree_create()))
 		return 0;
 
-	if (!_process_all(0, NULL, 0, _add_dep))
+	if (!_process_all(cmd, 0, NULL, 0, _add_dep))
 		return 0;
 
 	return 1;
 }
 
-static int _display_tree(int argc __attribute__((unused)),
-			 char **argv __attribute__((unused)),
-			 void *data __attribute__((unused)))
+static int _display_tree(CMD_ARGS)
 {
-	if (!_build_whole_deptree())
+	if (!_build_whole_deptree(cmd))
 		return 0;
 
 	_display_tree_walk_children(dm_tree_find_node(_dtree, 0, 0), 0);
@@ -2581,7 +2570,7 @@
 static const char *default_report_options = "name,major,minor,attr,open,segments,events,uuid";
 static const char *splitname_report_options = "vg_name,lv_name,lv_layer";
 
-static int _report_init(struct command *c)
+static int _report_init(const struct command *cmd)
 {
 	char *options = (char *) default_report_options;
 	const char *keys = "";
@@ -2592,7 +2581,7 @@
 	size_t len = 0;
 	int r = 0;
 
-	if (c && !strcmp(c->name, "splitname"))
+	if (cmd && !strcmp(cmd->name, "splitname"))
 		options = (char *) splitname_report_options;
 
 	/* emulate old dmsetup behaviour */
@@ -2638,7 +2627,7 @@
 	if (_switches[SORT_ARG] && _string_args[SORT_ARG]) {
 		keys = _string_args[SORT_ARG];
 		buffered = 1;
-		if (c && (!strcmp(c->name, "status") || !strcmp(c->name, "table"))) {
+		if (cmd && (!strcmp(cmd->name, "status") || !strcmp(cmd->name, "table"))) {
 			err("--sort is not yet supported with status and table");
 			goto out;
 		}
@@ -2672,7 +2661,7 @@
 				       options, separator, flags, keys, NULL)))
 		goto out;
 
-	if ((_report_type & DR_TREE) && !_build_whole_deptree()) {
+	if ((_report_type & DR_TREE) && !_build_whole_deptree(cmd)) {
 		err("Internal device dependency tree creation failed.");
 		goto out;
 	}
@@ -2695,56 +2684,56 @@
 /*
  * List devices
  */
-static int _ls(int argc, char **argv, void *data)
+static int _ls(CMD_ARGS)
 {
 	if ((_switches[TARGET_ARG] && _target) ||
 	    (_switches[EXEC_ARG] && _command))
-		return _status(argc, argv, data);
+		return _status(cmd, argc, argv, NULL, 0);
 	else if ((_switches[TREE_ARG]))
-		return _display_tree(argc, argv, data);
+		return _display_tree(cmd, 0, NULL, NULL, 0);
 	else
-		return _process_all(argc, argv, 0, _display_name);
+		return _process_all(cmd, argc, argv, 0, _display_name);
 }
 
-static int _help(int argc, char **argv, void *data);
+static int _help(CMD_ARGS);
 
 /*
  * Dispatch table
  */
 static struct command _commands[] = {
-	{"help", "[-c|-C|--columns]", 0, 0, _help},
+	{"help", "[-c|-C|--columns]", 0, 0, 0, _help},
 	{"create", "<dev_name> [-j|--major <major> -m|--minor <minor>]\n"
 	  "\t                  [-U|--uid <uid>] [-G|--gid <gid>] [-M|--mode <octal_mode>]\n"
 	  "\t                  [-u|uuid <uuid>] [{--addnodeonresume|--addnodeoncreate}]\n"
 	  "\t                  [--notable | --table <table> | <table_file>]",
-	 1, 2, _create},
-	{"remove", "[-f|--force] <device>", 0, 1, _remove},
-	{"remove_all", "[-f|--force]", 0, 0, _remove_all},
-	{"suspend", "[--noflush] <device>", 0, 1, _suspend},
-	{"resume", "<device> [{--addnodeonresume|--addnodeoncreate}]", 0, 1, _resume},
-	{"load", "<device> [<table_file>]", 0, 2, _load},
-	{"clear", "<device>", 0, 1, _clear},
-	{"reload", "<device> [<table_file>]", 0, 2, _load},
-	{"rename", "<device> [--setuuid] <new_name_or_uuid>", 1, 2, _rename},
-	{"message", "<device> <sector> <message>", 2, -1, _message},
-	{"ls", "[--target <target_type>] [--exec <command>] [--tree [-o options]]", 0, 0, _ls},
-	{"info", "[<device>]", 0, 1, _info},
-	{"deps", "[<device>]", 0, 1, _deps},
-	{"status", "[<device>] [--target <target_type>]", 0, 1, _status},
-	{"table", "[<device>] [--target <target_type>] [--showkeys]", 0, 1, _status},
-	{"wait", "<device> [<event_nr>]", 0, 2, _wait},
-	{"mknodes", "[<device>]", 0, 1, _mknodes},
-	{"udevcreatecookie", "", 0, 0, _udevcreatecookie},
-	{"udevreleasecookie", "[<cookie>]", 0, 1, _udevreleasecookie},
-	{"udevflags", "<cookie>", 1, 1, _udevflags},
-	{"udevcomplete", "<cookie>", 1, 1, _udevcomplete},
-	{"udevcomplete_all", "", 0, 0, _udevcomplete_all},
-	{"udevcookies", "", 0, 0, _udevcookies},
-	{"targets", "", 0, 0, _targets},
-	{"version", "", 0, 0, _version},
-	{"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, _setgeometry},
-	{"splitname", "<device> [<subsystem>]", 1, 2, _splitname},
-	{NULL, NULL, 0, 0, NULL}
+	 1, 2,0,  _create},
+	{"remove", "[-f|--force] <device>", 0, -1, 1, _remove},
+	{"remove_all", "[-f|--force]", 0, 0, 0,  _remove_all},
+	{"suspend", "[--noflush] <device>", 0, -1, 1, _suspend},
+	{"resume", "<device> [{--addnodeonresume|--addnodeoncreate}]", 0, -1, 1, _resume},
+	{"load", "<device> [<table_file>]", 0, 2, 0, _load},
+	{"clear", "<device>", 0, -1, 1, _clear},
+	{"reload", "<device> [<table_file>]", 0, 2, 0, _load},
+	{"rename", "<device> [--setuuid] <new_name_or_uuid>", 1, 2, 0, _rename},
+	{"message", "<device> <sector> <message>", 2, -1, 0, _message},
+	{"ls", "[--target <target_type>] [--exec <command>] [--tree [-o options]]", 0, 0, 0, _ls},
+	{"info", "[<device>]", 0, -1, 1, _info},
+	{"deps", "[<device>]", 0, -1, 1, _deps},
+	{"status", "[<device>] [--target <target_type>]", 0, -1, 1, _status},
+	{"table", "[<device>] [--target <target_type>] [--showkeys]", 0, -1, 1, _status},
+	{"wait", "<device> [<event_nr>]", 0, 2, 0, _wait},
+	{"mknodes", "[<device>]", 0, -1, 1, _mknodes},
+	{"udevcreatecookie", "", 0, 0, 0, _udevcreatecookie},
+	{"udevreleasecookie", "[<cookie>]", 0, 1, 0, _udevreleasecookie},
+	{"udevflags", "<cookie>", 1, 1, 0, _udevflags},
+	{"udevcomplete", "<cookie>", 1, 1, 0, _udevcomplete},
+	{"udevcomplete_all", "", 0, 0, 0, _udevcomplete_all},
+	{"udevcookies", "", 0, 0, 0, _udevcookies},
+	{"targets", "", 0, 0, 0, _targets},
+	{"version", "", 0, 0, 0, _version},
+	{"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, 0, _setgeometry},
+	{"splitname", "<device> [<subsystem>]", 1, 2, 0, _splitname},
+	{NULL, NULL, 0, 0, 0, NULL}
 };
 
 static void _usage(FILE *out)
@@ -2777,9 +2766,7 @@
 		     "[-o offset] [-f|loop_device] [file]\n\n");
 }
 
-static int _help(int argc __attribute__((unused)),
-		 char **argv __attribute__((unused)),
-		 void *data __attribute__((unused)))
+static int _help(CMD_ARGS)
 {
 	_usage(stderr);
 
@@ -2792,7 +2779,7 @@
 			dm_report_free(_report);
 			_report = NULL;
 		}
-		(void) _report_init(NULL);
+		(void) _report_init(cmd);
 	}
 
 	return 1;
@@ -3357,9 +3344,10 @@
 
 int main(int argc, char **argv)
 {
-	struct command *c;
 	int r = 1;
 	const char *dev_dir;
+	const struct command *cmd;
+	int multiple_devices;
 
 	(void) setlocale(LC_ALL, "");
 
@@ -3378,12 +3366,12 @@
 	}
 
 	if (_switches[HELP_ARG]) {
-		c = _find_command("help");
+		cmd = _find_command("help");
 		goto doit;
 	}
 
 	if (_switches[VERSION_ARG]) {
-		c = _find_command("version");
+		cmd = _find_command("version");
 		goto doit;
 	}
 
@@ -3392,27 +3380,27 @@
 		goto out;
 	}
 
-	if (!(c = _find_command(argv[0]))) {
+	if (!(cmd = _find_command(argv[0]))) {
 		fprintf(stderr, "Unknown command\n");
 		_usage(stderr);
 		goto out;
 	}
 
-	if (argc < c->min_args + 1 ||
-	    (c->max_args >= 0 && argc > c->max_args + 1)) {
+	if (argc < cmd->min_args + 1 ||
+	    (cmd->max_args >= 0 && argc > cmd->max_args + 1)) {
 		fprintf(stderr, "Incorrect number of arguments\n");
 		_usage(stderr);
 		goto out;
 	}
 
-	if (!_switches[COLS_ARG] && !strcmp(c->name, "splitname"))
+	if (!_switches[COLS_ARG] && !strcmp(cmd->name, "splitname"))
 		_switches[COLS_ARG]++;
 
 	if (_switches[COLS_ARG]) {
-		if (!_report_init(c))
+		if (!_report_init(cmd))
 			goto out;
 		if (!_report) {
-			if (!strcmp(c->name, "info"))
+			if (!strcmp(cmd->name, "info"))
 				r = 0;  /* info -c -o help */
 			goto out;
 		}
@@ -3424,10 +3412,13 @@
 	#endif
 
       doit:
-	if (!c->fn(argc, argv, NULL)) {
-		fprintf(stderr, "Command failed\n");
-		goto out;
-	}
+	multiple_devices = (argc > 1);
+	do {
+		if (!cmd->fn(cmd, argc--, argv++, NULL, multiple_devices)) {
+			fprintf(stderr, "Command failed\n");
+			goto out;
+		}
+	} while (cmd->repeatable_cmd && argc > 1);
 
 	r = 0;
 


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2010-08-03 13:04 zkabelac
  0 siblings, 0 replies; 18+ messages in thread
From: zkabelac @ 2010-08-03 13:04 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-08-03 13:04:32

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Wait for node creation before displaying debug info in dmsetup.
	
	Readahead check needs to see created node - so wait till udev gets in sync.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.402&r2=1.403
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.143&r2=1.144

--- LVM2/WHATS_NEW_DM	2010/08/03 12:56:00	1.402
+++ LVM2/WHATS_NEW_DM	2010/08/03 13:04:32	1.403
@@ -1,5 +1,6 @@
 Version 1.02.54 - 
 ================================
+  Wait for node creation before displaying debug info in dmsetup.
   Fix return status 0 for "dmsetup info -c -o help".
   Add check for kernel semaphore support and disable udev_sync if not available.
 
--- LVM2/tools/dmsetup.c	2010/08/03 12:56:00	1.143
+++ LVM2/tools/dmsetup.c	2010/08/03 13:04:32	1.144
@@ -633,9 +633,16 @@
 
 	r = 1;
 
+	if (!_udev_cookie)
+		(void) dm_udev_wait(cookie);
+
 	if (_switches[VERBOSE_ARG])
 		r = _display_info(dmt);
 
+	dm_task_destroy(dmt);
+
+	return r;
+
       out:
 	if (!_udev_cookie)
 		(void) dm_udev_wait(cookie);


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2010-08-03 12:56 zkabelac
  0 siblings, 0 replies; 18+ messages in thread
From: zkabelac @ 2010-08-03 12:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-08-03 12:56:00

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Fix return  status 0 for "dmsetup info -c -o help".
	
	Solution returns success for _report_init when help is passed,
	and caller needs to check for _report existance.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.401&r2=1.402
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143

--- LVM2/WHATS_NEW_DM	2010/08/03 07:56:03	1.401
+++ LVM2/WHATS_NEW_DM	2010/08/03 12:56:00	1.402
@@ -1,5 +1,6 @@
 Version 1.02.54 - 
 ================================
+  Fix return status 0 for "dmsetup info -c -o help".
   Add check for kernel semaphore support and disable udev_sync if not available.
 
 Version 1.02.53 - 28th July 2010
--- LVM2/tools/dmsetup.c	2010/07/09 15:34:48	1.142
+++ LVM2/tools/dmsetup.c	2010/08/03 12:56:00	1.143
@@ -2652,6 +2652,9 @@
 	r = 1;
 
 out:
+	if (!strcasecmp(options, "help") || !strcmp(options, "?"))
+		r = 1;
+
 	if (len)
 		dm_free(options);
 
@@ -3360,8 +3363,15 @@
 	if (!_switches[COLS_ARG] && !strcmp(c->name, "splitname"))
 		_switches[COLS_ARG]++;
 
-	if (_switches[COLS_ARG] && !_report_init(c))
-		goto out;
+	if (_switches[COLS_ARG]) {
+		if (!_report_init(c))
+			goto out;
+		if (!_report) {
+			if (!strcmp(c->name, "info"))
+				r = 0;  /* info -c -o help */
+			goto out;
+		}
+	}
 
 	#ifdef UDEV_SYNC_SUPPORT
 	if (!_set_up_udev_support(dev_dir))


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2010-07-08 14:29 zkabelac
  0 siblings, 0 replies; 18+ messages in thread
From: zkabelac @ 2010-07-08 14:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-07-08 14:29:28

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Revert previous commit as it would return also for incorrect syntax.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.393&r2=1.394
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.140&r2=1.141

--- LVM2/WHATS_NEW_DM	2010/07/08 13:35:55	1.393
+++ LVM2/WHATS_NEW_DM	2010/07/08 14:29:26	1.394
@@ -1,6 +1,5 @@
 Version 1.02.53 -
 ===============================
-  Fix return value to 0 for 'dmsetup -c -o help'.
   Use "nowatch" udev rule for inappropriate devices.
 
 Version 1.02.52 - 6th July 2010
--- LVM2/tools/dmsetup.c	2010/07/08 13:31:03	1.140
+++ LVM2/tools/dmsetup.c	2010/07/08 14:29:28	1.141
@@ -3341,7 +3341,6 @@
 
 	if (argc == 0) {
 		_usage(stderr);
-		r = 0;
 		goto out;
 	}
 


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2009-06-03 20:44 agk
  0 siblings, 0 replies; 18+ messages in thread
From: agk @ 2009-06-03 20:44 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-06-03 20:44:50

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Add splitname.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.271&r2=1.272
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116

--- LVM2/WHATS_NEW_DM	2009/06/03 18:35:39	1.271
+++ LVM2/WHATS_NEW_DM	2009/06/03 20:44:42	1.272
@@ -1,5 +1,6 @@
 Version 1.02.33 - 
 ===============================
+  Add splitname command to dmsetup.
   Add subsystem, vg_name, lv_name, lv_layer fields to dmsetup reports.
   Make mempool optional in dm_split_lvm_name().
 
--- LVM2/tools/dmsetup.c	2009/06/03 18:35:39	1.115
+++ LVM2/tools/dmsetup.c	2009/06/03 20:44:49	1.116
@@ -303,14 +303,14 @@
 	return NULL;
 }
 
-static char *_extract_uuid_prefix(const char *uuid)
+static char *_extract_uuid_prefix(const char *uuid, const int separator)
 {
 	char *ptr = NULL;
 	char *uuid_prefix = NULL;
 	size_t len;
 
 	if (uuid)
-		ptr = strchr(uuid, '-');
+		ptr = strchr(uuid, separator);
 
 	len = ptr ? ptr - uuid : 0;
 	if (!(uuid_prefix = dm_malloc(len + 1))) {
@@ -324,7 +324,8 @@
 	return uuid_prefix;
 }
 
-static struct dm_split_name *_get_split_name(const char *uuid, const char *name)
+static struct dm_split_name *_get_split_name(const char *uuid, const char *name,
+					     int separator)
 {
 	struct dm_split_name *split_name;
 
@@ -334,7 +335,7 @@
 		return NULL;
 	}
 
-	split_name->subsystem = _extract_uuid_prefix(uuid);
+	split_name->subsystem = _extract_uuid_prefix(uuid, separator);
 	split_name->vg_name = split_name->lv_name =
 	    split_name->lv_layer = (char *) "";
 
@@ -383,7 +384,7 @@
 		obj.deps_task = _get_deps_task(info->major, info->minor);
 
 	if (_report_type & DR_NAME)
-		obj.split_name = _get_split_name(dm_task_get_uuid(dmt), dm_task_get_name(dmt));
+		obj.split_name = _get_split_name(dm_task_get_uuid(dmt), dm_task_get_name(dmt), '-');
 
 	if (!dm_report_object(_report, &obj))
 		goto out;
@@ -721,6 +722,24 @@
 	return r;
 }
 
+static int _splitname(int argc, char **argv, void *data __attribute((unused)))
+{
+	struct dmsetup_report_obj obj;
+	int r = 1;
+
+	obj.task = NULL;
+	obj.info = NULL;
+	obj.deps_task = NULL;
+	obj.tree_node = NULL;
+	obj.split_name = _get_split_name((argc == 3) ? argv[2] : "LVM",
+					 argv[1], '\0');
+
+	r = dm_report_object(_report, &obj);
+	_destroy_split_name(obj.split_name);
+
+	return r;
+}
+
 static int _version(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused)))
 {
 	char version[80];
@@ -2090,6 +2109,7 @@
 #undef FIELD_F
 
 static const char *default_report_options = "name,major,minor,attr,open,segments,events,uuid";
+static const char *splitname_report_options = "vg_name,lv_name,lv_layer";
 
 static int _report_init(struct command *c)
 {
@@ -2102,6 +2122,9 @@
 	size_t len = 0;
 	int r = 0;
 
+	if (!strcmp(c->name, "splitname"))
+		options = (char *) splitname_report_options;
+
 	/* emulate old dmsetup behaviour */
 	if (_switches[NOHEADINGS_ARG]) {
 		separator = ":";
@@ -2241,6 +2264,7 @@
 	{"targets", "", 0, 0, _targets},
 	{"version", "", 0, 0, _version},
 	{"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, _setgeometry},
+	{"splitname", "<device> [<subsystem>]", 1, 2, _splitname},
 	{NULL, NULL, 0, 0, NULL}
 };
 
@@ -2858,6 +2882,9 @@
 		goto out;
 	}
 
+	if (!_switches[COLS_ARG] && !strcmp(c->name, "splitname"))
+		_switches[COLS_ARG]++;
+
 	if (_switches[COLS_ARG] && !_report_init(c))
 		goto out;
 


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2009-06-03 18:35 agk
  0 siblings, 0 replies; 18+ messages in thread
From: agk @ 2009-06-03 18:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-06-03 18:35:39

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Add subsystem, vg_name, lv_name, lv_layer fields to dmsetup reports.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.270&r2=1.271
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115

--- LVM2/WHATS_NEW_DM	2009/06/03 11:40:23	1.270
+++ LVM2/WHATS_NEW_DM	2009/06/03 18:35:39	1.271
@@ -1,5 +1,6 @@
 Version 1.02.33 - 
 ===============================
+  Add subsystem, vg_name, lv_name, lv_layer fields to dmsetup reports.
   Make mempool optional in dm_split_lvm_name().
 
 Version 1.02.32 - 21st May 2009
--- LVM2/tools/dmsetup.c	2009/04/24 11:30:49	1.114
+++ LVM2/tools/dmsetup.c	2009/06/03 18:35:39	1.115
@@ -141,7 +141,8 @@
 	DR_TASK = 1,
 	DR_INFO = 2,
 	DR_DEPS = 4,
-	DR_TREE = 8	/* Complete dependency tree required */
+	DR_TREE = 8,	/* Complete dependency tree required */
+	DR_NAME = 16
 } report_type_t;
 
 static int _switches[NUM_SWITCHES];
@@ -256,11 +257,19 @@
 	return r;
 }
 
+struct dm_split_name {
+        char *subsystem;
+        char *vg_name;
+        char *lv_name;
+        char *lv_layer;
+};
+
 struct dmsetup_report_obj {
 	struct dm_task *task;
 	struct dm_info *info;
 	struct dm_task *deps_task;
 	struct dm_tree_node *tree_node;
+	struct dm_split_name *split_name;
 };
 
 static struct dm_task *_get_deps_task(int major, int minor)
@@ -294,6 +303,64 @@
 	return NULL;
 }
 
+static char *_extract_uuid_prefix(const char *uuid)
+{
+	char *ptr = NULL;
+	char *uuid_prefix = NULL;
+	size_t len;
+
+	if (uuid)
+		ptr = strchr(uuid, '-');
+
+	len = ptr ? ptr - uuid : 0;
+	if (!(uuid_prefix = dm_malloc(len + 1))) {
+		log_error("Failed to allocate memory to extract uuid prefix.");
+		return NULL;
+	}
+
+	memcpy(uuid_prefix, uuid, len);
+	uuid_prefix[len] = '\0';
+
+	return uuid_prefix;
+}
+
+static struct dm_split_name *_get_split_name(const char *uuid, const char *name)
+{
+	struct dm_split_name *split_name;
+
+	if (!(split_name = dm_malloc(sizeof(*split_name)))) {
+		log_error("Failed to allocate memory to split device name "
+			  "into components.");
+		return NULL;
+	}
+
+	split_name->subsystem = _extract_uuid_prefix(uuid);
+	split_name->vg_name = split_name->lv_name =
+	    split_name->lv_layer = (char *) "";
+
+	if (!strcmp(split_name->subsystem, "LVM") &&
+	    (!(split_name->vg_name = dm_strdup(name)) ||
+	     !dm_split_lvm_name(NULL, NULL, &split_name->vg_name,
+			        &split_name->lv_name, &split_name->lv_layer)))
+		log_error("Failed to allocate memory to split LVM name "
+			  "into components.");
+
+	return split_name;
+}
+
+static void _destroy_split_name(struct dm_split_name *split_name)
+{
+	/*
+	 * lv_name and lv_layer are allocated within the same block
+	 * of memory as vg_name so don't need to be freed separately.
+	 */
+	if (!strcmp(split_name->subsystem, "LVM"))
+		dm_free(split_name->vg_name);
+
+	dm_free(split_name->subsystem);
+	dm_free(split_name);
+}
+
 static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
 {
 	struct dmsetup_report_obj obj;
@@ -307,6 +374,7 @@
 	obj.task = dmt;
 	obj.info = info;
 	obj.deps_task = NULL;
+	obj.split_name = NULL;
 
 	if (_report_type & DR_TREE)
 		obj.tree_node = dm_tree_find_node(_dtree, info->major, info->minor);
@@ -314,6 +382,9 @@
 	if (_report_type & DR_DEPS)
 		obj.deps_task = _get_deps_task(info->major, info->minor);
 
+	if (_report_type & DR_NAME)
+		obj.split_name = _get_split_name(dm_task_get_uuid(dmt), dm_task_get_name(dmt));
+
 	if (!dm_report_object(_report, &obj))
 		goto out;
 
@@ -322,6 +393,8 @@
       out:
 	if (obj.deps_task)
 		dm_task_destroy(obj.deps_task);
+	if (obj.split_name)
+		_destroy_split_name(obj.split_name);
 	return r;
 }
 
@@ -1899,6 +1972,41 @@
 	return 0;
 }
 
+static int _dm_subsystem_disp(struct dm_report *rh,
+			       struct dm_pool *mem __attribute((unused)),
+			       struct dm_report_field *field, const void *data,
+			       void *private __attribute((unused)))
+{
+	return dm_report_field_string(rh, field, (const char **) data);
+}
+
+static int _dm_vg_name_disp(struct dm_report *rh,
+			     struct dm_pool *mem __attribute((unused)),
+			     struct dm_report_field *field, const void *data,
+			     void *private __attribute((unused)))
+{
+
+	return dm_report_field_string(rh, field, (const char **) data);
+}
+
+static int _dm_lv_name_disp(struct dm_report *rh,
+			     struct dm_pool *mem __attribute((unused)),
+			     struct dm_report_field *field, const void *data,
+			     void *private __attribute((unused)))
+
+{
+	return dm_report_field_string(rh, field, (const char **) data);
+}
+
+static int _dm_lv_layer_name_disp(struct dm_report *rh,
+				   struct dm_pool *mem __attribute((unused)),
+				   struct dm_report_field *field, const void *data,
+				   void *private __attribute((unused)))
+
+{
+	return dm_report_field_string(rh, field, (const char **) data);
+}
+
 static void *_task_get_obj(void *obj)
 {
 	return ((struct dmsetup_report_obj *)obj)->task;
@@ -1919,11 +2027,17 @@
 	return ((struct dmsetup_report_obj *)obj)->tree_node;
 }
 
+static void *_split_name_get_obj(void *obj)
+{
+	return ((struct dmsetup_report_obj *)obj)->split_name;
+}
+
 static const struct dm_report_object_type _report_types[] = {
 	{ DR_TASK, "Mapped Device Name", "", _task_get_obj },
 	{ DR_INFO, "Mapped Device Information", "", _info_get_obj },
 	{ DR_DEPS, "Mapped Device Relationship Information", "", _deps_get_obj },
 	{ DR_TREE, "Mapped Device Relationship Information", "", _tree_get_obj },
+	{ DR_NAME, "Mapped Device Name Components", "", _split_name_get_obj },
 	{ 0, "", "", NULL },
 };
 
@@ -1960,6 +2074,12 @@
 FIELD_F(TREE, NUM, "#Refs", 5, dm_tree_parents_count, "device_ref_count", "Number of mapped devices referencing this one.")
 FIELD_F(TREE, STR, "RefNames", 8, dm_tree_parents_names, "names_using_dev", "List of names of mapped devices using this one.")
 FIELD_F(TREE, STR, "RefDevNos", 9, dm_tree_parents_devs, "devnos_using_dev", "List of device numbers of mapped devices using this one.")
+
+FIELD_O(NAME, dm_split_name, STR, "Subsys", subsystem, 6, dm_subsystem, "subsystem", "Userspace subsystem responsible for this device.")
+FIELD_O(NAME, dm_split_name, STR, "VG", vg_name, 4, dm_vg_name, "vg_name", "LVM Volume Group name.")
+FIELD_O(NAME, dm_split_name, STR, "LV", lv_name, 4, dm_lv_name, "lv_name", "LVM Logical Volume name.")
+FIELD_O(NAME, dm_split_name, STR, "LVLayer", lv_layer, 7, dm_lv_layer_name, "lv_layer", "LVM device layer.")
+
 {0, 0, 0, 0, "", "", NULL, NULL},
 /* *INDENT-ON* */
 };


^ permalink raw reply	[flat|nested] 18+ messages in thread
* LVM2 ./WHATS_NEW_DM tools/dmsetup.c
@ 2009-04-24 11:30 prajnoha
  0 siblings, 0 replies; 18+ messages in thread
From: prajnoha @ 2009-04-24 11:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2009-04-24 11:30:49

Modified files:
	.              : WHATS_NEW_DM 
	tools          : dmsetup.c 

Log message:
	Fix segfault when using -U, -G and -M options in dmsetup.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.265&r2=1.266
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114

--- LVM2/WHATS_NEW_DM	2009/03/03 18:25:05	1.265
+++ LVM2/WHATS_NEW_DM	2009/04/24 11:30:49	1.266
@@ -1,5 +1,6 @@
 Version 1.02.32 - 
 ================================
+  Fix segfault when using -U, -G and -M options in dmsetup.
 
 Version 1.02.31 - 3rd March 2009
 ================================
--- LVM2/tools/dmsetup.c	2008/10/30 17:52:06	1.113
+++ LVM2/tools/dmsetup.c	2009/04/24 11:30:49	1.114
@@ -2565,7 +2565,7 @@
 
 	optarg = 0;
 	optind = OPTIND_INIT;
-	while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCfGj:m:Mno:O:ru:Uv",
+	while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCfG:j:m:M:no:O:ru:U:v",
 					    long_options, NULL)) != -1) {
 		if (c == ':' || c == '?')
 			return 0;


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

end of thread, other threads:[~2012-04-24  8:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-24  8:00 LVM2 ./WHATS_NEW_DM tools/dmsetup.c prajnoha
  -- strict thread matches above, loose matches on Subject: below --
2012-04-24  8:24 prajnoha
2012-03-01 21:56 zkabelac
2012-02-15 12:08 prajnoha
2012-02-15 12:06 prajnoha
2012-02-15 12:03 prajnoha
2012-02-13 12:06 zkabelac
2011-08-11 17:06 mbroz
2011-07-08 17:08 agk
2011-06-17 14:55 prajnoha
2011-03-29 21:49 zkabelac
2011-03-02  2:44 agk
2010-08-03 13:04 zkabelac
2010-08-03 12:56 zkabelac
2010-07-08 14:29 zkabelac
2009-06-03 20:44 agk
2009-06-03 18:35 agk
2009-04-24 11:30 prajnoha

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).