2 dnl # Check for ZFS support in libblkid. This test needs to check
3 dnl # more than if the library exists because we expect there are
4 dnl # at least 3 flavors of the library out in the wild:
6 dnl # 1) blkid which has no ZFS support
7 dnl # 2) blkid with ZFS support and a flawed method of probing
8 dnl # 3) blkid with ZFS support and a working method of probing
10 dnl # To handle this the check first validates that there is a version
11 dnl # of the library installed. If there is it creates a simulated
12 dnl # ZFS filesystem and then links a small test app which attempts
13 dnl # to detect the simualated filesystem type. If it correctly
14 dnl # identifies the filesystem as ZFS we can safely assume case 3).
15 dnl # Otherwise we disable blkid support and resort to manual probing.
17 AC_DEFUN([ZFS_AC_CONFIG_USER_LIBBLKID], [
19 [AS_HELP_STRING([--with-blkid],
20 [support blkid caching @<:@default=check@:>@])],
25 AS_IF([test "x$with_blkid" = xyes],
27 AC_SUBST([LIBBLKID], ["-lblkid"])
28 AC_DEFINE([HAVE_LIBBLKID], 1,
29 [Define if you have libblkid])
32 AS_IF([test "x$with_blkid" = xcheck],
34 AC_CHECK_LIB([blkid], [blkid_get_cache],
36 AC_MSG_CHECKING([for blkid zfs support])
39 truncate -s 64M $ZFS_DEV
40 echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
41 dd of=$ZFS_DEV bs=1k count=8 \
42 seek=128 conv=notrunc &>/dev/null \
43 >/dev/null 2>/dev/null
44 echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
45 dd of=$ZFS_DEV bs=1k count=8 \
46 seek=132 conv=notrunc &>/dev/null \
47 >/dev/null 2>/dev/null
48 echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
49 dd of=$ZFS_DEV bs=1k count=8 \
50 seek=136 conv=notrunc &>/dev/null \
51 >/dev/null 2>/dev/null
52 echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
53 dd of=$ZFS_DEV bs=1k count=8 \
54 seek=140 conv=notrunc &>/dev/null \
55 >/dev/null 2>/dev/null
60 AC_RUN_IFELSE([AC_LANG_PROGRAM(
64 #include <blkid/blkid.h>
70 if (blkid_get_cache(&cache, NULL) < 0)
73 value = blkid_get_tag_value(cache, "TYPE",
76 blkid_put_cache(cache);
80 if (strcmp(value, "zfs_member")) {
82 blkid_put_cache(cache);
87 blkid_put_cache(cache);
92 AC_SUBST([LIBBLKID], ["-lblkid"])
93 AC_DEFINE([HAVE_LIBBLKID], 1,
94 [Define if you have libblkid])
99 AS_IF([test "x$with_blkid" != xcheck],
101 [--with-blkid given but unavailable])])
107 AS_IF([test "x$with_blkid" != xcheck],
109 [--with-blkid given but unavailable])])