chiark / gitweb /
[PATCH] more extras/multipath updates
authorchristophe.varoqui@free.fr <christophe.varoqui@free.fr>
Wed, 10 Dec 2003 08:50:25 +0000 (00:50 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:13:07 +0000 (21:13 -0700)
* update the Makefiles to autodetect libgcc.a & gcc includes
"ulibc-style". Factorisation of udevdirs & others niceties
* drop a hint about absent /dev/sd? on failed open() for poor Debian
users who don't imagine their favorite distro with only 16 preconfigured
SCSI device nodes :)

extras/multipath/Makefile
extras/multipath/libdevmapper/Makefile
extras/multipath/main.c
extras/multipath/main.h

index bccf126..89e6f35 100644 (file)
@@ -6,16 +6,22 @@ EXEC = multipath
 
 prefix      = /usr/local
 exec_prefix = ${prefix}
-bindir     = ${exec_prefix}/bin
+bindir      = ${exec_prefix}/bin
+udevdir            = ../..
+klibcdir    = $(udevdir)/klibc
+sysfsdir    = $(udevdir)/libsysfs
 
 CC = gcc
-CFLAGS = -pipe -g -O2 -Wall -Wunused -Wstrict-prototypes -nostdinc -I../../klibc/klibc/include -I../../klibc/klibc/include/bits32 -I/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/include -I../../klibc/linux/include -I../../libsysfs -I.
-LDFLAGS = -lsysfs -ldevmapper -ldlist
+GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
+CFLAGS = -pipe -g -O2 -Wall -Wunused -Wstrict-prototypes -nostdinc \
+         -I$(klibcdir)/klibc/include -I$(klibcdir)/klibc/include/bits32 \
+         -I$(GCCINCDIR) -I$(klibcdir)/linux/include -I$(sysfsdir) -I.
 
 OBJS = main.o
 CRT0 = ../../klibc/klibc/crt0.o
 LIB = ../../klibc/klibc/libc.a
-LIBGCC = /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/libgcc.a
+LIBGCC := $(shell $(CC) -print-libgcc-file-name )
+
 DMOBJS = libdevmapper/libdm-common.o libdevmapper/ioctl/libdevmapper.o
 SYSFSOBJS = ../../libsysfs/dlist.o ../../libsysfs/sysfs_bus.o \
            ../../libsysfs/sysfs_class.o ../../libsysfs/sysfs_device.o \
index 72b39ce..b160075 100644 (file)
@@ -3,7 +3,14 @@
 # Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui@free.fr>
 
 CC = gcc
-CFLAGS = -pipe -g -O2 -Wall -Wunused -Wstrict-prototypes -nostdinc -I../../../klibc/klibc/include -I../../../klibc/klibc/include/bits32 -I/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/include -I../../../klibc/linux/include -I. -Iioctl
+udevdir     = ../../..
+klibcdir    = $(udevdir)/klibc
+
+CC = gcc
+GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
+CFLAGS = -pipe -g -O2 -Wall -Wunused -Wstrict-prototypes -nostdinc \
+         -I$(klibcdir)/klibc/include -I$(klibcdir)/klibc/include/bits32 \
+         -I$(GCCINCDIR) -I$(klibcdir)/linux/include -I. -Iioctl
 
 OBJS = ioctl/libdevmapper.o libdm-common.o
 
index bc65899..e62d763 100644 (file)
@@ -253,6 +253,9 @@ get_all_paths_sysfs(struct env * conf, struct path * all_paths)
                sprintf(all_paths[k].sg_dev, "/dev/%s", buff);
                strcpy(all_paths[k].dev, all_paths[k].sg_dev);
                if ((sg_fd = open(all_paths[k].sg_dev, O_RDONLY)) < 0) {
+                       if (conf->verbose)
+                               fprintf(stderr, "can't open %s. mknod ?",
+                                       all_paths[k].sg_dev); 
                        continue;
                }
                get_lun_strings(sg_fd, &all_paths[k]);
@@ -285,8 +288,12 @@ get_all_paths_nosysfs(struct env * conf, struct path * all_paths,
                sprintf(buff, "%d", k);
                strncat(file_name, buff, FILE_NAME_SIZE);
                strcpy(all_paths[k].sg_dev, file_name);
-               if ((sg_fd = open(file_name, O_RDONLY)) < 0)
+               if ((sg_fd = open(file_name, O_RDONLY)) < 0) {
+                       if (conf->verbose)
+                               fprintf(stderr, "can't open %s. mknod ?",
+                                       file_name); 
                        continue;
+               }
                get_lun_strings(sg_fd, &all_paths[k]);
                get_unique_id(sg_fd, &all_paths[k]);
                all_paths[k].state = do_tur(sg_fd);
@@ -340,8 +347,12 @@ get_all_scsi_ids(struct env * conf, struct scsi_dev * all_scsi_ids)
                } else
                        strcat(fname, "xxxx");
 
-               if ((fd = open(fname, O_RDONLY)) < 0)
+               if ((fd = open(fname, O_RDONLY)) < 0) {
+                       if (conf->verbose)
+                               fprintf(stderr, "can't open %s. mknod ?",
+                                       fname); 
                        continue;
+               }
 
                res = ioctl(fd, SCSI_IOCTL_GET_IDLUN, &my_scsi_id);
                if (res < 0) {
index 692e5e4..a1de1d8 100644 (file)
 #define MX_ALLOC_LEN   255
 #define BLKGETSIZE      _IO(0x12,96)
 #define DM_TARGET      "striped"
+/*
+#define DM_TARGET      "multipath"
+#define DM_POLL_INTERVAL       10
+#define DM_PATH_SELECTOR       "latency"
+*/
 
 #define PINDEX(x,y)    mp[(x)].pindex[(y)]