r304 - in devmapper/upstream/current: . dmeventd dmsetup include kernel/ioctl lib lib/ioctl lib/mm man

Bastian Blank waldi at costa.debian.org
Sat Apr 15 09:20:36 UTC 2006


Author: waldi
Date: Sat Apr 15 09:20:32 2006
New Revision: 304

Modified:
   devmapper/upstream/current/VERSION
   devmapper/upstream/current/WHATS_NEW
   devmapper/upstream/current/dmeventd/dmeventd.c
   devmapper/upstream/current/dmsetup/dmsetup.c
   devmapper/upstream/current/include/.symlinks
   devmapper/upstream/current/kernel/ioctl/dm-ioctl.h
   devmapper/upstream/current/lib/.exported_symbols
   devmapper/upstream/current/lib/ioctl/libdm-compat.h
   devmapper/upstream/current/lib/ioctl/libdm-iface.c
   devmapper/upstream/current/lib/ioctl/libdm-targets.h
   devmapper/upstream/current/lib/libdevmapper.h
   devmapper/upstream/current/lib/libdm-common.c
   devmapper/upstream/current/lib/mm/dbg_malloc.c
   devmapper/upstream/current/man/dmsetup.8
Log:
Load device-mapper.1.02.04 into /devmapper/upstream/current.


Modified: devmapper/upstream/current/VERSION
==============================================================================
--- devmapper/upstream/current/VERSION	(original)
+++ devmapper/upstream/current/VERSION	Sat Apr 15 09:20:32 2006
@@ -1 +1 @@
-1.02.03 (2006-02-08)
+1.02.04 (2006-04-14)

Modified: devmapper/upstream/current/WHATS_NEW
==============================================================================
--- devmapper/upstream/current/WHATS_NEW	(original)
+++ devmapper/upstream/current/WHATS_NEW	Sat Apr 15 09:20:32 2006
@@ -1,3 +1,13 @@
+Version 1.02.04 - 14 Apr 2006
+=============================
+  Bring dmsetup man page up-to-date.
+  Use name-based device refs if kernel doesn't support device number refs.
+  Fix memory leak (struct dm_ioctl) when struct dm_task is reused.
+  If _create_and_load_v4 fails part way through, revert the creation.
+  dmeventd thread/fifo fixes.
+  Add file & line to dm_strdup_aux().
+  Add setgeometry.
+
 Version 1.02.03 - 7 Feb 2006
 ============================
   Add exported functions to set uid, gid and mode.

Modified: devmapper/upstream/current/dmeventd/dmeventd.c
==============================================================================
--- devmapper/upstream/current/dmeventd/dmeventd.c	(original)
+++ devmapper/upstream/current/dmeventd/dmeventd.c	Sat Apr 15 09:20:32 2006
@@ -1032,21 +1032,32 @@
 
 /*
  * Read message from client making sure that data is available
- * and a complete message is read.
+ * and a complete message is read.  Must not block indefinitely.
  */
 static int client_read(struct dm_event_fifos *fifos, struct dm_event_daemon_message *msg)
 {
+	struct timeval t;
 	unsigned bytes = 0;
 	int ret = 0;
 	fd_set fds;
 
 	errno = 0;
 	while (bytes < sizeof(*msg) && errno != EOF) {
-		do {
-			/* Watch client read FIFO for input. */
-			FD_ZERO(&fds);
-			FD_SET(fifos->client, &fds);
-		} while (select(fifos->client+1, &fds, NULL, NULL, NULL) != 1);
+		/* Watch client read FIFO for input. */
+		FD_ZERO(&fds);
+		FD_SET(fifos->client, &fds);
+		t.tv_sec = 1;
+		t.tv_usec = 0;
+		ret = select(fifos->client+1, &fds, NULL, NULL, &t);
+
+		if (!ret && !bytes) /* nothing to read */
+			return 0;
+
+		if (!ret)     /* trying to finish read */
+			continue;
+
+		if (ret < 0)  /* error */
+			return 0;
 
 		ret = read(fifos->client, msg, sizeof(*msg) - bytes);
 		bytes += ret > 0 ? ret : 0;
@@ -1138,12 +1149,16 @@
 
 	/* FIXME: better error handling */
 
-	/* Read the request from the client. */
-	if (!memset(&msg, 0, sizeof(msg)) ||
-	    !client_read(fifos, &msg)) {
-		stack;
+	memset(&msg, 0, sizeof(msg));
+
+	/*
+	 * Read the request from the client.
+	 * Of course, it's tough to tell what to do when
+	 * we use fucking retarded return codes like
+	 * 0 for error.
+	 */
+	if (!client_read(fifos, &msg))
 		return;
-	}
 
 	msg.opcode.status = do_process_request(&msg);
 
@@ -1276,25 +1291,25 @@
 	/*
 	 * We exit when there are no more devices to watch.
 	 * That is, when the last unregister happens.
+	 *
+	 * We must be careful though.  One of our threads which is
+	 * watching a device may receive an event and:
+	 * 1) Alter the device and unregister it
+	 * or
+	 * 2) Alter the device, unregister, [alter again,] and reregister
+	 *
+	 * We must be capable of answering a request to unregister
+	 * that comes from the very thread that must be unregistered.
+	 * Additionally, if that thread unregisters itself and it was the
+	 * only thread being monitored, we must also handle the case where
+	 * that thread may perform a register before exiting.  (In other
+	 * words, we can not simply exit if all threads have been unregistered
+	 * unless all threads are done processing.
 	 */
 	do {
 		process_request(&fifos);
 		cleanup_unused_threads();
-	} while(!list_empty(&thread_registry));
-
-	/*
-	 * There may still have been some threads that were doing work,
-	 * make sure these are cleaned up
-	 *
-	 * I don't necessarily like the sleep there, but otherwise,
-	 * cleanup_unused_threads could get called many many times.
-	 * It's worth noting that the likelyhood of it being called
-	 * here is slim.
-	 */
-	while(!list_empty(&thread_registry_unused)) {
-		sleep(1);
-		cleanup_unused_threads();
-	}
+	} while(!list_empty(&thread_registry) || !list_empty(&thread_registry_unused));
 
 	exit_dm_lib();
 

Modified: devmapper/upstream/current/dmsetup/dmsetup.c
==============================================================================
--- devmapper/upstream/current/dmsetup/dmsetup.c	(original)
+++ devmapper/upstream/current/dmsetup/dmsetup.c	Sat Apr 15 09:20:32 2006
@@ -508,6 +508,39 @@
 	return r;
 }
 
+static int _setgeometry(int argc, char **argv, void *data)
+{
+	int r = 0;
+	struct dm_task *dmt;
+
+	if (!(dmt = dm_task_create(DM_DEVICE_SET_GEOMETRY)))
+		return 0;
+
+	if (_switches[UUID_ARG] || _switches[MAJOR_ARG]) {
+		if (!_set_task_device(dmt, NULL, 0))
+			goto out;
+	} else {
+		if (!_set_task_device(dmt, argv[1], 0))
+			goto out;
+		argc--;
+		argv++;
+	}
+
+	if (!dm_task_set_geometry(dmt, argv[1], argv[2], argv[3], argv[4]))
+		goto out;
+
+	/* run the task */
+	if (!dm_task_run(dmt))
+		goto out;
+
+	r = 1;
+
+      out:
+	dm_task_destroy(dmt);
+
+	return r;
+}
+
 static int _version(int argc, char **argv, void *data)
 {
 	char version[80];
@@ -1317,7 +1350,7 @@
 	{"reload", "<device> [<table_file>]", 0, 2, _load},
 	{"rename", "<device> <new_name>", 1, 2, _rename},
 	{"message", "<device> <sector> <message>", 2, -1, _message},
-	{"ls", "[--target <target_type>] [--exec <command>] [--tree]", 0, 0, _ls},
+	{"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},
@@ -1326,6 +1359,7 @@
 	{"mknodes", "[<device>]", 0, 1, _mknodes},
 	{"targets", "", 0, 0, _targets},
 	{"version", "", 0, 0, _version},
+	{"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, _setgeometry},
 	{NULL, NULL, 0, 0, NULL}
 };
 
@@ -1340,7 +1374,9 @@
 		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, "Table_file contents may be supplied on stdin.\n\n");
+	fprintf(out, "Table_file contents may be supplied on stdin.\n");
+	fprintf(out, "Tree options are: ascii, utf, vt100; compact, inverted, notrunc;\n"
+		     "                  [no]device, active, open, rw and uuid.\n\n");
 	return;
 }
 

