All of lore.kernel.org
 help / color / mirror / Atom feed
From: prajnoha@sourceware.org <prajnoha@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/libdm libdm-common.c
Date: 6 Aug 2009 15:00:26 -0000	[thread overview]
Message-ID: <20090806150026.12694.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha at sourceware.org	2009-08-06 15:00:25

Modified files:
	libdm          : libdm-common.c 

Log message:
	Detect udev problems in _rename_dev_node.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75

--- LVM2/libdm/libdm-common.c	2009/08/05 19:50:08	1.74
+++ LVM2/libdm/libdm-common.c	2009/08/06 15:00:25	1.75
@@ -381,6 +381,29 @@
 	return 1;
 }
 
+static int _rm_dev_node(const char *dev_name)
+{
+	char path[PATH_MAX];
+	struct stat info;
+
+	_build_dev_path(path, sizeof(path), dev_name);
+
+	if (stat(path, &info) < 0)
+		return 1;
+	else if (dm_udev_get_sync_support())
+		log_warn("Node %s was not removed by udev. "
+			 "Falling back to direct node removal.", path);
+
+	if (unlink(path) < 0) {
+		log_error("Unable to unlink device node for '%s'", dev_name);
+		return 0;
+	}
+
+	log_debug("Removed %s", path);
+
+	return 1;
+}
+
 static int _rename_dev_node(const char *old_name, const char *new_name)
 {
 	char oldpath[PATH_MAX];
@@ -396,6 +419,19 @@
 				  "is already present", newpath);
 			return 0;
 		}
+		else if (dm_udev_get_sync_support()) {
+			if (stat(oldpath, &info) < 0 &&
+				 errno == ENOENT)
+				/* assume udev already deleted this */
+				return 1;
+			else {
+				log_warn("The node %s should have been renamed to %s "
+					 "by udev but old node is still present. "
+					 "Falling back to direct old node removal.",
+					 oldpath, newpath);
+				return _rm_dev_node(old_name);
+			}
+		}
 
 		if (unlink(newpath) < 0) {
 			if (errno == EPERM) {
@@ -407,6 +443,11 @@
 			return 0;
 		}
 	}
+	else if (dm_udev_get_sync_support())
+		log_warn("The node %s should have been renamed to %s "
+			 "by udev but new node is not present. "
+			 "Falling back to direct node rename.",
+			 oldpath, newpath);
 
 	if (rename(oldpath, newpath) < 0) {
 		log_error("Unable to rename device node from '%s' to '%s'",
@@ -419,29 +460,6 @@
 	return 1;
 }
 
-static int _rm_dev_node(const char *dev_name)
-{
-	char path[PATH_MAX];
-	struct stat info;
-
-	_build_dev_path(path, sizeof(path), dev_name);
-
-	if (stat(path, &info) < 0)
-		return 1;
-	else if (dm_udev_get_sync_support())
-		log_warn("Node %s was not removed by udev. "
-			 "Falling back to direct node removal.", path);
-
-	if (unlink(path) < 0) {
-		log_error("Unable to unlink device node for '%s'", dev_name);
-		return 0;
-	}
-
-	log_debug("Removed %s", path);
-
-	return 1;
-}
-
 #ifdef linux
 static int _open_dev_node(const char *dev_name)
 {



             reply	other threads:[~2009-08-06 15:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-06 15:00 prajnoha [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-13 14:39 LVM2/libdm libdm-common.c zkabelac
2012-01-25 21:47 zkabelac
2011-09-24 11:47 prajnoha
2011-07-08 15:34 agk
2011-07-05 16:17 agk
2011-06-28  9:24 agk
2011-03-02  8:40 zkabelac
2010-12-13 12:44 prajnoha
2010-12-13 12:30 prajnoha
2010-12-13 12:18 prajnoha
2010-11-29 10:11 zkabelac
2009-09-25 19:06 agk
2009-09-25 18:19 agk
2009-09-25 18:13 agk
2009-09-11 16:11 prajnoha
2009-09-11 15:57 prajnoha
2009-08-05 19:50 agk
2009-08-03 18:33 agk
2009-08-03 11:01 agk
2009-07-31 16:57 agk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090806150026.12694.qmail@sourceware.org \
    --to=prajnoha@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.