Skip to contentSkip to conversation

misc: if dlopen() is available, use it to load the libmagic library

PATCH New Theodore Ts'o 2 participants 3 messages Sep 21, 2014 – Oct 4, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: if dlopen() is available, use it to load the libmagic library

This prevents the libmagic library from being a hard dependency; if it's not there, we can simply do without it.

Cc Darrick J. Wong <[email protected]>
---
 configure        |  3 +++
 configure.in     |  3 +++
 misc/plausible.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 55 insertions(+), 7 deletions(-)
configure +3 -0
index 7ee6323..2bc1275 100755
@@ -13187,6 +13187,9 @@ done
 
 fi
 
+if test "$ac_cv_lib_dl_dlopen" = yes ; then
+   MAGIC_LIB=$DLOPEN_LIB
+fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for optreset" >&5
 $as_echo_n "checking for optreset... " >&6; }
configure.in +3 -0
index 3bd3c20..e809324 100644
@@ -1157,6 +1157,9 @@ dnl See if libmagic exists
 dnl
 AC_CHECK_LIB(magic, magic_file, [MAGIC_LIB=-lmagic
 AC_CHECK_HEADERS([magic.h])])
+if test "$ac_cv_lib_dl_dlopen" = yes ; then
+   MAGIC_LIB=$DLOPEN_LIB
+fi
 AC_SUBST(MAGIC_LIB)
 dnl
 dnl See if optreset exists
misc/plausible.c +49 -7

75 lines not on this page · raw message

Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/1 misc: fix build on absence of magic.h

If magic.h is not present, there will be unresolved references to the magic_t type in plausible.c. Fix that by moving the protecting #ifdef directive.

---
 misc/plausible.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
misc/plausible.c +1 -1
index aea4fce..00bc6e2 100644
@@ -36,12 +36,12 @@
 #include "nls-enable.h"
 #include "blkid/blkid.h"
 
+#ifdef HAVE_MAGIC_H
 static magic_t (*dl_magic_open)(int);
 static const char *(*dl_magic_file)(magic_t, const char *);
 static int (*dl_magic_load)(magic_t, const char *);
 static void (*dl_magic_close)(magic_t);
 
-#ifdef HAVE_MAGIC_H
 #ifdef HAVE_DLOPEN
 #include <dlfcn.h>
 
Signature · 1 line
1.9.1
author Applied
#2 lore raw

Re: [PATCH] misc: fix build on absence of magic.h

Quoted 4 lines · Artemiy Volkov

If magic.h is not present, there will be unresolved references to the magic_t type in plausible.c. Fix that by moving the protecting #ifdef directive.

Applied, thanks.

- Ted