All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bryn M. Reeves" <breeves@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Subject: [PATCH] multipath assumes pathnames are block devices
Date: Mon, 15 Jan 2007 20:36:15 +0000	[thread overview]
Message-ID: <45ABE5BF.3090708@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1345 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

When a name is passed on the multipath command line, multipath assumes
it is a block device if it appears in the filesystem:

multipath/main.c:386:
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;

This conflicts with the use of "-f" (flush map by name), in the case
that a file of the same name as the map exists in the current directory:

$ multipath -f mpath0
$ touch mpath0
$ multipath -f mpath0
must provide a map name to remove

The attached patch avoids this by adding a new function isblockdev() to
libmultipath/util.c and adding this to the DEV_DEVNODE condition. This
also means that we check for the case that what the user passed was a
character device, fifo etc.

It's probably also worth changing "-f" option to take an explicit
mapname argument, rather than just using argv[optind] after option
processing - I'll send another patch for that.

Kind regards,

Bryn.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFFq+W/6YSQoMYUY94RAojDAKDD+0xeACwY8S/ommZw6SX0pw8Z1gCcDzhV
ZkYc0ZtRHPxRQzk+JO5zDkU=
=azH8
-----END PGP SIGNATURE-----

[-- Attachment #2: multipath-tools-0.4.7-check_path_is_blockdev.patch --]
[-- Type: text/x-patch, Size: 1078 bytes --]

diff -Nurp multipath-tools-0.4.7.orig/libmultipath/util.c multipath-tools-0.4.7/libmultipath/util.c
--- multipath-tools-0.4.7.orig/libmultipath/util.c	2007-01-15 20:21:05.000000000 +0000
+++ multipath-tools-0.4.7/libmultipath/util.c	2007-01-15 20:22:07.000000000 +0000
@@ -53,6 +53,16 @@ filepresent (char * run) {
 }
 
 int
+isblockdev (char * run) {
+	struct stat buf;
+	
+	if(stat(run, &buf))
+		return 0;
+
+	return S_ISBLK(buf.st_mode);
+}
+
+int
 get_word (char * sentence, char ** word)
 {
 	char * p;
diff -Nurp multipath-tools-0.4.7.orig/multipath/main.c multipath-tools-0.4.7/multipath/main.c
--- multipath-tools-0.4.7.orig/multipath/main.c	2007-01-15 20:21:05.000000000 +0000
+++ multipath-tools-0.4.7/multipath/main.c	2007-01-15 20:22:07.000000000 +0000
@@ -383,7 +383,7 @@ main (int argc, char *argv[])
 
 		strncpy(conf->dev, argv[optind], FILE_NAME_SIZE);
 
-		if (filepresent(conf->dev))
+		if (filepresent(conf->dev) && isblockdev(conf->dev))
 			conf->dev_type = DEV_DEVNODE;
 		else if (sscanf(conf->dev, "%d:%d", &i, &i) == 2)
 			conf->dev_type = DEV_DEVT;

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



                 reply	other threads:[~2007-01-15 20:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=45ABE5BF.3090708@redhat.com \
    --to=breeves@redhat.com \
    --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 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.