Modified: devmapper/upstream/current/include/.symlinks
==============================================================================
--- devmapper/upstream/current/include/.symlinks	(original)
+++ devmapper/upstream/current/include/.symlinks	Sat Apr 15 09:20:32 2006
@@ -1,4 +1,5 @@
 ../lib/libdevmapper.h
 ../lib/libdm-file.h
 ../dmeventd/libdevmapper-event.h
+../multilog/libmultilog.h
 ../po/pogen.h

Modified: devmapper/upstream/current/kernel/ioctl/dm-ioctl.h
==============================================================================
--- devmapper/upstream/current/kernel/ioctl/dm-ioctl.h	(original)
+++ devmapper/upstream/current/kernel/ioctl/dm-ioctl.h	Sat Apr 15 09:20:32 2006
@@ -82,6 +82,17 @@
  *
  * DM_TARGET_MSG:
  * Pass a message string to the target at a specific offset of a device.
+ *
+ * DM_DEV_SET_GEOMETRY:
+ * Set the geometry of a device by passing in a string.  The
+ * string should have this format:
+ *
+ * "cylinders heads sectors_per_track start_sector"
+ * 
+ * Beware that CHS geometry is nearly obsolete and only provided
+ * for compatibility with dm devices that can be booted by a PC
+ * BIOS.  See struct hd_geometry for range limits.  Also note that
+ * the geometry is erased if the device size changes.
  */
 
 /*
@@ -220,6 +231,7 @@
 	/* Added later */
 	DM_LIST_VERSIONS_CMD,
 	DM_TARGET_MSG_CMD,
+	DM_DEV_SET_GEOMETRY_CMD
 };
 
 /*
@@ -232,51 +244,53 @@
  */
 #ifdef CONFIG_COMPAT
 typedef char ioctl_struct[308];
-#define DM_VERSION_32       _IOWR(DM_IOCTL, DM_VERSION_CMD, ioctl_struct)
-#define DM_REMOVE_ALL_32    _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, ioctl_struct)
-#define DM_LIST_DEVICES_32  _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, ioctl_struct)
-
-#define DM_DEV_CREATE_32    _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, ioctl_struct)
-#define DM_DEV_REMOVE_32    _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, ioctl_struct)
-#define DM_DEV_RENAME_32    _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, ioctl_struct)
-#define DM_DEV_SUSPEND_32   _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, ioctl_struct)
-#define DM_DEV_STATUS_32    _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, ioctl_struct)
-#define DM_DEV_WAIT_32      _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, ioctl_struct)
-
-#define DM_TABLE_LOAD_32    _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, ioctl_struct)
-#define DM_TABLE_CLEAR_32   _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, ioctl_struct)
-#define DM_TABLE_DEPS_32    _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
-#define DM_TABLE_STATUS_32  _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
-#define DM_LIST_VERSIONS_32 _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
-#define DM_TARGET_MSG_32    _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
+#define DM_VERSION_32		_IOWR(DM_IOCTL, DM_VERSION_CMD, ioctl_struct)
+#define DM_REMOVE_ALL_32	_IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, ioctl_struct)
+#define DM_LIST_DEVICES_32	_IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, ioctl_struct)
+
+#define DM_DEV_CREATE_32	_IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, ioctl_struct)
+#define DM_DEV_REMOVE_32	_IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, ioctl_struct)
+#define DM_DEV_RENAME_32	_IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, ioctl_struct)
+#define DM_DEV_SUSPEND_32	_IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, ioctl_struct)
+#define DM_DEV_STATUS_32	_IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, ioctl_struct)
+#define DM_DEV_WAIT_32		_IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, ioctl_struct)
+
+#define DM_TABLE_LOAD_32	_IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, ioctl_struct)
+#define DM_TABLE_CLEAR_32	_IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, ioctl_struct)
+#define DM_TABLE_DEPS_32	_IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
+#define DM_TABLE_STATUS_32	_IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
+#define DM_LIST_VERSIONS_32	_IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
+#define DM_TARGET_MSG_32	_IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
+#define DM_DEV_SET_GEOMETRY_32	_IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, ioctl_struct)
 #endif
 
 #define DM_IOCTL 0xfd
 
-#define DM_VERSION       _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
-#define DM_REMOVE_ALL    _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
-#define DM_LIST_DEVICES  _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
-
-#define DM_DEV_CREATE    _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
-#define DM_DEV_REMOVE    _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
-#define DM_DEV_RENAME    _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
-#define DM_DEV_SUSPEND   _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
-#define DM_DEV_STATUS    _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
-#define DM_DEV_WAIT      _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
-
-#define DM_TABLE_LOAD    _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
-#define DM_TABLE_CLEAR   _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
-#define DM_TABLE_DEPS    _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
-#define DM_TABLE_STATUS  _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
+#define DM_VERSION		_IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
+#define DM_REMOVE_ALL		_IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
+#define DM_LIST_DEVICES		_IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
+
+#define DM_DEV_CREATE		_IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
+#define DM_DEV_REMOVE		_IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
+#define DM_DEV_RENAME		_IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
+#define DM_DEV_SUSPEND		_IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
+#define DM_DEV_STATUS		_IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
+#define DM_DEV_WAIT		_IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
+
+#define DM_TABLE_LOAD		_IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
+#define DM_TABLE_CLEAR		_IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
+#define DM_TABLE_DEPS		_IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
+#define DM_TABLE_STATUS		_IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
 
-#define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
+#define DM_LIST_VERSIONS	_IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
 
-#define DM_TARGET_MSG	 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
+#define DM_TARGET_MSG		_IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
+#define DM_DEV_SET_GEOMETRY	_IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
 
 #define DM_VERSION_MAJOR	4
-#define DM_VERSION_MINOR	5
+#define DM_VERSION_MINOR	6
 #define DM_VERSION_PATCHLEVEL	0
-#define DM_VERSION_EXTRA	"-ioctl (2005-10-04)"
+#define DM_VERSION_EXTRA	"-ioctl (2006-02-17)"
 
 /* Status bits */
 #define DM_READONLY_FLAG	(1 << 0) /* In/Out */

Modified: devmapper/upstream/current/lib/.exported_symbols
==============================================================================
--- devmapper/upstream/current/lib/.exported_symbols	(original)
+++ devmapper/upstream/current/lib/.exported_symbols	Sat Apr 15 09:20:32 2006
@@ -108,3 +108,4 @@
 dm_hash_get_first
 dm_hash_get_next
 dm_set_selinux_context
+dm_task_set_geometry

Modified: devmapper/upstream/current/lib/ioctl/libdm-compat.h
==============================================================================
--- devmapper/upstream/current/lib/ioctl/libdm-compat.h	(original)
+++ devmapper/upstream/current/lib/ioctl/libdm-compat.h	Sat Apr 15 09:20:32 2006
@@ -116,6 +116,7 @@
 	{ "mknodes",	0,			{4, 0, 0} },
 	{ "versions",	0,			{4, 1, 0} },
 	{ "message",	0,			{4, 2, 0} },
+	{ "setgeometry",0,			{4, 6, 0} },
 };
 /* *INDENT-ON* */
 

Modified: devmapper/upstream/current/lib/ioctl/libdm-iface.c
==============================================================================
--- devmapper/upstream/current/lib/ioctl/libdm-iface.c	(original)
+++ devmapper/upstream/current/lib/ioctl/libdm-iface.c	Sat Apr 15 09:20:32 2006
@@ -59,7 +59,9 @@
 #define NUMBER_OF_MAJORS 4096
 
 /* dm major version no for running kernel */
-static int _dm_version = DM_VERSION_MAJOR;
+static unsigned _dm_version = DM_VERSION_MAJOR;
+static unsigned _dm_version_minor = 0;
+static unsigned _dm_version_patchlevel = 0;
 static int _log_suppress = 0;
 
 static dm_bitset_t _dm_bitset = NULL;
@@ -103,6 +105,9 @@
 #ifdef DM_TARGET_MSG
 	{"message",	DM_TARGET_MSG,		{4, 2, 0}},
 #endif
+#ifdef DM_DEV_SET_GEOMETRY
+	{"setgeometry",	DM_DEV_SET_GEOMETRY,	{4, 6, 0}},
+#endif
 };
 /* *INDENT-ON* */
 
@@ -236,10 +241,10 @@
 	}
 
 #ifdef HAVE_SELINUX
-        if (!dm_set_selinux_context(control, S_IFCHR)) {
-                stack;
-                return 0;
-        }
+	if (!dm_set_selinux_context(control, S_IFCHR)) {
+		stack;
+		return 0;
+	}
 #endif
 
 	return 1;
@@ -742,7 +747,7 @@
 
 int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size)
 {
-	unsigned int *v;
+	unsigned *v;
 
 #ifdef DM_COMPAT
 	if (_dm_version == 1)
@@ -756,6 +761,9 @@
 
 	v = dmt->dmi.v4->version;
 	snprintf(version, size, "%u.%u.%u", v[0], v[1], v[2]);
+	_dm_version_minor = v[1];
+	_dm_version_patchlevel = v[2];
+
 	return 1;
 }
 
@@ -801,7 +809,7 @@
 	if (!_dm_compat)
 		goto bad;
 
-	log_verbose("device-mapper ioctl protocol version %d failed. "
+	log_verbose("device-mapper ioctl protocol version %u failed. "
 		    "Trying protocol version 1.", _dm_version);
 	_dm_version = 1;
 	if (_check_version(dmversion, sizeof(dmversion), 0)) {
@@ -1001,6 +1009,23 @@
 	return 1;
 }
 
+int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads, const char *sectors, const char *start)
+{
+	size_t len = strlen(cylinders) + 1 + strlen(heads) + 1 + strlen(sectors) + 1 + strlen(start) + 1;
+
+	if (!(dmt->geometry = dm_malloc(len))) {
+		log_error("dm_task_set_geometry: dm_malloc failed");
+		return 0;
+	}
+
+	if (sprintf(dmt->geometry, "%s %s %s %s", cylinders, heads, sectors, start) < 0) {
+		log_error("dm_task_set_geometry: sprintf failed");
+		return 0;
+	}
+
+	return 1;
+}
+
 int dm_task_no_open_count(struct dm_task *dmt)
 {
 	dmt->no_open_count = 1;
@@ -1095,6 +1120,40 @@
 	return out;
 }
 
+static int _lookup_dev_name(uint64_t dev, char *buf, size_t len)
+{
+	struct dm_names *names;
+	unsigned next = 0;
+	struct dm_task *dmt;
+	int r = 0;
+ 
+	if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
+		return 0;
+ 
+	if (!dm_task_run(dmt))
+		goto out;
+
+	if (!(names = dm_task_get_names(dmt)))
+		goto out;
+ 
+	if (!names->dev)
+		goto out;
+ 
+	do {
+		names = (void *) names + next;
+		if (names->dev == dev) {
+			strncpy(buf, names->name, len);
+			r = 1;
+			break;
+		}
+		next = names->next;
+	} while (next);
+
+      out:
+	dm_task_destroy(dmt);
+	return r;
+}
+
 static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
 {
 	const size_t min_size = 16 * 1024;
@@ -1123,11 +1182,26 @@
 		return NULL;
 	}
 
+	if (count && dmt->geometry) {
+		log_error("targets and geometry are incompatible");
+		return NULL;
+	}
+
 	if (dmt->newname && (dmt->sector || dmt->message)) {
 		log_error("message and newname are incompatible");
 		return NULL;
 	}
 
