Linux Device Mapper development
 help / color / mirror / Atom feed
From: bmarzins@sourceware.org
To: dm-cvs@sourceware.org, dm-devel@redhat.com
Subject: multipath-tools/multipath main.c
Date: 24 Oct 2011 13:44:26 -0000	[thread overview]
Message-ID: <20111024134426.744.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/dm
Module name:	multipath-tools
Branch: 	RHEL5_FC6
Changes by:	bmarzins@sourceware.org	2011-10-24 13:44:25

Modified files:
	multipath      : main.c 

Log message:
	Fix for bz #740022. Do better type checking on the argument passed to multipath,
	to determine whether it's a path device name, dev_t, or a multipath device.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipath/main.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.44.2.10&r2=1.44.2.11

--- multipath-tools/multipath/main.c	2010/04/24 05:28:06	1.44.2.10
+++ multipath-tools/multipath/main.c	2011/10/24 13:44:25	1.44.2.11
@@ -1,7 +1,7 @@
 /*
  * Soft:        multipath device mapper target autoconfig
  *
- * Version:     $Id: main.c,v 1.44.2.10 2010/04/24 05:28:06 bmarzins Exp $
+ * Version:     $Id: main.c,v 1.44.2.11 2011/10/24 13:44:25 bmarzins Exp $
  *
  * Author:      Christophe Varoqui
  *
@@ -21,7 +21,8 @@
  * Copyright (c) 2005 Patrick Caulfield, Redhat
  * Copyright (c) 2005 Edward Goggin, EMC
  */
-
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <ctype.h>
@@ -47,6 +48,7 @@
 #include <configure.h>
 #include <pgpolicies.h>
 #include <version.h>
+#include "dev_t.h"
 
 static int
 filter_pathvec (vector pathvec, char * refwwid)
@@ -302,13 +304,29 @@
 	return r;
 }
 
+static int
+get_dev_type(char *dev) {
+	struct stat buf;
+	int i;
+
+	if (stat(dev, &buf) == 0 && S_ISBLK(buf.st_mode)) {
+		if (dm_is_dm_major(MAJOR(buf.st_rdev)))
+			return DEV_DEVMAP;
+		return DEV_DEVNODE;
+	}
+	else if (sscanf(dev, "%d:%d", &i, &i) == 2)
+		return DEV_DEVT;
+	else
+		return DEV_DEVMAP;
+}
+
 int
 main (int argc, char *argv[])
 {
 	int arg;
 	extern char *optarg;
 	extern int optind;
-	int i, r = 1;
+	int r = 1;
 
 	if (getuid() != 0) {
 		fprintf(stderr, "need to be root\n");
@@ -396,13 +414,7 @@
 
 		strncpy(conf->dev, argv[optind], FILE_NAME_SIZE);
 
-		if (filepresent(conf->dev))
-			conf->dev_type = DEV_DEVNODE;
-		else if (sscanf(conf->dev, "%d:%d", &i, &i) == 2)
-			conf->dev_type = DEV_DEVT;
-		else
-			conf->dev_type = DEV_DEVMAP;
-
+		conf->dev_type = get_dev_type(conf->dev);
 	}
 	dm_init();
 

             reply	other threads:[~2011-10-24 13:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-24 13:44 bmarzins [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-05-12 17:46 multipath-tools/multipath main.c bmarzins
2007-12-17 23:15 bmarzins

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=20111024134426.744.qmail@sourceware.org \
    --to=bmarzins@sourceware.org \
    --cc=dm-cvs@sourceware.org \
    --cc=dm-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox