Skip to contentSkip to conversation

xfsprogs: allow using libblkid instead of libdisk

PATCH In review Christoph Hellwig 2 participants 3 messages Oct 6, 2009 – Oct 7, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsprogs: allow using libblkid instead of libdisk

Add a new --enable-blkid switch to use libblkid from util-linux to detect the device geometry and check for existing partitions or filesystem on a device. Note that this requires the latest blkid from util-linux-ng git for the topology calls, odler ones won't work. If I had a little more autoconf fu we might be able to detect a too early one, but right now it just fails if it's too old and --enable-blkid is specified. We also stop building libdisk in the blkid case as it's an internal static library not otherwise used.

For the actual checks I tried to stay as close as possible to the old code, so we still don't check topology for external log devices. I hope to add this at a later stage.

As a small addition we also print a warning if trying to create a filesystem on a partition that is not properly aligned.

mkfs/Makefile +16 -3
Index: xfsprogs-dev/mkfs/Makefile
===================================================================
@@ -11,14 +11,27 @@ FSTYP = fstyp
 HFILES = xfs_mkfs.h
 CFILES = maxtrres.c proto.c xfs_mkfs.c
 
-LLDLIBS = $(LIBXFS) $(LIBUUID) $(LIBDISK) $(LIBRT) $(LIBPTHREAD)
-LTDEPENDENCIES = $(LIBXFS) $(LIBDISK)
+LLDLIBS = $(LIBXFS) $(LIBUUID) $(LIBRT) $(LIBPTHREAD)
+LTDEPENDENCIES = $(LIBXFS)
 LLDFLAGS = -static
 
+ifeq ($(ENABLE_BLKID),yes)
+LLDLIBS += $(LIBBLKID)
+CFLAGS += -DENABLE_BLKID
+else
+LLDLIBS += $(LIBDISK)
+LTDEPENDENCIES += $(LIBDISK)
+endif
+
+
 LSRCFILES = $(FSTYP).c
 LDIRT = $(FSTYP)
 
-default: $(FSTYP) $(LTCOMMAND)
+default: $(LTCOMMAND)
+
+ifneq ($(ENABLE_BLKID),yes)
+default: $(FSTYP)
+endif
 
 include $(BUILDRULES)
 
mkfs/xfs_mkfs.c +149 -21

241 lines not on this page · raw message

