]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
build: make libblkid usage optional
authorJan Tulak <jtulak@redhat.com>
Tue, 13 Oct 2015 23:57:39 +0000 (10:57 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 13 Oct 2015 23:57:39 +0000 (10:57 +1100)
Because not all platforms have up-to-date blkid with required
functions, allow at least partial functionality by adding
--enable-blkid=yes/no optional configure argument.

When blkid is disabled, signature detection and device geometry
detection doesn't work.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
configure.ac
include/builddefs.in
mkfs/xfs_mkfs.c

index 16f3f68baf31c0766e5fc02e122a37e455336520..aa241cd4b657ee469756968947ff048e00325414 100644 (file)
@@ -26,6 +26,11 @@ AC_ARG_ENABLE(gettext,
        enable_gettext=yes)
 AC_SUBST(enable_gettext)
 
+AC_ARG_ENABLE(blkid,
+[ --enable-blkid=[yes/no] Enable use of block device id library [default=yes]],,
+       enable_blkid=yes)
+AC_SUBST(enable_blkid)
+
 AC_ARG_ENABLE(readline,
 [ --enable-readline=[yes/no] Enable readline command editing [default=no]],
        test $enable_readline = yes && libreadline="-lreadline",
@@ -117,9 +122,12 @@ AC_HAVE_PREADV
 AC_HAVE_SYNC_FILE_RANGE
 AC_HAVE_MNTENT
 AC_HAVE_FLS
-AC_HAVE_BLKID_TOPO
 AC_HAVE_READDIR
 
+if test "$enable_blkid" = yes; then
+AC_HAVE_BLKID_TOPO
+fi
+
 AC_CHECK_SIZEOF([long])
 AC_CHECK_SIZEOF([char *])
 AC_TYPE_UMODE_T
index 885195642c63206e4ca1083a541709605d3a6241..6c16a651caffc10eced853c3bfbec2d92bc4da24 100644 (file)
@@ -89,6 +89,7 @@ ENABLE_SHARED = @enable_shared@
 ENABLE_GETTEXT = @enable_gettext@
 ENABLE_EDITLINE        = @enable_editline@
 ENABLE_READLINE        = @enable_readline@
+ENABLE_BLKID   = @enable_blkid@
 
 HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@
 
@@ -138,6 +139,10 @@ endif
 ifeq ($(HAVE_MNTENT),yes)
 PCFLAGS+= -DHAVE_MNTENT
 endif
+ifeq ($(ENABLE_BLKID),yes)
+PCFLAGS+= -DENABLE_BLKID
+endif
+
 
 GCFLAGS = $(OPTIMIZER) $(DEBUG) \
          -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\"  \
index d993fc04baf150dedec7f627dbd94dcec5e84617..5964eaf2f189199f54fec83a14a1902c4c355321 100644 (file)
@@ -18,7 +18,9 @@
 
 #include "libxfs.h"
 #include <ctype.h>
-#include <blkid/blkid.h>
+#ifdef ENABLE_BLKID
+#  include <blkid/blkid.h>
+#endif /* ENABLE_BLKID */
 #include "xfs_mkfs.h"
 
 /*
@@ -298,6 +300,7 @@ calc_stripe_factors(
  *      0 for nothing found
  *     -1 for internal error
  */
+#ifdef ENABLE_BLKID
 static int
 check_overwrite(
        char            *device)
@@ -451,6 +454,38 @@ out_free_probe:
                _("warning: unable to probe device topology for device %s\n"),
                device);
 }
+#else /* ifdef ENABLE_BLKID */
+/*
+ * Without blkid, we can't do a good check for signatures.
+ * So instead of some messy attempts, just disable any checks
+ * and always return 'nothing found'.
+ */
+#  warning BLKID is disabled, so signature detection and block device\
+ access are not working!
+static int
+check_overwrite(
+       char            *device)
+{
+       return 1;
+}
+
+static void blkid_get_topology(
+       const char      *device,
+       int             *sunit,
+       int             *swidth,
+       int             *lsectorsize,
+       int             *psectorsize,
+       int             force_overwrite)
+{
+       /*
+        * Shouldn't make any difference (no blkid = no block device access),
+        * but make sure this dummy replacement returns with at least some
+        * sanity.
+        */
+       *lsectorsize = *psectorsize = 512;
+}
+
+#endif /* ENABLE_BLKID */
 
 static void get_topology(
        libxfs_init_t           *xi,