multipath-tools/multipath main.c
CVSROOT: /cvs/dm
Module name: multipath-tools
Branch: RHEL5_FC6
Changes by: [email protected] 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.
multipath/main.c +22 -10
@@ -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 ();