From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1m43Ot-0006kW-DB for mharc-grub-devel@gnu.org; Thu, 15 Jul 2021 11:35:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m43Os-0006if-HS for grub-devel@gnu.org; Thu, 15 Jul 2021 11:35:46 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:47258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m43Om-00084v-0P for grub-devel@gnu.org; Thu, 15 Jul 2021 11:35:46 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6318922A32; Thu, 15 Jul 2021 15:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1626363336; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rWCkUxR/gOiHV1Qg8U/P9rxniqGbXpAyPhdlAvKU8oY=; b=TxSJMEogMDVrhughcHzxcdMe+6uER4+vJr/vaPu4I+SSWZeQ+3e/HwuhgD+B0VhLPPHFxB n7eDbo7Zd1tMMl3bcvxrspWFlEkrEq5IQrCO1rp/rdR2F6iFX1Qg028QwutCpq50pMU7q6 gb0pS5qVZCyvDlIDtXmT2xnltKhMu6A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1626363336; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rWCkUxR/gOiHV1Qg8U/P9rxniqGbXpAyPhdlAvKU8oY=; b=dJoWopOxoNqReGXSNjSN6KxZ8+QOuoijNc0P6ML6tXBlasboG1N4pVXY21KbCRhrDxvE/n MU+1NhBepsCkhpCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1E1AE13C3B; Thu, 15 Jul 2021 15:35:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0H7dBchV8GA+dQAAMHmgww (envelope-from ); Thu, 15 Jul 2021 15:35:36 +0000 From: Petr Vorel To: grub-devel@gnu.org Cc: Petr Vorel , Daniel Kiper , Michael Chang , Mike Gilbert , Jeff Mahoney Subject: [PATCH v2 1/2] osdep: Introduce major.h and use it Date: Thu, 15 Jul 2021 17:35:27 +0200 Message-Id: <20210715153528.16233-2-pvorel@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715153528.16233-1-pvorel@suse.cz> References: <20210715153528.16233-1-pvorel@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=195.135.220.28; envelope-from=pvorel@suse.cz; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2021 15:35:46 -0000 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 --- changes v1->v2: * improve comment in major.h * adjust comment in configure.ac * improve commit message configure.ac | 2 +- grub-core/osdep/devmapper/getroot.c | 7 +------ grub-core/osdep/devmapper/hostdisk.c | 7 +------ grub-core/osdep/linux/getroot.c | 7 +------ grub-core/osdep/unix/getroot.c | 7 +------ include/grub/osdep/major.h | 30 ++++++++++++++++++++++++++++ 6 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 include/grub/osdep/major.h diff --git a/configure.ac b/configure.ac index b025e1e84..09ba4ba2b 100644 --- a/configure.ac +++ b/configure.ac @@ -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 major.h. SAVED_CFLAGS="$CFLAGS" CFLAGS="$HOST_CFLAGS -Werror" AC_HEADER_MAJOR diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index a13a39c96..9ba5c9865 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -40,12 +40,7 @@ #include #endif -#if defined(MAJOR_IN_MKDEV) -#include -#elif defined(MAJOR_IN_SYSMACROS) -#include -#endif - +#include #include #include diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devmapper/hostdisk.c index a8afc0c94..c8053728b 100644 --- a/grub-core/osdep/devmapper/hostdisk.c +++ b/grub-core/osdep/devmapper/hostdisk.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -24,12 +25,6 @@ #include #include -#if defined(MAJOR_IN_MKDEV) -#include -#elif defined(MAJOR_IN_SYSMACROS) -#include -#endif - #ifdef HAVE_DEVICE_MAPPER # include diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index 001b818fe..cd588588e 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -35,12 +35,7 @@ #include #endif -#if defined(MAJOR_IN_MKDEV) -#include -#elif defined(MAJOR_IN_SYSMACROS) -#include -#endif - +#include #include #include /* ioctl */ #include diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index 46d7116c6..74f69116d 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -51,12 +51,7 @@ #endif /* ! FLOPPY_MAJOR */ #endif -#include -#if defined(MAJOR_IN_MKDEV) -#include -#elif defined(MAJOR_IN_SYSMACROS) -#include -#endif +#include #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) # include diff --git a/include/grub/osdep/major.h b/include/grub/osdep/major.h new file mode 100644 index 000000000..cb468351d --- /dev/null +++ b/include/grub/osdep/major.h @@ -0,0 +1,30 @@ +/* + * 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 . + */ + +/* + * Fix for glibc 2.25 which is deprecating the namespace pollution of + * sys/types.h injecting major(), minor(), and makedev() into the compilation + * environment. +*/ + +#include +#ifdef MAJOR_IN_MKDEV +# include +#elif defined(MAJOR_IN_SYSMACROS) +# include +#endif -- 2.32.0