public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/libdm libdm-common.c ioctl/libdm-iface.c
@ 2012-03-05 12:40 prajnoha
  0 siblings, 0 replies; 3+ messages in thread
From: prajnoha @ 2012-03-05 12:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-03-05 12:40:35

Modified files:
	libdm          : libdm-common.c 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Clean up internal mangling interface.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.143&r2=1.144
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.140&r2=1.141

--- LVM2/libdm/libdm-common.c	2012/02/28 14:24:57	1.143
+++ LVM2/libdm/libdm-common.c	2012/03/05 12:40:34	1.144
@@ -340,7 +340,7 @@
 		return -1;
 
 	/* Is there anything to do at all? */
-	if (!*str || !len || mode == DM_STRING_MANGLING_NONE)
+	if (!*str || !len)
 		return 0;
 
 	if (buf_len < DM_NAME_LEN) {
@@ -348,6 +348,9 @@
 		return -1;
 	}
 
+	if (mode == DM_STRING_MANGLING_NONE)
+		mode = DM_STRING_MANGLING_AUTO;
+
 	for (i = 0, j = 0; str[i]; i++) {
 		if (mode == DM_STRING_MANGLING_AUTO) {
 			/*
@@ -427,7 +430,7 @@
 		return -1;
 
 	/* Is there anything to do at all? */
-	if (!*str || !len || mode == DM_STRING_MANGLING_NONE)
+	if (!*str || !len)
 		return 0;
 
 	if (buf_len < DM_NAME_LEN) {
@@ -462,7 +465,7 @@
 			     dm_string_mangling_t mangling_mode)
 {
 	char mangled_name[DM_NAME_LEN];
-	int r;
+	int r = 0;
 
 	dm_free(dmt->dev_name);
 	dmt->dev_name = NULL;
@@ -474,7 +477,8 @@
 		return 0;
 	}
 
-	if ((r = mangle_name(name, strlen(name), mangled_name,
+	if (mangling_mode != DM_STRING_MANGLING_NONE &&
+	    (r = mangle_name(name, strlen(name), mangled_name,
 			     sizeof(mangled_name), mangling_mode)) < 0) {
 		log_error("Failed to mangle device name \"%s\".", name);
 		return 0;
@@ -562,13 +566,8 @@
 	char *rs = NULL;
 	int r;
 
-	/*
-	 * We're using 'auto mangling' here. If the name is already mangled,
-	 * this is detected and we keep it as it is. If the name is not mangled,
-	 * we do mangle it. This way we always get a mangled form of the name.
-	 */
 	if ((r = mangle_name(s, strlen(s), buf, sizeof(buf),
-			     DM_STRING_MANGLING_AUTO)) < 0)
+			     dm_get_name_mangling_mode())) < 0)
 		log_error("Failed to mangle device name \"%s\".", s);
 	else if (!(rs = r ? dm_strdup(buf) : dm_strdup(s)))
 		log_error("dm_task_get_name_mangled: dm_strdup failed");
@@ -583,12 +582,8 @@
 	char *rs = NULL;
 	int r;
 
-	/*
-	 * We just want to unmangle the string.
-	 * Both auto and hex mode will do it.
-	 */
 	if ((r = unmangle_name(s, strlen(s), buf, sizeof(buf),
-			       DM_STRING_MANGLING_AUTO)) < 0)
+			       dm_get_name_mangling_mode())) < 0)
 		log_error("Failed to unmangle device name \"%s\".", s);
 	else if (!(rs = r ? dm_strdup(buf) : dm_strdup(s)))
 		log_error("dm_task_get_name_unmangled: dm_strdup failed");