+	if (dmt->newname && dmt->geometry) {
+		log_error("geometry and newname are incompatible");
+		return NULL;
+	}
+
+	if (dmt->geometry && (dmt->sector || dmt->message)) {
+		log_error("geometry and message are incompatible");
+		return NULL;
+	}
+
 	if (dmt->sector && !dmt->message) {
 		log_error("message is required with sector");
 		return NULL;
@@ -1139,6 +1213,9 @@
 	if (dmt->message)
 		len += sizeof(struct dm_target_msg) + strlen(dmt->message) + 1;
 
+	if (dmt->geometry)
+		len += strlen(dmt->geometry) + 1;
+
 	/*
 	 * Give len a minimum size so that we have space to store
 	 * dependencies or status information.
@@ -1164,16 +1241,6 @@
 	dmi->data_size = len;
 	dmi->data_start = sizeof(struct dm_ioctl);
 
-	if (dmt->dev_name)
-		strncpy(dmi->name, dmt->dev_name, sizeof(dmi->name));
-
-	if (dmt->type == DM_DEVICE_SUSPEND)
-		dmi->flags |= DM_SUSPEND_FLAG;
-	if (dmt->read_only)
-		dmi->flags |= DM_READONLY_FLAG;
-	if (dmt->skip_lockfs)
-		dmi->flags |= DM_SKIP_LOCKFS_FLAG;
-
 	if (dmt->minor >= 0) {
 		if (dmt->major <= 0) {
 			log_error("Missing major number for persistent device.");
@@ -1183,9 +1250,31 @@
 		dmi->dev = MKDEV(dmt->major, dmt->minor);
 	}
 
+	/* Does driver support device number referencing? */
+	if (_dm_version_minor < 3 && !dmt->dev_name && !dmt->uuid && dmi->dev) {
+		if (!_lookup_dev_name(dmi->dev, dmi->name, sizeof(dmi->name))) {
+			log_error("Unable to find name for device (%" PRIu32
+				  ":%" PRIu32 ")", dmt->major, dmt->minor);
+			goto bad;
+		}
+		log_verbose("device (%" PRIu32 ":%" PRIu32 ") is %s "
+			    "for compatibility with old kernel",
+			    dmt->major, dmt->minor, dmi->name);
+	}
+
+	if (dmt->dev_name)
+		strncpy(dmi->name, dmt->dev_name, sizeof(dmi->name));
+
 	if (dmt->uuid)
 		strncpy(dmi->uuid, dmt->uuid, sizeof(dmi->uuid));
 
+	if (dmt->type == DM_DEVICE_SUSPEND)
+		dmi->flags |= DM_SUSPEND_FLAG;
+	if (dmt->read_only)
+		dmi->flags |= DM_READONLY_FLAG;
+	if (dmt->skip_lockfs)
+		dmi->flags |= DM_SKIP_LOCKFS_FLAG;
+
 	dmi->target_count = count;
 	dmi->event_nr = dmt->event_nr;
 
@@ -1205,6 +1294,9 @@
 		strcpy(tmsg->message, dmt->message);
 	}
 
+	if (dmt->geometry)
+		strcpy(b, dmt->geometry);
+
 	return dmi;
 
       bad:
@@ -1342,7 +1434,7 @@
 	task->tail = NULL;
 	dm_task_destroy(task);
 	if (!r)
-		return r;
+		goto revert;
 
 	/* Use the original structure last so the info will be correct */
 	dmt->type = DM_DEVICE_RESUME;
@@ -1351,6 +1443,17 @@
 
 	r = dm_task_run(dmt);
 
+	if (r)
+		return r;
+
+      revert:
+ 	dmt->type = DM_DEVICE_REMOVE;
+	dm_free(dmt->uuid);
+	dmt->uuid = NULL;
+
+	if (!dm_task_run(dmt))
+		log_error("Failed to revert device creation.");
+
 	return r;
 }
 
@@ -1571,6 +1674,9 @@
 		break;
 	}
 
+	/* Was structure reused? */
+	if (dmt->dmi.v4)
+		dm_free(dmt->dmi.v4);
 	dmt->dmi.v4 = dmi;
 	return 1;
 

Modified: devmapper/upstream/current/lib/ioctl/libdm-targets.h
==============================================================================
--- devmapper/upstream/current/lib/ioctl/libdm-targets.h	(original)
+++ devmapper/upstream/current/lib/ioctl/libdm-targets.h	Sat Apr 15 09:20:32 2006
@@ -50,6 +50,7 @@
 	} dmi;
 	char *newname;
 	char *message;
+	char *geometry;
 	uint64_t sector;
 	int no_open_count;
 	int skip_lockfs;

Modified: devmapper/upstream/current/lib/libdevmapper.h
==============================================================================
--- devmapper/upstream/current/lib/libdevmapper.h	(original)
+++ devmapper/upstream/current/lib/libdevmapper.h	Sat Apr 15 09:20:32 2006
@@ -80,7 +80,9 @@
 
 	DM_DEVICE_LIST_VERSIONS,
 	
-	DM_DEVICE_TARGET_MSG
+	DM_DEVICE_TARGET_MSG,
+
+	DM_DEVICE_SET_GEOMETRY
 };
 
 struct dm_task;
@@ -145,6 +147,7 @@
 int dm_task_set_gid(struct dm_task *dmt, gid_t gid);
 int dm_task_set_mode(struct dm_task *dmt, mode_t mode);
 int dm_task_set_event_nr(struct dm_task *dmt, uint32_t event_nr);
+int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads, const char *sectors, const char *start);
 int dm_task_set_message(struct dm_task *dmt, const char *message);
 int dm_task_set_sector(struct dm_task *dmt, uint64_t sector);
 int dm_task_no_open_count(struct dm_task *dmt);
@@ -369,7 +372,7 @@
 
 void *dm_malloc_aux(size_t s, const char *file, int line);
 void *dm_malloc_aux_debug(size_t s, const char *file, int line);
