xfsqa: build dbtest on debian platforms
authorDave Chinner <david@fromorbit.com>
Tue, 4 May 2010 06:01:26 +0000 (16:01 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 4 May 2010 06:01:26 +0000 (16:01 +1000)
Set up autoconf to find the correct headers and compat libraries for
debian squeeze, and massage the includes to ensure the right headers get
included. Also fix a compile warning that was emitted now that it is being
compiled.

Signed-off-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
m4/package_gdbmdev.m4
src/dbtest.c

index d826acdf0728420f2590960aed1e1ececcd7e0df..6580fbae5befbcb5ec204696931f60847a083d4b 100644 (file)
@@ -6,9 +6,13 @@ AC_DEFUN([AC_PACKAGE_WANT_NDBM],
   ])
 
 AC_DEFUN([AC_PACKAGE_WANT_GDBM],
   ])
 
 AC_DEFUN([AC_PACKAGE_WANT_GDBM],
-  [ AC_CHECK_HEADERS([gdbm/ndbm.h], [ have_db=true ], [ have_db=false ])
+  [ AC_CHECK_HEADERS([gdbm/ndbm.h, gdbm-ndbm.h], [ have_db=true ], [ have_db=false ])
+    libgdbm=""
+    if test $have_db = true -a -f ${libexecdir}${libdirsuffix}/libgdbm_compat.a; then
+       libgdbm="${libexecdir}${libdirsuffix}/libgdbm_compat.a"
+    fi
     if test $have_db = true -a -f ${libexecdir}${libdirsuffix}/libgdbm.a; then
     if test $have_db = true -a -f ${libexecdir}${libdirsuffix}/libgdbm.a; then
-       libgdbm="${libexecdir}${libdirsuffix}/libgdbm.a"
+       libgdbm="${libgdbm} ${libexecdir}${libdirsuffix}/libgdbm.a"
     fi
     AC_SUBST(libgdbm)
     AC_SUBST(have_db)
     fi
     AC_SUBST(libgdbm)
     AC_SUBST(have_db)
index 48667b79b3b15d47ada54b9f91a31e40fec80e84..ec8db0b93a4e1532d7ad90c4c5f429561a88b6e3 100644 (file)
  
 #include "global.h"
 
  
 #include "global.h"
 
-#ifdef HAVE_GDBM_NDBM_H
+#ifdef HAVE_GDBM_NDBM_H_
 #include <gdbm/ndbm.h>
 #include <gdbm/ndbm.h>
-#else
-#ifdef HAVE_GDBM_H
+#elif HAVE_GDBM_NDBM_H
+#include <gdbm-ndbm.h>
+#elif HAVE_GDBM_H
 #include <gdbm.h>
 #include <gdbm.h>
-#else
-#ifdef HAVE_NDBM_H
+#elif HAVE_NDBM_H
 #include <ndbm.h>
 #else
 bozo!
 #endif
 #include <ndbm.h>
 #else
 bozo!
 #endif
-#endif
-#endif
 
 
 /* #define WorkDir     "/xfs" */
 
 
 /* #define WorkDir     "/xfs" */
@@ -140,11 +138,12 @@ int InitDbmLookup(int howmany)
 
        sprintf(filename, "%s-%d", DBNAME, (int)getpid());
        if (debugflg) {
 
        sprintf(filename, "%s-%d", DBNAME, (int)getpid());
        if (debugflg) {
-               printf("dbm_open(%s, O_WRONLY|O_CREAT, 0644)\n", filename);
+               printf("dbm_open(%s, O_RDWR|O_CREAT, 0644)\n", filename);
                fflush(stdout);
        }
                fflush(stdout);
        }
-       dbm = dbm_open(filename, O_WRONLY|O_CREAT, 0644);
-       if(dbm == NULL) DoSysError("\ndbm_open", (int)dbm);
+       dbm = dbm_open(filename, O_RDWR|O_CREAT, 0644);
+       if(dbm == NULL)
+               DoSysError("\ndbm_open", -1);
 
        if ((KeyArray = (unsigned short *)calloc( howmany,
                                sizeof(unsigned short))) == NULL)
 
        if ((KeyArray = (unsigned short *)calloc( howmany,
                                sizeof(unsigned short))) == NULL)
@@ -191,11 +190,12 @@ int InitDbmLookup(int howmany)
        }
        dbm_close(dbm); /* close to eliminate chance of in-memory caching */
        if (debugflg) {
        }
        dbm_close(dbm); /* close to eliminate chance of in-memory caching */
        if (debugflg) {
-               printf("dbm_open(%s, O_RDNLY, 0)\n", filename);
+               printf("dbm_open(%s, O_RDONLY, 0)\n", filename);
                fflush(stdout);
        }
        dbm = dbm_open(filename, O_RDONLY, 0);
                fflush(stdout);
        }
        dbm = dbm_open(filename, O_RDONLY, 0);
-       if(dbm == NULL) DoSysError("\ndbm_open", (int)dbm);
+       if(dbm == NULL)
+               DoSysError("\ndbm_open", -1);
        return 0;
 }
 
        return 0;
 }