[Libguestfs] [PATCH supermin 2/2] Use AC_HEADER_MAJOR to find definitions of major, minor, makedev.

Richard W.M. Jones rjones at redhat.com
Wed Mar 1 12:18:58 UTC 2017


Note this requires either the following fix in autoconf:

http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=e17a30e98

OR gnulib sys_types module plus gnulib
commit a512e041120e9012e69afa2f5c3adc196ec4999a (any gnulib more
recent than Sep 2016) which corrects the AC_HEADER_MAJOR macro in a
similar way.
---
 configure.ac       | 3 +++
 init/init.c        | 6 ++++++
 m4/gnulib-cache.m4 | 1 +
 src/ext2fs-c.c     | 6 ++++++
 4 files changed, 16 insertions(+)

diff --git a/configure.ac b/configure.ac
index 72ffb92..24c0dcd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,9 @@ AC_SYS_LARGEFILE
 dnl Enable GNU stuff.
 AC_USE_SYSTEM_EXTENSIONS
 
+dnl Which header file defines major, minor, makedev.
+AC_HEADER_MAJOR
+
 dnl Define the host CPU architecture (defines host_cpu).
 AC_CANONICAL_HOST
 
diff --git a/init/init.c b/init/init.c
index ef74332..e6fd0e6 100644
--- a/init/init.c
+++ b/init/init.c
@@ -40,7 +40,13 @@
 #include <sys/mount.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
+
+#if MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#elif MAJOR_IN_SYSMACROS
 #include <sys/sysmacros.h>
+/* else it's in sys/types.h, included above */
+#endif
 
 /* Maximum time to wait for the root device to appear (seconds).
  *
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 2abd246..9a0a802 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -33,6 +33,7 @@
 gl_LOCAL_DIR([])
 gl_MODULES([
   fts
+  sys_types
 ])
 gl_AVOID([])
 gl_SOURCE_BASE([lib])
diff --git a/src/ext2fs-c.c b/src/ext2fs-c.c
index 733c901..2743da7 100644
--- a/src/ext2fs-c.c
+++ b/src/ext2fs-c.c
@@ -32,7 +32,13 @@
 #include <errno.h>
 #include <assert.h>
 #include <inttypes.h>
+
+#if MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#elif MAJOR_IN_SYSMACROS
 #include <sys/sysmacros.h>
+/* else it's in sys/types.h, included above */
+#endif
 
 /* Inlining is broken in the ext2fs header file.  Disable it by
  * defining the following:
-- 
2.9.3




More information about the Libguestfs mailing list