help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] examples/loadables/finfo: correctly include sys/sysmacros.h


From: Eli Schwartz
Subject: [PATCH v2] examples/loadables/finfo: correctly include sys/sysmacros.h
Date: Mon, 4 Nov 2019 15:09:21 -0500

Many projects historically relied on including this via sys/types.h, but
this was deprecated by glibc 2.25 and dropped fully in glibc 2.28:
https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html

Add autoconf check for the location of major/minor/makedev, and add
defines to include the correct header if it is detected outside of
sys/types.h
---

v2: add missing bits from config.h.in

 config.h.in                | 6 ++++++
 configure.ac               | 1 +
 examples/loadables/finfo.c | 6 ++++++
 3 files changed, 13 insertions(+)

diff --git a/config.h.in b/config.h.in
index 92633057..22e1c061 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1086,6 +1086,12 @@
 /* Define if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
+/* Define if major/minor/makedev is defined in <sys/mkdev.h> */
+#undef MAJOR_IN_MKDEV
+
+/* Define if major/minor/makedev is defined in <sys/sysmacros.h> */
+#undef MAJOR_IN_SYSMACROS
+
 /* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
 #undef HAVE_SYS_WAIT_H
 
diff --git a/configure.ac b/configure.ac
index cf5d1ed5..1b26587a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -743,6 +743,7 @@ AM_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl])
 dnl header files
 AC_HEADER_DIRENT
 AC_HEADER_TIME
+AC_HEADER_MAJOR
 
 BASH_HEADER_INTTYPES
 
diff --git a/examples/loadables/finfo.c b/examples/loadables/finfo.c
index 4273aa59..323ecac4 100644
--- a/examples/loadables/finfo.c
+++ b/examples/loadables/finfo.c
@@ -28,6 +28,12 @@
 #endif
 
 #include <sys/types.h>
+#ifdef MAJOR_IN_MKDEV
+#    include <sys/mkdev.h>
+#endif
+#ifdef MAJOR_IN_SYSMACROS
+#    include <sys/sysmacros.h>
+#endif
 #include "posixstat.h"
 #include <stdio.h>
 #include <pwd.h>
-- 
2.23.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]