Makefile +10 -2
Index: xfsprogs-dev/Makefile
===================================================================
@@ -16,10 +16,14 @@ LDIRT = config.log .dep config.status co
 	Logs/* built .census install.* install-dev.* *.gz autom4te.cache/* \
 	libtool include/builddefs include/platform_defs.h
 
-LIB_SUBDIRS = libxfs libxlog libxcmd libhandle libdisk
+LIB_SUBDIRS = libxfs libxlog libxcmd libhandle $(LDISK)
 TOOL_SUBDIRS = copy db estimate fsck fsr growfs io logprint mkfs quota \
 		mdrestore repair rtcp m4 man doc po debian build
 
+ifneq ($(ENABLE_BLKID), yes)
+LIB_SUBDIRS += libdisk
+endif
+
 SUBDIRS = include $(LIB_SUBDIRS) $(TOOL_SUBDIRS)
 
 default: include/builddefs include/platform_defs.h
@@ -36,10 +40,14 @@ db logprint: libxfs libxlog
 fsr: libhandle
 growfs: libxfs libxcmd
 io: libxcmd libhandle
-mkfs: libxfs libdisk
+mkfs: libxfs
 quota: libxcmd
 repair: libxfs libxlog
 
+ifneq ($(ENABLE_BLKID), yes)
+mkfs: libdisk
+endif
+
 ifeq ($(HAVE_BUILDDEFS), yes)
 include $(BUILDRULES)
 else
configure.in +6 -0
Index: xfsprogs-dev/configure.in
===================================================================
@@ -35,6 +35,12 @@ AC_ARG_ENABLE(termcap,
 	test $enable_termcap = yes && libtermcap="-ltermcap",)
 AC_SUBST(libtermcap)
 
+AC_ARG_ENABLE(blkid,
+[ --enable-blkid=[yes/no] Enable block device id library [default=no]],
+	test $enable_blkid = yes && libblkid="-lblkid",)
+AC_SUBST(libblkid)
+AC_SUBST(enable_blkid)
+
 AC_ARG_ENABLE(lib64,
 [ --enable-lib64=[yes/no] Enable lib64 support [default=yes]],,
 	enable_lib64=yes)
include/builddefs.in +2 -0
Index: xfsprogs-dev/include/builddefs.in
===================================================================
@@ -31,6 +31,7 @@ LIBPTHREAD = @libpthread@
 LIBTERMCAP = @libtermcap@
 LIBEDITLINE = @libeditline@
 LIBREADLINE = @libreadline@
+LIBBLKID = @libblkid@
 LIBXFS = $(TOPDIR)/libxfs/libxfs.la
 LIBXCMD = $(TOPDIR)/libxcmd/libxcmd.la
 LIBXLOG = $(TOPDIR)/libxlog/libxlog.la
@@ -85,6 +86,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@
 

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 6 lines · Christoph Hellwig

Add a new --enable-blkid switch to use libblkid from util-linux to detect the device geometry and check for existing partitions or filesystem on a device. Note that this requires the latest blkid from util-linux-ng git for the topology calls, odler ones won't work. If I had a little more autoconf fu we might be able to detect a too early one, but right now it just fails if it's too old and --enable-blkid is specified.

Here's some autoconf fu to check for blkid topo support; this changes it to default to using blkid, optionally disable-able, and disables it automatically if the topo stuff isn't found (I think ;)

---

configure.in +0 -0
index 78ac522..f75fad1 100644
@@ -35,11 +35,10 @@ AC_ARG_ENABLE(termcap,
	test $enable_termcap = yes && libtermcap="-ltermcap",)

AC_SUBST(libtermcap)

+# AC_HAVE_BLKID_TOPO below wil find the library & check for topo support AC_ARG_ENABLE(blkid,
-[ --enable-blkid=[yes/no] Enable block device id library [default=no]],
- test $enable_blkid = yes && libblkid="-lblkid",)
-AC_SUBST(libblkid)
-AC_SUBST(enable_blkid)
+[ --enable-blkid=[yes/no] Enable block device id library [default=yes]],,
+ enable_blkid=yes)

AC_ARG_ENABLE(lib64,
[ --enable-lib64=[yes/no] Enable lib64 support [default=yes]],, @@ -96,6 +95,7 @@ AC_HAVE_SENDFILE
AC_HAVE_GETMNTENT
AC_HAVE_GETMNTINFO
AC_HAVE_FALLOCATE
+AC_HAVE_BLKID_TOPO($enable_blkid)

AC_TYPE_PSINT
AC_TYPE_PSUNSIGNED

m4/package_blkid.m4 new file +20 -0
new file mode 100644
index 0000000..44ca2cc
@@ -0,0 +1,20 @@
+#
+# See if blkid has the topology bits
+#
+
+AC_DEFUN([AC_HAVE_BLKID_TOPO],
+[
+  enable_blkid="$1"
+  if test "$enable_blkid" = "yes"; then
+    AC_SEARCH_LIBS([blkid_probe_all], [blkid])
+    AC_CHECK_FUNCS(blkid_probe_get_topology)
+    if test $ac_cv_func_blkid_probe_get_topology = yes; then
+      libblkid="-lblkid"
+    else
+      libblkd=""
+      enable_blkid="no"
+      AC_SUBST(enable_blkid)
+    fi
+  fi
+  AC_SUBST(libblkid)
+])

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 11 lines · Eric Sandeen
Quoted 6 lines · Christoph Hellwig

Add a new --enable-blkid switch to use libblkid from util-linux to detect the device geometry and check for existing partitions or filesystem on a device. Note that this requires the latest blkid from util-linux-ng git for the topology calls, odler ones won't work. If I had a little more autoconf fu we might be able to detect a too early one, but right now it just fails if it's too old and --enable-blkid is specified.

Here's some autoconf fu to check for blkid topo support; this changes it to default to using blkid, optionally disable-able, and disables it automatically if the topo stuff isn't found (I think ;)

Thanks, I've folded it into my patch.

Btw, something I forgot to ask with the original patch: Does anyone have a use for the fstype binary that doesn't actually get installed? It would be a lot cleaner to just nuke it instead of building it conditionally.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs