Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2687370pxf; Sun, 4 Apr 2021 10:21:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIQD89YdDm6rv7sXolceTLdr6GTIB1OIuBURLQ861Ug0sN3WJDI3c/iJP7uavrLk1uyKTJ X-Received: by 2002:a6b:bf07:: with SMTP id p7mr17442246iof.15.1617556903587; Sun, 04 Apr 2021 10:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617556903; cv=none; d=google.com; s=arc-20160816; b=sDaJENsJeck0VI4Ma2+kewwMUpPsudwo6roRCHqTl78CbmdYv4x19sXiAGygpnhuH4 w4q0wbDms9fAoked+hsmbVvV7x1ecgMvZXLmxX5W3RwEzDyxdCcdT+ZJw5wf3hz5I+rk 0efH4ImJyoQZs8NzIVc1+Jl+PdaPRCjcDs1boAxAVF3QQOci3e2PDDae2LR1O0NX9oYy EeXrV/qZGq17deCCCq/Esu9PsKwp6LzIPAkjW2hzt8I9CSLDN0Cqro/gpPENKMdMUUtI CgGi7yMjB4hmuUjlqAQ3EqCJ22em+IWjjk1uaF4oktJr0eZnPeoaytYZEJU7kqh/sPKh CMGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=TUW0XhZnXbTk4uQmFclkOPLQObOfO2q63iwflzaP8Nw=; b=XUrWbnZs4cSUk7zSyZzWpOz9XCgwDaCX22C7Vg32BD1+9MYMurZ2XknMqotKeYed9T aSRb4ujkhhJSw7DluuUBDDf9ET8LtvZ0y5Ljl65uOhJPJBk4Ob0vQiXxRAro7TmC/dC4 6pv9XByubcUOSLjiDyggGtCtQQzsJd88JwL6BPKQPdVCGbCEDgbt/yfMnnoaJ0GZNVPc sg16ekIg3KC4Irp21A+T/DbomsCN026Gxmfw5hOoG1HvILKLLQvJqxnUh6ea6U7ULtBZ lPow1S9BooRuxuH45fXVni3flN+NY6V/9LdHtC3Eabr4+S3p97ZM4w1lJngt7nCmdiau DuWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si3484741ila.29.2021.04.04.10.21.30; Sun, 04 Apr 2021 10:21:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231289AbhDDRU5 (ORCPT + 99 others); Sun, 4 Apr 2021 13:20:57 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:63707 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbhDDRU4 (ORCPT ); Sun, 4 Apr 2021 13:20:56 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4FD0tP1t4vz9tymG; Sun, 4 Apr 2021 19:20:45 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id ffq992l6CBkv; Sun, 4 Apr 2021 19:20:45 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4FD0tP0d2fz9tymF; Sun, 4 Apr 2021 19:20:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9F2F08B78E; Sun, 4 Apr 2021 19:20:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id b-KtXSnASDF0; Sun, 4 Apr 2021 19:20:48 +0200 (CEST) Received: from po16121vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4454D8B76A; Sun, 4 Apr 2021 19:20:48 +0200 (CEST) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 06D3A67685; Sun, 4 Apr 2021 17:20:48 +0000 (UTC) Message-Id: <34d20d1dbb88f26d418b33985557b0475374a1a5.1617556785.git.christophe.leroy@csgroup.eu> From: Christophe Leroy Subject: [RFC PATCH v6 1/1] cmdline: Add capability to both append and prepend at the same time To: will@kernel.org, danielwa@cisco.com, robh@kernel.org, daniel@gimpelevich.san-francisco.ca.us, arnd@kernel.org, akpm@linux-foundation.org Cc: linux-arch@vger.kernel.org, devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, microblaze , linux-mips@vger.kernel.org, nios2 , openrisc@lists.librecores.org, linux-hexagon@vger.kernel.org, linux-riscv@lists.infradead.org, x86@kernel.org, linux-xtensa@linux-xtensa.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org Date: Sun, 4 Apr 2021 17:20:48 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org One user has expressed the need to both append and prepend some built-in parameters to the command line provided by the bootloader. Allthough it is a corner case, it is easy to implement so let's do it. When the user chooses to prepend the bootloader provided command line with the built-in command line, he is offered the possibility to enter an additionnal built-in command line to be appended after the bootloader provided command line. It is a complementary feature which has no impact on the already existing ones and/or the existing defconfig. Suggested-by: Daniel Walker Signed-off-by: Christophe Leroy --- Sending this out as an RFC, applies on top of the series ("Implement GENERIC_CMDLINE"). I will add it to the series next spin unless someone is against it. --- include/linux/cmdline.h | 3 +++ init/Kconfig | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h index 020028e2bdf0..fb274a4d5519 100644 --- a/include/linux/cmdline.h +++ b/include/linux/cmdline.h @@ -36,6 +36,9 @@ static __always_inline bool __cmdline_build(char *dst, const char *src) len = cmdline_strlcat(dst, src, COMMAND_LINE_SIZE); + if (IS_ENABLED(CONFIG_CMDLINE_PREPEND)) + len = cmdline_strlcat(dst, " " CONFIG_CMDLINE_MORE, COMMAND_LINE_SIZE); + if (IS_ENABLED(CONFIG_CMDLINE_APPEND)) len = cmdline_strlcat(dst, " " CONFIG_CMDLINE, COMMAND_LINE_SIZE); diff --git a/init/Kconfig b/init/Kconfig index fa002e3765ab..cd3087ff4f28 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -128,6 +128,14 @@ config CMDLINE If this string is not empty, additional choices are proposed below to determine how it will be used by the kernel. +config CMDLINE_MORE + string "Additional default kernel command string" if GENERIC_CMDLINE && CMDLINE_PREPEND + default "" + help + Defines an additional default kernel command string. + If this string is not empty, it is appended to the + command-line arguments provided by the bootloader + choice prompt "Kernel command line type" if CMDLINE != "" default CMDLINE_PREPEND if ARCH_WANT_CMDLINE_PREPEND_BY_DEFAULT @@ -154,7 +162,9 @@ config CMDLINE_PREPEND bool "Prepend to the bootloader kernel arguments" help The default kernel command string will be prepended to the - command-line arguments provided by the bootloader. + command-line arguments provided by the bootloader. When this + option is selected, another string can be added which will + be appended. config CMDLINE_FORCE bool "Always use the default kernel command string" -- 2.25.0