From: Roland Dreier Date: Thu, 25 May 2006 16:38:11 +0000 (+0000) Subject: r7497: Development versions of libibverbs don't include libsysfs headers or X-Git-Tag: v1.0-rc1~14 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=d9056d9549cc03e3a3ca6e2ef1aba8c31c4e37da;p=~shefty%2Flibibcm.git r7497: Development versions of libibverbs don't include libsysfs headers or link with libsysfs implicitly any more. So libibcm and librdmacm need to explicitly include and link libsysfs. Signed-off-by: Roland Dreier --- diff --git a/configure.in b/configure.in index 0dff705..425405c 100644 --- a/configure.in +++ b/configure.in @@ -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([ not found. libibcm requires libsysfs.])) AC_CHECK_HEADER(infiniband/verbs.h, [], AC_MSG_ERROR([ not found. Is libibverbs installed?])) AC_CHECK_HEADER(infiniband/marshall.h, [], diff --git a/src/cm.c b/src/cm.c index f6105db..27550d4 100644 --- a/src/cm.c +++ b/src/cm.c @@ -50,6 +50,8 @@ #include #include +#include + #include #include #include @@ -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)