[v2,4/7] cmdline: Add capability to prepend the command line
diff mbox series

Message ID e1a498d02d47ec2420b404bd5f3e4a00fc628532.1614705851.git.christophe.leroy@csgroup.eu
State New, archived
Headers show
Series
  • Improve boot command line handling
Related show

Commit Message

Christophe Leroy March 2, 2021, 5:25 p.m. UTC
This patchs adds an option of prepend a text to the command
line instead of appending it.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 include/linux/cmdline.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Will Deacon March 3, 2021, 6:19 p.m. UTC | #1
On Tue, Mar 02, 2021 at 05:25:20PM +0000, Christophe Leroy wrote:
> This patchs adds an option of prepend a text to the command
> line instead of appending it.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  include/linux/cmdline.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
> index ae3610bb0ee2..144346051e01 100644
> --- a/include/linux/cmdline.h
> +++ b/include/linux/cmdline.h
> @@ -31,7 +31,7 @@ static __always_inline size_t cmdline_strlcat(char *dest, const char *src, size_
>  }
>  
>  /*
> - * This function will append a builtin command line to the command
> + * This function will append or prepend a builtin command line to the command
>   * line provided by the bootloader. Kconfig options can be used to alter
>   * the behavior of this builtin command line.
>   * @dest: The destination of the final appended/prepended string.
> @@ -50,6 +50,9 @@ static __always_inline void cmdline_build(char *dest, const char *src, size_t le
>  		cmdline_strlcat(dest, CONFIG_CMDLINE, length);
>  		return;
>  	}
> +
> +	if (IS_ENABLED(CONFIG_CMDLINE_PREPEND) && sizeof(CONFIG_CMDLINE) > 1)
> +		cmdline_strlcat(dest, CONFIG_CMDLINE " ", length);

Same comment as the other patch: I don't think we need to worry about the
sizeof() here.

Will

Patch
diff mbox series

diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
index ae3610bb0ee2..144346051e01 100644
--- a/include/linux/cmdline.h
+++ b/include/linux/cmdline.h
@@ -31,7 +31,7 @@  static __always_inline size_t cmdline_strlcat(char *dest, const char *src, size_
 }
 
 /*
- * This function will append a builtin command line to the command
+ * This function will append or prepend a builtin command line to the command
  * line provided by the bootloader. Kconfig options can be used to alter
  * the behavior of this builtin command line.
  * @dest: The destination of the final appended/prepended string.
@@ -50,6 +50,9 @@  static __always_inline void cmdline_build(char *dest, const char *src, size_t le
 		cmdline_strlcat(dest, CONFIG_CMDLINE, length);
 		return;
 	}
+
+	if (IS_ENABLED(CONFIG_CMDLINE_PREPEND) && sizeof(CONFIG_CMDLINE) > 1)
+		cmdline_strlcat(dest, CONFIG_CMDLINE " ", length);
 #endif
 	if (dest != src)
 		cmdline_strlcat(dest, src, length);