]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
osdep: Introduce include/grub/osdep/major.h and use it
authorPetr Vorel <pvorel@suse.cz>
Thu, 15 Jul 2021 15:35:27 +0000 (17:35 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 22 Jul 2021 13:54:15 +0000 (15:54 +0200)
... to factor out fix for glibc 2.25 introduced in 7a5b301e3 (build: Use
AC_HEADER_MAJOR to find device macros).

Note: Once glibc 2.25 is old enough and this fix is not needed also
AC_HEADER_MAJOR in configure.ac should be removed.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
configure.ac
grub-core/osdep/devmapper/getroot.c
grub-core/osdep/devmapper/hostdisk.c
grub-core/osdep/linux/getroot.c
grub-core/osdep/unix/getroot.c
include/grub/osdep/major.h [new file with mode: 0644]

index b025e1e84cfb92939cb68170851c8790939f632a..bee28dbebf10f18de07e59e60f7673f992bcd36b 100644 (file)
@@ -424,7 +424,7 @@ AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
 
 # glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation
 # warning which causes compilation failure later with -Werror. So use -Werror here
-# as well to force proper sys/sysmacros.h detection.
+# as well to force proper sys/sysmacros.h detection. Used in include/grub/osdep/major.h.
 SAVED_CFLAGS="$CFLAGS"
 CFLAGS="$HOST_CFLAGS -Werror"
 AC_HEADER_MAJOR
index a13a39c96c6766559fd2990e69d7e78bdf5bfeed..9ba5c9865559794124ed6f9c5b97116d9d6962a5 100644 (file)
 #include <limits.h>
 #endif
 
-#if defined(MAJOR_IN_MKDEV)
-#include <sys/mkdev.h>
-#elif defined(MAJOR_IN_SYSMACROS)
-#include <sys/sysmacros.h>
-#endif
-
+#include <grub/osdep/major.h>
 #include <libdevmapper.h>
 
 #include <grub/types.h>
index a8afc0c9408d0ae8b8811054e4ed53d1c9852a6d..c8053728b0a35f02f03f346ef5d13f949b6f2961 100644 (file)
@@ -11,6 +11,7 @@
 #include <grub/misc.h>
 #include <grub/i18n.h>
 #include <grub/list.h>
+#include <grub/osdep/major.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <limits.h>
 
-#if defined(MAJOR_IN_MKDEV)
-#include <sys/mkdev.h>
-#elif defined(MAJOR_IN_SYSMACROS)
-#include <sys/sysmacros.h>
-#endif
-
 #ifdef HAVE_DEVICE_MAPPER
 # include <libdevmapper.h>
 
index 001b818fe581da2b5eecbdb2025cef316e3ff1ae..cd588588eecf28194ee6ef2a08fd6013753e5f53 100644 (file)
 #include <limits.h>
 #endif
 
-#if defined(MAJOR_IN_MKDEV)
-#include <sys/mkdev.h>
-#elif defined(MAJOR_IN_SYSMACROS)
-#include <sys/sysmacros.h>
-#endif
-
+#include <grub/osdep/major.h>
 #include <grub/types.h>
 #include <sys/ioctl.h>         /* ioctl */
 #include <sys/mount.h>
index 46d7116c6e660dc9c47df5f5c004715de26fe1bb..74f69116dbdd3266b3e4b1da5455ec2e54080bb7 100644 (file)
 #endif /* ! FLOPPY_MAJOR */
 #endif
 
-#include <sys/types.h>
-#if defined(MAJOR_IN_MKDEV)
-#include <sys/mkdev.h>
-#elif defined(MAJOR_IN_SYSMACROS)
-#include <sys/sysmacros.h>
-#endif
+#include <grub/osdep/major.h>
 
 #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
 # include <grub/util/libzfs.h>
diff --git a/include/grub/osdep/major.h b/include/grub/osdep/major.h
new file mode 100644 (file)
index 0000000..84a9159
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2021  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *  Fix for glibc 2.25 which is deprecating the namespace pollution of
+ *  sys/types.h injecting major(), minor(), and makedev() into the
+ *  compilation environment.
+ */
+
+#ifndef GRUB_OSDEP_MAJOR_H
+#define GRUB_OSDEP_MAJOR_H     1
+
+#include <sys/types.h>
+
+#ifdef MAJOR_IN_MKDEV
+# include <sys/mkdev.h>
+#elif defined (MAJOR_IN_SYSMACROS)
+# include <sys/sysmacros.h>
+#endif
+#endif /* GRUB_OSDEP_MAJOR_H */