@@ -600,7 +595,7 @@
 {
 	dm_string_mangling_t mangling_mode = dm_get_name_mangling_mode();
 	char mangled_name[DM_NAME_LEN];
-	int r;
+	int r = 0;
 
 	if (strchr(newname, '/')) {
 		log_error("Name \"%s\" invalid. It contains \"/\".", newname);
@@ -612,7 +607,8 @@
 		return 0;
 	}
 
-	if ((r = mangle_name(newname, strlen(newname), mangled_name,
+	if (mangling_mode != DM_STRING_MANGLING_NONE &&
+	    (r = mangle_name(newname, strlen(newname), mangled_name,
 			     sizeof(mangled_name), mangling_mode)) < 0) {
 		log_error("Failed to mangle new device name \"%s\"", newname);
 		return 0;
--- LVM2/libdm/ioctl/libdm-iface.c	2012/03/01 10:46:39	1.140
+++ LVM2/libdm/ioctl/libdm-iface.c	2012/03/05 12:40:34	1.141
@@ -1552,9 +1552,13 @@
 
 static void _do_dm_ioctl_unmangle_name(char *name)
 {
+	dm_string_mangling_t mode = dm_get_name_mangling_mode();
 	char buf[DM_NAME_LEN];
 	int r;
 
+	if (mode == DM_STRING_MANGLING_NONE)
+		return;
+
 	if ((r = unmangle_name(name, DM_NAME_LEN, buf, sizeof(buf),
 			       dm_get_name_mangling_mode())) < 0)
 		log_debug("_do_dm_ioctl_unmangle_name: failed to "


^ permalink raw reply	[flat|nested] 3+ messages in thread
* LVM2/libdm libdm-common.c ioctl/libdm-iface.c
@ 2012-01-17 14:37 prajnoha
  0 siblings, 0 replies; 3+ messages in thread
From: prajnoha @ 2012-01-17 14:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-01-17 14:36:59

Modified files:
	libdm          : libdm-common.c 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Move dm_task_set_newname from libdm-iface.c to libdm-common.c

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.131&r2=1.132

--- LVM2/libdm/libdm-common.c	2012/01/11 12:34:45	1.132
+++ LVM2/libdm/libdm-common.c	2012/01/17 14:36:58	1.133
@@ -342,6 +342,27 @@
 	return 1;
 }
 
+int dm_task_set_newname(struct dm_task *dmt, const char *newname)
+{
+	if (strchr(newname, '/')) {
+		log_error("Name \"%s\" invalid. It contains \"/\".", newname);
+		return 0;
+	}
+
+	if (strlen(newname) >= DM_NAME_LEN) {
+		log_error("Name \"%s\" too long", newname);
+		return 0;
+	}
+
+	if (!(dmt->newname = dm_strdup(newname))) {
+		log_error("dm_task_set_newname: strdup(%s) failed", newname);
+		return 0;
+	}
+	dmt->new_uuid = 0;
+
+	return 1;
+}
+
 int dm_task_set_uuid(struct dm_task *dmt, const char *uuid)
 {
 	dm_free(dmt->uuid);
--- LVM2/libdm/ioctl/libdm-iface.c	2012/01/09 12:26:15	1.131
+++ LVM2/libdm/ioctl/libdm-iface.c	2012/01/17 14:36:59	1.132
@@ -747,27 +747,6 @@
 	return 1;
 }
 
-int dm_task_set_newname(struct dm_task *dmt, const char *newname)
-{
-	if (strchr(newname, '/')) {
-		log_error("Name \"%s\" invalid. It contains \"/\".", newname);
-		return 0;
-	}
-
-	if (strlen(newname) >= DM_NAME_LEN) {
-		log_error("Name \"%s\" too long", newname);
-		return 0;
-	}
-
-	if (!(dmt->newname = dm_strdup(newname))) {
-		log_error("dm_task_set_newname: strdup(%s) failed", newname);
-		return 0;
-	}
-	dmt->new_uuid = 0;
-
-	return 1;
-}
-
 int dm_task_set_message(struct dm_task *dmt, const char *message)
 {
 	if (!(dmt->message = dm_strdup(message))) {


^ permalink raw reply	[flat|nested] 3+ messages in thread
* LVM2/libdm libdm-common.c ioctl/libdm-iface.c
@ 2010-05-03 21:06 prajnoha
  0 siblings, 0 replies; 3+ messages in thread
From: prajnoha @ 2010-05-03 21:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2010-05-03 21:06:53

Modified files:
	libdm          : libdm-common.c 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Synchronize "remove" dm task while reverting unsuccessful "create" dm task
	(with table provided).
	
	This remove ioctl generates udev events like any other hence it needs to be
	synchronized properly as well. Also, add dm task type in debug log when
	setting a cookie (for better debugging).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.71&r2=1.72

--- LVM2/libdm/libdm-common.c	2010/03/23 14:43:18	1.94
+++ LVM2/libdm/libdm-common.c	2010/05/03 21:06:53	1.95
@@ -1192,7 +1192,7 @@
 	dmt->cookie_set = 1;
 
 	log_debug("Udev cookie 0x%" PRIx32 " (semid %d) assigned to dm_task "
-		  "with flags 0x%" PRIx16, *cookie, semid, flags);
+		  "type %d with flags 0x%" PRIx16, *cookie, semid, dmt->type, flags);
 
 	return 1;
 
--- LVM2/libdm/ioctl/libdm-iface.c	2010/04/28 13:37:37	1.71
+++ LVM2/libdm/ioctl/libdm-iface.c	2010/05/03 21:06:53	1.72
@@ -1546,6 +1546,7 @@
 {
 	struct dm_task *task;
 	int r;
+	uint32_t cookie;
 
 	/* Use new task struct to create the device */
 	if (!(task = dm_task_create(DM_DEVICE_CREATE))) {
@@ -1625,7 +1626,18 @@
  	dmt->type = DM_DEVICE_REMOVE;
 	dm_free(dmt->uuid);
 	dmt->uuid = NULL;
-	dmt->cookie_set = 0;
+
+	/*
+	 * Also udev-synchronize "remove" dm task that is a part of this revert!
+	 * But only if the original dm task was supposed to be synchronized.
+	 */
+	if (dmt->cookie_set) {
+		cookie = (dmt->event_nr & ~DM_UDEV_FLAGS_MASK) |
+			 (DM_COOKIE_MAGIC << DM_UDEV_FLAGS_SHIFT);
+		dm_task_set_cookie(dmt, &cookie,
+				   (dmt->event_nr & DM_UDEV_FLAGS_MASK) >>
+				    DM_UDEV_FLAGS_SHIFT);
+	}
 
 	if (!dm_task_run(dmt))
 		log_error("Failed to revert device creation.");


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

end of thread, other threads:[~2012-03-05 12:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-05 12:40 LVM2/libdm libdm-common.c ioctl/libdm-iface.c prajnoha
  -- strict thread matches above, loose matches on Subject: below --
2012-01-17 14:37 prajnoha
2010-05-03 21:06 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).