]> git.openfabrics.org - ~shefty/libibcm.git/commitdiff
r7497: Development versions of libibverbs don't include libsysfs headers or
authorRoland Dreier <rolandd@cisco.com>
Thu, 25 May 2006 16:38:11 +0000 (16:38 +0000)
committerRoland Dreier <roland@topspin.com>
Thu, 25 May 2006 16:38:11 +0000 (16:38 +0000)
link with libsysfs implicitly any more.  So libibcm and librdmacm
need to explicitly include and link libsysfs.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
configure.in
src/cm.c

index 0dff705187c88da63c9e87c44090e2e13dc982a0..425405cce5e4605a9b74174377ff1b4246f1a89a 100644 (file)
@@ -25,6 +25,8 @@ AC_CHECK_SIZEOF(long)
 dnl Checks for libraries
 if test "$disable_libcheck" != "yes"
 then
+AC_CHECK_LIB(sysfs, sysfs_open_class, [],
+    AC_MSG_ERROR([sysfs_open_class() not found.  libibcm requires libsysfs.]))
 AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
     AC_MSG_ERROR([ibv_get_device_list() not found.  libibcm requires libibverbs.]))
 #AC_CHECK_LIB(rdmacm, rdma_create_id, [],
@@ -34,6 +36,8 @@ fi
 dnl Checks for header files.
 if test "$disable_libcheck" != "yes"
 then
+AC_CHECK_HEADER(sysfs/libsysfs.h, [],
+    AC_MSG_ERROR([<sysfs/libsysfs.h> not found.  libibcm requires libsysfs.]))
 AC_CHECK_HEADER(infiniband/verbs.h, [],
     AC_MSG_ERROR([<infiniband/verbs.h> not found.  Is libibverbs installed?]))
 AC_CHECK_HEADER(infiniband/marshall.h, [],
index f6105db8bf549420871491dc11c5321833266ce8..27550d4a940e29431e73b94d248e671e6df30f11 100644 (file)
--- a/src/cm.c
+++ b/src/cm.c
@@ -50,6 +50,8 @@
 #include <endian.h>
 #include <byteswap.h>
 
+#include <sysfs/libsysfs.h>
+
 #include <infiniband/cm.h>
 #include <infiniband/cm_abi.h>
 #include <infiniband/marshall.h>
@@ -115,8 +117,9 @@ static struct dlist *device_list;
 static int check_abi_version(void)
 {
        char path[256];
-       char val[16];
+       struct sysfs_attribute *attr;
        int abi_ver;
+       int ret = -1;
 
        if (sysfs_get_mnt_path(path, sizeof path)) {
                fprintf(stderr, PFX "couldn't find sysfs mount.\n");
@@ -124,20 +127,32 @@ static int check_abi_version(void)
        }
 
        strncat(path, "/class/infiniband_cm/abi_version", sizeof path);
-       if (sysfs_read_attribute_value(path, val, sizeof val)) {
-               fprintf(stderr, PFX "couldn't read ucm ABI version.\n");
+
+       attr = sysfs_open_attribute(path);
+       if (!attr) {
+               fprintf(stderr, PFX "couldn't open ucm ABI version.\n");
                return -1;
        }
 
-       abi_ver = strtol(val, NULL, 10);
+       if (sysfs_read_attribute(attr)) {
+               fprintf(stderr, PFX "couldn't read ucm ABI version.\n");
+               goto out;
+       }
+
+       abi_ver = strtol(attr->value, NULL, 10);
        if (abi_ver < IB_USER_CM_MIN_ABI_VERSION ||
            abi_ver > IB_USER_CM_MAX_ABI_VERSION) {
                fprintf(stderr, PFX "kernel ABI version %d "
                        "doesn't match library version %d.\n",
                        abi_ver, IB_USER_CM_MAX_ABI_VERSION);
-               return -1;
+               goto out;
        }
-       return 0;
+
+       ret = 0;
+
+out:
+       sysfs_close_attribute(attr);
+       return ret;
 }
 
 static uint64_t get_device_guid(struct sysfs_class_device *ibdev)