-char *dm_strdup_aux(const char *str);
+char *dm_strdup_aux(const char *str, const char *file, int line);
 void dm_free_aux(void *p);
 void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line);
 int dm_dump_memory_debug(void);
@@ -378,7 +381,7 @@
 #ifdef DEBUG_MEM
 
 #  define dm_malloc(s) dm_malloc_aux_debug((s), __FILE__, __LINE__)
-#  define dm_strdup(s) dm_strdup_aux(s)
+#  define dm_strdup(s) dm_strdup_aux((s), __FILE__, __LINE__)
 #  define dm_free(p) dm_free_aux(p)
 #  define dm_realloc(p, s) dm_realloc_aux(p, s, __FILE__, __LINE__)
 #  define dm_dump_memory() dm_dump_memory_debug()

Modified: devmapper/upstream/current/lib/libdm-common.c
==============================================================================
--- devmapper/upstream/current/lib/libdm-common.c	(original)
+++ devmapper/upstream/current/lib/libdm-common.c	Sat Apr 15 09:20:32 2006
@@ -510,3 +510,4 @@
 	dm_task_destroy(dmt);
 	return r;
 }
+

Modified: devmapper/upstream/current/lib/mm/dbg_malloc.c
==============================================================================
--- devmapper/upstream/current/lib/mm/dbg_malloc.c	(original)
+++ devmapper/upstream/current/lib/mm/dbg_malloc.c	Sat Apr 15 09:20:32 2006
@@ -18,9 +18,9 @@
 #include <assert.h>
 #include <stdarg.h>
 
-char *dm_strdup_aux(const char *str)
+char *dm_strdup_aux(const char *str, const char *file, int line)
 {
-	char *ret = dm_malloc(strlen(str) + 1);
+	char *ret = dm_malloc_aux_debug(strlen(str) + 1, file, line);
 
 	if (ret)
 		strcpy(ret, str);

Modified: devmapper/upstream/current/man/dmsetup.8
==============================================================================
--- devmapper/upstream/current/man/dmsetup.8	(original)
+++ devmapper/upstream/current/man/dmsetup.8	Sat Apr 15 09:20:32 2006
@@ -1,4 +1,4 @@
-.TH DMSETUP 8 "Sep 17 2003" "Linux" "MAINTENTANCE COMMANDS"
+.TH DMSETUP 8 "Apr 06 2006" "Linux" "MAINTENTANCE COMMANDS"
 .SH NAME
 dmsetup \- low level logical volume management
 .SH SYNOPSIS
@@ -12,7 +12,7 @@
 .B dmsetup remove_all
 .br
 .B dmsetup suspend
-.I device_name
+.I [--nolockfs] device_name
 .br
 .B dmsetup resume
 .I device_name
@@ -29,7 +29,7 @@
 .B dmsetup rename
 .I device_name new_name
 .br
-.B dmsetup ls [--target target_type] [--exec command]
+.B dmsetup ls [--target target_type] [--exec command] [--tree [-o options]]
 .br
 .B dmsetup info 
 .I [device_name]
@@ -147,10 +147,17 @@
 .IP \fBls
 .I [--target target_type]
 .I [--exec command]
+.I [--tree [-o options]]
 .br
 List device names.  Optionally only list devices that have at least
 one target of the specified type.  Optionally execute a command for
 each device.  The device name is appended to the supplied command.
+--tree displays dependencies between devices as a tree.
+It accepts a comma-separate list of options.
+Some specify the information displayed against each node:
+device/nodevice; active, open, rw, uuid.
+Others specify how the tree is displayed:
+ascii, utf, vt100; compact, inverted, notrunc.
 .IP \fBload|reload
 .I device_name [table_file]
 .br
@@ -183,11 +190,14 @@
 With --target, only information relating to the specified target type
 is displayed.
 .IP \fBsuspend
+.I [--nolockfs]
 .I device_name
 .br
 Suspends a device.  Any I/O that has already been mapped by the device
 but has not yet completed will be flushed.  Any further I/O to that
 device will be postponed for as long as the device is suspended.
+If there's a filesystem on the device which supports the operation, 
+an attempt will be made to sync it first unless --nolockfs is specified.
 .IP \fBtable
 .I [--target target_type]
 .I [device_name]



More information about the pkg-lvm-commits mailing list