[Buildroot] [PATCH] mmc-utils: allow enabling of "dangerous commands"

Markus Mayer mmayer at broadcom.com
Fri Oct 14 00:50:55 UTC 2022


Provide a config option that allows the user to enable mmc's "dangerous
commands" if so desired. mmc-utils considers turning on permanent write
protection on a device a "dangerous command" and doesn't offer it by
default.

Signed-off-by: Markus Mayer <mmayer at broadcom.com>
---
 package/mmc-utils/Config.in    | 8 ++++++++
 package/mmc-utils/mmc-utils.mk | 9 ++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/package/mmc-utils/Config.in b/package/mmc-utils/Config.in
index 850aeac44571..0283658a7a57 100644
--- a/package/mmc-utils/Config.in
+++ b/package/mmc-utils/Config.in
@@ -8,3 +8,11 @@ config BR2_PACKAGE_MMC_UTILS
 
 comment "mmc-utils needs a toolchain w/ headers >= 3.0"
 	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0
+
+config BR2_PACKAGE_MMC_UTILS_ENABLE_DANGEROUS_COMMANDS
+	bool "Enable dangerous commands"
+	depends on BR2_PACKAGE_MMC_UTILS
+	help
+	   Enable support for dangerous commands in mmc-utils. mmc-utils
+	   considers turning on permanent write protection on a device a
+	   "dangerous command" and doesn't offer it by default.
diff --git a/package/mmc-utils/mmc-utils.mk b/package/mmc-utils/mmc-utils.mk
index c84737869264..a176cb94ae43 100644
--- a/package/mmc-utils/mmc-utils.mk
+++ b/package/mmc-utils/mmc-utils.mk
@@ -10,12 +10,19 @@ MMC_UTILS_SITE_METHOD = git
 MMC_UTILS_LICENSE = GPL-2.0
 MMC_UTILS_LICENSE_FILES = mmc.h
 
+MMC_UTILS_CFLAGS = $(TARGET_CFLAGS)
+
+ifeq ($(BR2_PACKAGE_MMC_UTILS_ENABLE_DANGEROUS_COMMANDS),y)
+MMC_UTILS_CFLAGS += -DDANGEROUS_COMMANDS_ENABLED
+endif
+
 # override AM_CFLAGS as the project Makefile uses it to pass
 # -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2, and the latter conflicts
 # with the _FORTIFY_SOURCE that we pass when hardening options are
 # enabled.
 define MMC_UTILS_BUILD_CMDS
-	$(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) AM_CFLAGS=
+	$(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) CFLAGS=$(MMC_UTILS_CFLAGS) \
+		AM_CFLAGS=
 endef
 
 define MMC_UTILS_INSTALL_TARGET_CMDS
-- 
2.34.1




More information about the buildroot mailing list