* [infiniband-diags PATCH 0/2] libudev usage fixes
@ 2015-06-25 14:12 Michal Schmidt
[not found] ` <1435241522-7721-1-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Michal Schmidt @ 2015-06-25 14:12 UTC (permalink / raw)
To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
Hello,
the first patch simplifies code.
The second patch fixes an overlinking issue.
Regards,
Michal
Michal Schmidt (2):
rdma-ndd: never use udev_get_sys_path()
build-sys: avoid overlinking to libudev
Makefile.am | 6 ++++++
configure.ac | 10 +++++-----
src/rdma-ndd.c | 19 +++++--------------
3 files changed, 16 insertions(+), 19 deletions(-)
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [infiniband-diags PATCH 1/2] rdma-ndd: never use udev_get_sys_path()
[not found] ` <1435241522-7721-1-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2015-06-25 14:12 ` Michal Schmidt
[not found] ` <1435241522-7721-2-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-25 14:12 ` [infiniband-diags PATCH 2/2] build-sys: avoid overlinking to libudev Michal Schmidt
1 sibling, 1 reply; 5+ messages in thread
From: Michal Schmidt @ 2015-06-25 14:12 UTC (permalink / raw)
To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
The function was deprecated and later dropped by udev entirely
because it was pointless.
Quoting kernel's Documentation/sysfs-rules.txt:
sysfs is always at /sys
Parsing /proc/mounts is a waste of time. Other mount points are
a system configuration bug you should not try to solve. [...]
Signed-off-by: Michal Schmidt <mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
configure.ac | 1 -
src/rdma-ndd.c | 19 +++++--------------
2 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/configure.ac b/configure.ac
index b9b7ad84ee..ece1d530a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -214,7 +214,6 @@ if test x$rdmandd = xyes; then
AC_CHECK_HEADER(libudev.h, with_udev="yes", with_udev="no")
AC_CHECK_LIB(udev, udev_monitor_ref, [], AC_MSG_ERROR(libudev is required for rdma-ndd...))
AC_CONFIG_FILES([doc/man/rdma-ndd.8 etc/rdma-ndd.init])
- AC_CHECK_FUNCS_ONCE(udev_get_sys_path)
fi
dnl Generate doc/man/*.in files if possible
diff --git a/src/rdma-ndd.c b/src/rdma-ndd.c
index 194c2cd865..d40e7567db 100644
--- a/src/rdma-ndd.c
+++ b/src/rdma-ndd.c
@@ -58,9 +58,7 @@ struct udev_monitor *mon;
#include "ibdiag_common.h"
#define SYS_HOSTNAME "/proc/sys/kernel/hostname"
-#define DEF_SYS_DIR "/sys"
-char *sys_dir = DEF_SYS_DIR;
-#define SYS_INFINIBAND "class/infiniband"
+#define SYS_INFINIBAND "/sys/class/infiniband"
#define DEFAULT_RETRY_RATE 60
#define DEFAULT_RETRY_COUNT 0
#define DEFAULT_ND_FORMAT "%h %d"
@@ -122,8 +120,8 @@ static int update_node_desc(const char *device, const char *hostname, int force)
char nd_file[PATH_MAX];
FILE *f;
- snprintf(nd_file, sizeof(nd_file), "%s/%s/%s/node_desc",
- sys_dir, SYS_INFINIBAND, device);
+ snprintf(nd_file, sizeof(nd_file), SYS_INFINIBAND "/%s/node_desc",
+ device);
nd_file[sizeof(nd_file)-1] = '\0';
f = fopen(nd_file, "r+");
@@ -160,14 +158,10 @@ static int set_rdma_node_desc(const char *hostname, int force)
{
DIR *class_dir;
struct dirent *dent;
- char dev_dir[PATH_MAX];
- snprintf(dev_dir, sizeof(dev_dir), "%s/%s", sys_dir, SYS_INFINIBAND);
- dev_dir[sizeof(dev_dir)-1] = '\0';
-
- class_dir = opendir(dev_dir);
+ class_dir = opendir(SYS_INFINIBAND);
if (!class_dir) {
- syslog(LOG_INFO, "Failed to open %s", dev_dir);
+ syslog(LOG_INFO, "Failed to open " SYS_INFINIBAND);
return -ENOSYS;
}
@@ -261,9 +255,6 @@ static void setup_udev(void)
udev_set_log_fn(udev, udev_log_fn);
udev_set_log_priority(udev, LOG_INFO);
-#if HAVE_UDEV_GET_SYS_PATH
- sys_dir = (char *)udev_get_sys_path(udev);
-#endif
}
static int get_udev_fd(void)
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [infiniband-diags PATCH 2/2] build-sys: avoid overlinking to libudev
[not found] ` <1435241522-7721-1-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-25 14:12 ` [infiniband-diags PATCH 1/2] rdma-ndd: never use udev_get_sys_path() Michal Schmidt
@ 2015-06-25 14:12 ` Michal Schmidt
[not found] ` <1435241522-7721-3-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
1 sibling, 1 reply; 5+ messages in thread
From: Michal Schmidt @ 2015-06-25 14:12 UTC (permalink / raw)
To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
Not all built binaries need to link to udev, only rdma-ndd.
Use pkg-config to detect udev in configure.ac.
Signed-off-by: Michal Schmidt <mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
Makefile.am | 6 ++++++
configure.ac | 9 +++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 057508b18d..93af707ad6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -130,6 +130,12 @@ src_ibcacheedit_LDFLAGS = -L$(top_builddir)/libibnetdisc -libnetdisc
src_dump_fts_SOURCES = src/dump_fts.c
src_dump_fts_LDFLAGS = -L$(top_builddir)/libibnetdisc -libnetdisc
+if ENABLE_RDMA_NDD
+src_rdma_ndd_SOURCES = src/rdma-ndd.c
+src_rdma_ndd_CFLAGS = $(AM_CFLAGS) $(UDEV_CFLAGS)
+src_rdma_ndd_LDADD = libcommon.a $(UDEV_LIBS)
+endif
+
BUILT_SOURCES = ibdiag_version
ibdiag_version:
if [ -x $(top_srcdir)/gen_ver.sh ] ; then \
diff --git a/configure.ac b/configure.ac
index ece1d530a7..090b6ecf76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -210,11 +210,12 @@ default_start="null"
AC_SUBST(DEFAULT_START, $default_start)
AC_SUBST(DEFAULT_STOP, $default_stop)
-if test x$rdmandd = xyes; then
- AC_CHECK_HEADER(libudev.h, with_udev="yes", with_udev="no")
- AC_CHECK_LIB(udev, udev_monitor_ref, [], AC_MSG_ERROR(libudev is required for rdma-ndd...))
+AS_IF([test x$rdmandd = xyes], [
+ PKG_CHECK_MODULES([UDEV], [libudev])
AC_CONFIG_FILES([doc/man/rdma-ndd.8 etc/rdma-ndd.init])
-fi
+ AC_SUBST([UDEV_CFLAGS])
+ AC_SUBST([UDEV_LIBS])
+])
dnl Generate doc/man/*.in files if possible
DOC_DATE="`date +%Y-%m-%d`"
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [infiniband-diags PATCH 1/2] rdma-ndd: never use udev_get_sys_path()
[not found] ` <1435241522-7721-2-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2015-07-14 15:44 ` ira.weiny
0 siblings, 0 replies; 5+ messages in thread
From: ira.weiny @ 2015-07-14 15:44 UTC (permalink / raw)
To: Michal Schmidt; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
On Thu, Jun 25, 2015 at 04:12:01PM +0200, Michal Schmidt wrote:
> The function was deprecated and later dropped by udev entirely
> because it was pointless.
> Quoting kernel's Documentation/sysfs-rules.txt:
> sysfs is always at /sys
> Parsing /proc/mounts is a waste of time. Other mount points are
> a system configuration bug you should not try to solve. [...]
>
> Signed-off-by: Michal Schmidt <mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Thanks applied,
Ira
> ---
> configure.ac | 1 -
> src/rdma-ndd.c | 19 +++++--------------
> 2 files changed, 5 insertions(+), 15 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index b9b7ad84ee..ece1d530a7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -214,7 +214,6 @@ if test x$rdmandd = xyes; then
> AC_CHECK_HEADER(libudev.h, with_udev="yes", with_udev="no")
> AC_CHECK_LIB(udev, udev_monitor_ref, [], AC_MSG_ERROR(libudev is required for rdma-ndd...))
> AC_CONFIG_FILES([doc/man/rdma-ndd.8 etc/rdma-ndd.init])
> - AC_CHECK_FUNCS_ONCE(udev_get_sys_path)
> fi
>
> dnl Generate doc/man/*.in files if possible
> diff --git a/src/rdma-ndd.c b/src/rdma-ndd.c
> index 194c2cd865..d40e7567db 100644
> --- a/src/rdma-ndd.c
> +++ b/src/rdma-ndd.c
> @@ -58,9 +58,7 @@ struct udev_monitor *mon;
> #include "ibdiag_common.h"
>
> #define SYS_HOSTNAME "/proc/sys/kernel/hostname"
> -#define DEF_SYS_DIR "/sys"
> -char *sys_dir = DEF_SYS_DIR;
> -#define SYS_INFINIBAND "class/infiniband"
> +#define SYS_INFINIBAND "/sys/class/infiniband"
> #define DEFAULT_RETRY_RATE 60
> #define DEFAULT_RETRY_COUNT 0
> #define DEFAULT_ND_FORMAT "%h %d"
> @@ -122,8 +120,8 @@ static int update_node_desc(const char *device, const char *hostname, int force)
> char nd_file[PATH_MAX];
> FILE *f;
>
> - snprintf(nd_file, sizeof(nd_file), "%s/%s/%s/node_desc",
> - sys_dir, SYS_INFINIBAND, device);
> + snprintf(nd_file, sizeof(nd_file), SYS_INFINIBAND "/%s/node_desc",
> + device);
> nd_file[sizeof(nd_file)-1] = '\0';
>
> f = fopen(nd_file, "r+");
> @@ -160,14 +158,10 @@ static int set_rdma_node_desc(const char *hostname, int force)
> {
> DIR *class_dir;
> struct dirent *dent;
> - char dev_dir[PATH_MAX];
>
> - snprintf(dev_dir, sizeof(dev_dir), "%s/%s", sys_dir, SYS_INFINIBAND);
> - dev_dir[sizeof(dev_dir)-1] = '\0';
> -
> - class_dir = opendir(dev_dir);
> + class_dir = opendir(SYS_INFINIBAND);
> if (!class_dir) {
> - syslog(LOG_INFO, "Failed to open %s", dev_dir);
> + syslog(LOG_INFO, "Failed to open " SYS_INFINIBAND);
> return -ENOSYS;
> }
>
> @@ -261,9 +255,6 @@ static void setup_udev(void)
>
> udev_set_log_fn(udev, udev_log_fn);
> udev_set_log_priority(udev, LOG_INFO);
> -#if HAVE_UDEV_GET_SYS_PATH
> - sys_dir = (char *)udev_get_sys_path(udev);
> -#endif
> }
>
> static int get_udev_fd(void)
> --
> 2.4.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [infiniband-diags PATCH 2/2] build-sys: avoid overlinking to libudev
[not found] ` <1435241522-7721-3-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2015-07-14 15:44 ` ira.weiny
0 siblings, 0 replies; 5+ messages in thread
From: ira.weiny @ 2015-07-14 15:44 UTC (permalink / raw)
To: Michal Schmidt; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
On Thu, Jun 25, 2015 at 04:12:02PM +0200, Michal Schmidt wrote:
> Not all built binaries need to link to udev, only rdma-ndd.
> Use pkg-config to detect udev in configure.ac.
>
> Signed-off-by: Michal Schmidt <mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Thanks applied,
Ira
> ---
> Makefile.am | 6 ++++++
> configure.ac | 9 +++++----
> 2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 057508b18d..93af707ad6 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -130,6 +130,12 @@ src_ibcacheedit_LDFLAGS = -L$(top_builddir)/libibnetdisc -libnetdisc
> src_dump_fts_SOURCES = src/dump_fts.c
> src_dump_fts_LDFLAGS = -L$(top_builddir)/libibnetdisc -libnetdisc
>
> +if ENABLE_RDMA_NDD
> +src_rdma_ndd_SOURCES = src/rdma-ndd.c
> +src_rdma_ndd_CFLAGS = $(AM_CFLAGS) $(UDEV_CFLAGS)
> +src_rdma_ndd_LDADD = libcommon.a $(UDEV_LIBS)
> +endif
> +
> BUILT_SOURCES = ibdiag_version
> ibdiag_version:
> if [ -x $(top_srcdir)/gen_ver.sh ] ; then \
> diff --git a/configure.ac b/configure.ac
> index ece1d530a7..090b6ecf76 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -210,11 +210,12 @@ default_start="null"
> AC_SUBST(DEFAULT_START, $default_start)
> AC_SUBST(DEFAULT_STOP, $default_stop)
>
> -if test x$rdmandd = xyes; then
> - AC_CHECK_HEADER(libudev.h, with_udev="yes", with_udev="no")
> - AC_CHECK_LIB(udev, udev_monitor_ref, [], AC_MSG_ERROR(libudev is required for rdma-ndd...))
> +AS_IF([test x$rdmandd = xyes], [
> + PKG_CHECK_MODULES([UDEV], [libudev])
> AC_CONFIG_FILES([doc/man/rdma-ndd.8 etc/rdma-ndd.init])
> -fi
> + AC_SUBST([UDEV_CFLAGS])
> + AC_SUBST([UDEV_LIBS])
> +])
>
> dnl Generate doc/man/*.in files if possible
> DOC_DATE="`date +%Y-%m-%d`"
> --
> 2.4.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-07-14 15:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-25 14:12 [infiniband-diags PATCH 0/2] libudev usage fixes Michal Schmidt
[not found] ` <1435241522-7721-1-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-25 14:12 ` [infiniband-diags PATCH 1/2] rdma-ndd: never use udev_get_sys_path() Michal Schmidt
[not found] ` <1435241522-7721-2-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-07-14 15:44 ` ira.weiny
2015-06-25 14:12 ` [infiniband-diags PATCH 2/2] build-sys: avoid overlinking to libudev Michal Schmidt
[not found] ` <1435241522-7721-3-git-send-email-mschmidt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-07-14 15:44 ` ira.weiny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).