[lib] define _GNU_SOURCE in preparation for using recvmsg()
authorChristophe Varoqui <christophe.varoqui@free.fr>
Sun, 19 Apr 2009 21:44:28 +0000 (23:44 +0200)
committerChristophe Varoqui <christophe.varoqui@free.fr>
Sun, 19 Apr 2009 21:44:28 +0000 (23:44 +0200)
And deal with consequences :
1/ rename util::basename() to util::basenamecpy() to resolve
   namespace conflict GNU version
2/ don't redefine _GNU_SOURCE if already set in regex.c to avoid
   a build warning

libmultipath/Makefile
libmultipath/configure.c
libmultipath/discovery.c
libmultipath/discovery.h
libmultipath/regex.c
libmultipath/util.c
libmultipath/util.h

index 35cb911..915d2f2 100644 (file)
@@ -17,7 +17,7 @@ OBJS = memory.o parser.o vector.o devmapper.o callout.o \
 LIBDM_API_FLUSH = $(shell if test -d /lib64 ; then objdump -T /lib64/libdevmapper.so* ; else objdump -T /lib/libdevmapper.so.* ; fi | grep -c dm_task_no_flush)
 
 ifneq ($(strip $(LIBDM_API_FLUSH)),0)
-       CFLAGS += -DLIBDM_API_FLUSH
+       CFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE
 endif
 
 all: $(LIBS)
index 8b9a603..e21b8ba 100644 (file)
@@ -34,6 +34,7 @@
 #include "dict.h"
 #include "alias.h"
 #include "prio.h"
+#include "util.h"
 
 extern int
 setup_map (struct multipath * mpp)
@@ -589,7 +590,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec)
                return NULL;
 
        if (dev_type == DEV_DEVNODE) {
-               basename(dev, buff);
+               basenamecpy(dev, buff);
                pp = find_path_by_dev(pathvec, buff);
                
                if (!pp) {
index 9ae2b8f..c92c19b 100644 (file)
@@ -275,7 +275,7 @@ devt2devname (char *devname, char *devt)
                condlog(0, "sysfs entry %s is not a directory\n", block_path);
                return 1;
        }
-       basename(block_path, devname);
+       basenamecpy(block_path, devname);
        return 0;
 }
 
@@ -404,7 +404,7 @@ scsi_sysfs_pathinfo (struct path * pp, struct sysfs_device * parent)
        /*
         * host / bus / target / lun
         */
-       basename(parent->devpath, attr_path);
+       basenamecpy(parent->devpath, attr_path);
 
        sscanf(attr_path, "%i:%i:%i:%i",
                        &pp->sg_id.host_no,
@@ -463,7 +463,7 @@ ccw_sysfs_pathinfo (struct path * pp, struct sysfs_device * parent)
        /*
         * host / bus / target / lun
         */
-       basename(parent->devpath, attr_path);
+       basenamecpy(parent->devpath, attr_path);
        pp->sg_id.lun = 0;
        sscanf(attr_path, "%i.%i.%x",
                        &pp->sg_id.host_no,
@@ -487,7 +487,7 @@ cciss_sysfs_pathinfo (struct path * pp, struct sysfs_device * dev)
        /*
         * host / bus / target / lun
         */
-       basename(dev->devpath, attr_path);
+       basenamecpy(dev->devpath, attr_path);
        pp->sg_id.lun = 0;
        pp->sg_id.channel = 0;
        sscanf(attr_path, "cciss!c%id%i",
index 1c7590d..7283f36 100644 (file)
@@ -27,7 +27,6 @@
 int sysfs_get_dev (struct sysfs_device * dev, char * buff, size_t len);
 int path_discovery (vector pathvec, struct config * conf, int flag);
 
-void basename (char *, char *);
 int do_tur (char *);
 int devt2devname (char *, char *);
 int path_offline (struct path *);
index f08874b..0e13c62 100644 (file)
@@ -19,7 +19,9 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <sys/types.h>
 #include <stdlib.h>
index 57b2a2d..ebe06dc 100644 (file)
@@ -39,7 +39,7 @@ strchop(char *str)
 }
 
 void
-basename (char * str1, char * str2)
+basenamecpy (char * str1, char * str2)
 {
        char *p = str1 + (strlen(str1) - 1);
 
index d0df8aa..52f2578 100644 (file)
@@ -3,7 +3,7 @@
 
 int strcmp_chomp(char *, char *);
 void strchop(char *);
-void basename (char * src, char * dst);
+void basenamecpy (char * src, char * dst);
 int filepresent (char * run);
 int get_word (char * sentence, char ** word);
 size_t strlcpy(char *dst, const char *src, size_t size);