* [PATCH] usr/gen_initramfs.sh: (cosmetic) improve comments and formatting
@ 2025-11-05 18:06 Jack Grube
2025-11-05 18:27 ` Grube, Jack
0 siblings, 1 reply; 3+ messages in thread
From: Jack Grube @ 2025-11-05 18:06 UTC (permalink / raw)
To: linux-kbuild@vger.kernel.org
This patch rewrites comments to be more descriptive and as complete sentences;
it also tweaks the usage function's output is also adjusted to make it more readable
when using the -h flag.
I ran the script with the -h option to verify that the usage output remains correct,
but no other testing was performed as no core logic was changed.
Lastly, I added an SPDX license identifier for any tools that may depend on that.
I welcome feedback there are any areas for improvement.
diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh
index 4490d496f374..7eba2fddf0ef 100755
--- a/usr/gen_initramfs.sh
+++ b/usr/gen_initramfs.sh
@@ -1,8 +1,8 @@
#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
# Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
-# Released under the terms of the GNU GPL.
+#
+# Released under the terms of the GNU GPL
#
# Generate a cpio packed initramfs. It uses gen_init_cpio to generate
# the cpio archive.
@@ -18,15 +18,15 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
-o <file> Create initramfs file named <file> by using gen_init_cpio
-l <dep_list> Create dependency list named <dep_list>
-u <uid> User ID to map to user ID 0 (root).
- <uid> is only meaningful if <cpio_source> is a
- directory. "squash" forces all files to uid 0.
+ <uid> is only meaningful if <cpio_source> is a
+ directory. "squash" forces all files to uid 0.
-g <gid> Group ID to map to group ID 0 (root).
- <gid> is only meaningful if <cpio_source> is a
- directory. "squash" forces all files to gid 0.
+ <gid> is only meaningful if <cpio_source> is a
+ directory. "squash" forces all files to gid 0.
-d <date> Use date for all file mtime values
<cpio_source> File list or directory for cpio archive.
- If <cpio_source> is a .cpio file it will be used
- as direct input to initramfs.
+ If <cpio_source> is a .cpio file it will be used
+ as direct input to initramfs.
All options except -o and -l may be repeated and are interpreted
sequentially and immediately. -u and -g states are preserved across
@@ -35,9 +35,8 @@ to reset the root/group mapping.
EOF
}
-
# awk style field access
-# $1 -- field number; the rest is the argument string.
+# $1 - field number; rest is argument string
field() {
shift $1 ; echo $1
}
@@ -45,7 +44,7 @@ field() {
filetype() {
local argv1="$1"
- # The symlink test must come before the file test.
+ # symlink test must come before file test
if [ -L "${argv1}" ]; then
echo "slink"
elif [ -f "${argv1}" ]; then
@@ -82,9 +81,9 @@ list_parse() {
echo "$1" | sed 's/:/\\:/g; s/$/ \\/' >> $dep_list
}
-# For each file, print a line in following format:
+# for each file print a line in following format
# <filetype> <name> <path to file> <octal mode> <uid> <gid>
-# For links, devices, etc., the format differs. See gen_init_cpio for details.
+# for links, devices etc the format differs. See gen_init_cpio for details
parse() {
local location="$1"
local name="/${location#${srcdir}}"
@@ -144,14 +143,14 @@ header() {
printf "\n#####################\n# $1\n" >> $cpio_list
}
-# Process one directory (including sub-directories).
+# process one directory (incl sub-directories)
dir_filelist() {
header "$1"
srcdir=$(echo "$1" | sed -e 's://*:/:g')
dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LC_ALL=C sort)
- # If $dirlist is only one line, then the directory is empty.
+ # If $dirlist is only one line, then the directory is empty
if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
print_mtime "$1"
@@ -180,7 +179,7 @@ input_file() {
done
fi
elif [ -d "$1" ]; then
- # If a directory is specified, then add all files in it to the file system.
+ # If a directory is specified then add all files in it to fs
dir_filelist "$1"
else
echo " ${prog}: Cannot open '$1'" >&2
@@ -203,26 +202,26 @@ while [ $# -gt 0 ]; do
arg="$1"
shift
case "$arg" in
- "-l") # files included in initramfs--used by kbuild
+ "-l") # files included in initramfs - used by kbuild
dep_list="$1"
echo "deps_initramfs := \\" > $dep_list
shift
;;
- "-o") # Generate a cpio image named $1.
+ "-o") # generate cpio image named $1
output="-o $1"
shift
;;
- "-u") # Map $1 to uid=0 (root).
+ "-u") # map $1 to uid=0 (root)
root_uid="$1"
[ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0)
shift
;;
- "-g") # Map $1 to gid=0 (root).
+ "-g") # map $1 to gid=0 (root)
root_gid="$1"
[ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
shift
;;
- "-d") # Date for file mtimes
+ "-d") # date for file mtimes
timestamp="$(date -d"$1" +%s || :)"
if test -n "$timestamp"; then
timestamp="-t $timestamp"
@@ -238,7 +237,7 @@ while [ $# -gt 0 ]; do
"-"*)
unknown_option
;;
- *) # input file/dir -- process it
+ *) # input file/dir - process it
input_file "$arg"
;;
esac
@@ -246,6 +245,6 @@ while [ $# -gt 0 ]; do
esac
done
-# If the output_file is set, we will generate cpio archive.
-# We are careful to delete tmp files.
+# If output_file is set we will generate cpio archive
+# we are careful to delete tmp files
usr/gen_init_cpio $output $timestamp $cpio_list
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usr/gen_initramfs.sh: (cosmetic) improve comments and formatting
2025-11-05 18:06 [PATCH] usr/gen_initramfs.sh: (cosmetic) improve comments and formatting Jack Grube
@ 2025-11-05 18:27 ` Grube, Jack
2025-12-09 13:07 ` Nicolas Schier
0 siblings, 1 reply; 3+ messages in thread
From: Grube, Jack @ 2025-11-05 18:27 UTC (permalink / raw)
To: linux-kbuild@vger.kernel.org
I heartily apologize for the double email. I got the order of
arguments mixed up when using git format-patch the first time. This is
the correct patch.
Signed-off-by: Jack Grube <jrg72@njit.edu>
---
usr/gen_initramfs.sh | 48 +++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh
index 7eba2fddf0ef..ff8ddd373fc1 100755
--- a/usr/gen_initramfs.sh
+++ b/usr/gen_initramfs.sh
@@ -1,8 +1,9 @@
#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
# Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
-#
-# Released under the terms of the GNU GPL
+
+# Released under the terms of the GNU GPL.
#
# Generate a cpio packed initramfs. It uses gen_init_cpio to generate
# the cpio archive.
@@ -18,15 +19,15 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g
<gid>] {-d | <cpio_source>} ...
-o <file> Create initramfs file named <file> by using gen_init_cpio
-l <dep_list> Create dependency list named <dep_list>
-u <uid> User ID to map to user ID 0 (root).
- <uid> is only meaningful if <cpio_source> is a
- directory. "squash" forces all files to uid 0.
+ <uid> is only meaningful if <cpio_source> is a
+ directory. "squash" forces all files to uid 0.
-g <gid> Group ID to map to group ID 0 (root).
- <gid> is only meaningful if <cpio_source> is a
- directory. "squash" forces all files to gid 0.
+ <gid> is only meaningful if <cpio_source> is a
+ directory. "squash" forces all files to gid 0.
-d <date> Use date for all file mtime values
<cpio_source> File list or directory for cpio archive.
- If <cpio_source> is a .cpio file it will be used
- as direct input to initramfs.
+ If <cpio_source> is a .cpio file it will be used
+ as direct input to initramfs.
All options except -o and -l may be repeated and are interpreted
sequentially and immediately. -u and -g states are preserved across
@@ -35,8 +36,9 @@ to reset the root/group mapping.
EOF
}
+
# awk style field access
-# $1 - field number; rest is argument string
+# $1 -- field number; the rest is the argument string.
field() {
shift $1 ; echo $1
}
@@ -44,7 +46,7 @@ field() {
filetype() {
local argv1="$1"
- # symlink test must come before file test
+ # The symlink test must come before the file test.
if [ -L "${argv1}" ]; then
echo "slink"
elif [ -f "${argv1}" ]; then
@@ -81,9 +83,9 @@ list_parse() {
echo "$1" | sed 's/:/\\:/g; s/$/ \\/' >> $dep_list
}
-# for each file print a line in following format
+# For each file, print a line in following format:
# <filetype> <name> <path to file> <octal mode> <uid> <gid>
-# for links, devices etc the format differs. See gen_init_cpio for details
+# For links, devices, etc., the format differs. See gen_init_cpio for details.
parse() {
local location="$1"
local name="/${location#${srcdir}}"
@@ -143,14 +145,14 @@ header() {
printf "\n#####################\n# $1\n" >> $cpio_list
}
-# process one directory (incl sub-directories)
+# Process one directory (including sub-directories).
dir_filelist() {
header "$1"
srcdir=$(echo "$1" | sed -e 's://*:/:g')
dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LC_ALL=C sort)
- # If $dirlist is only one line, then the directory is empty
+ # If $dirlist is only one line, then the directory is empty.
if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
print_mtime "$1"
@@ -179,7 +181,7 @@ input_file() {
done
fi
elif [ -d "$1" ]; then
- # If a directory is specified then add all files in it to fs
+ # If a directory is specified, then add all files in it to the
file system.
dir_filelist "$1"
else
echo " ${prog}: Cannot open '$1'" >&2
@@ -202,26 +204,26 @@ while [ $# -gt 0 ]; do
arg="$1"
shift
case "$arg" in
- "-l") # files included in initramfs - used by kbuild
+ "-l") # files included in initramfs--used by kbuild
dep_list="$1"
echo "deps_initramfs := \\" > $dep_list
shift
;;
- "-o") # generate cpio image named $1
+ "-o") # Generate a cpio image named $1.
output="-o $1"
shift
;;
- "-u") # map $1 to uid=0 (root)
+ "-u") # Map $1 to uid=0 (root).
root_uid="$1"
[ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0)
shift
;;
- "-g") # map $1 to gid=0 (root)
+ "-g") # Map $1 to gid=0 (root).
root_gid="$1"
[ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
shift
;;
- "-d") # date for file mtimes
+ "-d") # Date for file mtimes
timestamp="$(date -d"$1" +%s || :)"
if test -n "$timestamp"; then
timestamp="-t $timestamp"
@@ -237,7 +239,7 @@ while [ $# -gt 0 ]; do
"-"*)
unknown_option
;;
- *) # input file/dir - process it
+ *) # input file/dir -- process it
input_file "$arg"
;;
esac
@@ -245,6 +247,6 @@ while [ $# -gt 0 ]; do
esac
done
-# If output_file is set we will generate cpio archive
-# we are careful to delete tmp files
+# If the output_file is set, we will generate cpio archive.
+# We are careful to delete tmp files.
usr/gen_init_cpio $output $timestamp $cpio_list
--
Jack Grube
On Wed, Nov 5, 2025 at 1:06 PM Jack Grube <jrg72@njit.edu> wrote:
>
> This patch rewrites comments to be more descriptive and as complete sentences;
> it also tweaks the usage function's output is also adjusted to make it more readable
> when using the -h flag.
> I ran the script with the -h option to verify that the usage output remains correct,
> but no other testing was performed as no core logic was changed.
> Lastly, I added an SPDX license identifier for any tools that may depend on that.
> I welcome feedback there are any areas for improvement.
>
>
> diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh
> index 4490d496f374..7eba2fddf0ef 100755
> --- a/usr/gen_initramfs.sh
> +++ b/usr/gen_initramfs.sh
> @@ -1,8 +1,8 @@
> #!/bin/sh
> -# SPDX-License-Identifier: GPL-2.0-or-later
> # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
> # Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
> -# Released under the terms of the GNU GPL.
> +#
> +# Released under the terms of the GNU GPL
> #
> # Generate a cpio packed initramfs. It uses gen_init_cpio to generate
> # the cpio archive.
> @@ -18,15 +18,15 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
> -o <file> Create initramfs file named <file> by using gen_init_cpio
> -l <dep_list> Create dependency list named <dep_list>
> -u <uid> User ID to map to user ID 0 (root).
> - <uid> is only meaningful if <cpio_source> is a
> - directory. "squash" forces all files to uid 0.
> + <uid> is only meaningful if <cpio_source> is a
> + directory. "squash" forces all files to uid 0.
> -g <gid> Group ID to map to group ID 0 (root).
> - <gid> is only meaningful if <cpio_source> is a
> - directory. "squash" forces all files to gid 0.
> + <gid> is only meaningful if <cpio_source> is a
> + directory. "squash" forces all files to gid 0.
> -d <date> Use date for all file mtime values
> <cpio_source> File list or directory for cpio archive.
> - If <cpio_source> is a .cpio file it will be used
> - as direct input to initramfs.
> + If <cpio_source> is a .cpio file it will be used
> + as direct input to initramfs.
>
> All options except -o and -l may be repeated and are interpreted
> sequentially and immediately. -u and -g states are preserved across
> @@ -35,9 +35,8 @@ to reset the root/group mapping.
> EOF
> }
>
> -
> # awk style field access
> -# $1 -- field number; the rest is the argument string.
> +# $1 - field number; rest is argument string
> field() {
> shift $1 ; echo $1
> }
> @@ -45,7 +44,7 @@ field() {
> filetype() {
> local argv1="$1"
>
> - # The symlink test must come before the file test.
> + # symlink test must come before file test
> if [ -L "${argv1}" ]; then
> echo "slink"
> elif [ -f "${argv1}" ]; then
> @@ -82,9 +81,9 @@ list_parse() {
> echo "$1" | sed 's/:/\\:/g; s/$/ \\/' >> $dep_list
> }
>
> -# For each file, print a line in following format:
> +# for each file print a line in following format
> # <filetype> <name> <path to file> <octal mode> <uid> <gid>
> -# For links, devices, etc., the format differs. See gen_init_cpio for details.
> +# for links, devices etc the format differs. See gen_init_cpio for details
> parse() {
> local location="$1"
> local name="/${location#${srcdir}}"
> @@ -144,14 +143,14 @@ header() {
> printf "\n#####################\n# $1\n" >> $cpio_list
> }
>
> -# Process one directory (including sub-directories).
> +# process one directory (incl sub-directories)
> dir_filelist() {
> header "$1"
>
> srcdir=$(echo "$1" | sed -e 's://*:/:g')
> dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LC_ALL=C sort)
>
> - # If $dirlist is only one line, then the directory is empty.
> + # If $dirlist is only one line, then the directory is empty
> if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
> print_mtime "$1"
>
> @@ -180,7 +179,7 @@ input_file() {
> done
> fi
> elif [ -d "$1" ]; then
> - # If a directory is specified, then add all files in it to the file system.
> + # If a directory is specified then add all files in it to fs
> dir_filelist "$1"
> else
> echo " ${prog}: Cannot open '$1'" >&2
> @@ -203,26 +202,26 @@ while [ $# -gt 0 ]; do
> arg="$1"
> shift
> case "$arg" in
> - "-l") # files included in initramfs--used by kbuild
> + "-l") # files included in initramfs - used by kbuild
> dep_list="$1"
> echo "deps_initramfs := \\" > $dep_list
> shift
> ;;
> - "-o") # Generate a cpio image named $1.
> + "-o") # generate cpio image named $1
> output="-o $1"
> shift
> ;;
> - "-u") # Map $1 to uid=0 (root).
> + "-u") # map $1 to uid=0 (root)
> root_uid="$1"
> [ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0)
> shift
> ;;
> - "-g") # Map $1 to gid=0 (root).
> + "-g") # map $1 to gid=0 (root)
> root_gid="$1"
> [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
> shift
> ;;
> - "-d") # Date for file mtimes
> + "-d") # date for file mtimes
> timestamp="$(date -d"$1" +%s || :)"
> if test -n "$timestamp"; then
> timestamp="-t $timestamp"
> @@ -238,7 +237,7 @@ while [ $# -gt 0 ]; do
> "-"*)
> unknown_option
> ;;
> - *) # input file/dir -- process it
> + *) # input file/dir - process it
> input_file "$arg"
> ;;
> esac
> @@ -246,6 +245,6 @@ while [ $# -gt 0 ]; do
> esac
> done
>
> -# If the output_file is set, we will generate cpio archive.
> -# We are careful to delete tmp files.
> +# If output_file is set we will generate cpio archive
> +# we are careful to delete tmp files
> usr/gen_init_cpio $output $timestamp $cpio_list
>
--
Jack Grube
B.S. Computer Science, 2026.
Ying Wu College of Computing, NJIT.
Secretary — Newman Catholic Club, 2023–24; President 2024–26
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usr/gen_initramfs.sh: (cosmetic) improve comments and formatting
2025-11-05 18:27 ` Grube, Jack
@ 2025-12-09 13:07 ` Nicolas Schier
0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Schier @ 2025-12-09 13:07 UTC (permalink / raw)
To: Grube, Jack; +Cc: linux-kbuild@vger.kernel.org
Hi Jack,
On Wed, Nov 05, 2025 at 01:27:32PM -0500, Grube, Jack wrote:
> I heartily apologize for the double email. I got the order of
> arguments mixed up when using git format-patch the first time. This is
> the correct patch.
>
> Signed-off-by: Jack Grube <jrg72@njit.edu>
thanks for your contribution and sorry for the long delay. Common
practise of Linux patch submissions obeys several rules (cp. [1] and
other documents in that folder), for example:
* send logically independent changes as separate patches
(here for example: SPDX header; code indentation; re-formatting of
comments)
* describe the changes for each patch (what problem you want to fix,
why each patch is important and shall be applied).
[1]: Documentation/process/submitting-patches.rst
Iff you might send another patch (set), please make use of '--dry-run'
or similar options to check your patches prior to sending them out.
`scripts/get_maintainer.pl --email --no-rolestats` helps obtaining a
list of reasonable patch mail receipients.
> ---
> usr/gen_initramfs.sh | 48 +++++++++++++++++++++++---------------------
> 1 file changed, 25 insertions(+), 23 deletions(-)
>
> diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh
> index 7eba2fddf0ef..ff8ddd373fc1 100755
> --- a/usr/gen_initramfs.sh
> +++ b/usr/gen_initramfs.sh
> @@ -1,8 +1,9 @@
> #!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
Good catch. To my own surprise, there are even more files below usr/
that are missing SPDX headers.
Please put SPDX header addition into a separate patch.
> # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
> # Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
> -#
> -# Released under the terms of the GNU GPL
> +
> +# Released under the terms of the GNU GPL.
I don't think that this a relevant enhancement.
> #
> # Generate a cpio packed initramfs. It uses gen_init_cpio to generate
> # the cpio archive.
> @@ -18,15 +19,15 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g
> <gid>] {-d | <cpio_source>} ...
> -o <file> Create initramfs file named <file> by using gen_init_cpio
> -l <dep_list> Create dependency list named <dep_list>
> -u <uid> User ID to map to user ID 0 (root).
> - <uid> is only meaningful if <cpio_source> is a
> - directory. "squash" forces all files to uid 0.
> + <uid> is only meaningful if <cpio_source> is a
> + directory. "squash" forces all files to uid 0.
> -g <gid> Group ID to map to group ID 0 (root).
> - <gid> is only meaningful if <cpio_source> is a
> - directory. "squash" forces all files to gid 0.
> + <gid> is only meaningful if <cpio_source> is a
> + directory. "squash" forces all files to gid 0.
> -d <date> Use date for all file mtime values
> <cpio_source> File list or directory for cpio archive.
> - If <cpio_source> is a .cpio file it will be used
> - as direct input to initramfs.
> + If <cpio_source> is a .cpio file it will be used
> + as direct input to initramfs.
This patch is not applicable, did you generate it properly with 'git
format-patch' or something similar? usr/gen_initramfs.sh starts with
one or two tabs in these lines, your patch does not match that.
(And it seems to me, that your editor settings might be suboptimal for
kernel code; please use a tab size of 8 characters if you want to
optimise indenting.)
>
> All options except -o and -l may be repeated and are interpreted
> sequentially and immediately. -u and -g states are preserved across
> @@ -35,8 +36,9 @@ to reset the root/group mapping.
> EOF
> }
>
> +
Please do not add arbitrary empty lines.
> # awk style field access
> -# $1 - field number; rest is argument string
> +# $1 -- field number; the rest is the argument string.
While I think that most of your changes in the comments (this one and
the remaining) are correct, I am not convinced that it's worth the
effort.
Kind regards,
Nicolas
> field() {
> shift $1 ; echo $1
> }
> @@ -44,7 +46,7 @@ field() {
> filetype() {
> local argv1="$1"
>
> - # symlink test must come before file test
> + # The symlink test must come before the file test.
> if [ -L "${argv1}" ]; then
> echo "slink"
> elif [ -f "${argv1}" ]; then
> @@ -81,9 +83,9 @@ list_parse() {
> echo "$1" | sed 's/:/\\:/g; s/$/ \\/' >> $dep_list
> }
>
> -# for each file print a line in following format
> +# For each file, print a line in following format:
> # <filetype> <name> <path to file> <octal mode> <uid> <gid>
> -# for links, devices etc the format differs. See gen_init_cpio for details
> +# For links, devices, etc., the format differs. See gen_init_cpio for details.
> parse() {
> local location="$1"
> local name="/${location#${srcdir}}"
> @@ -143,14 +145,14 @@ header() {
> printf "\n#####################\n# $1\n" >> $cpio_list
> }
>
> -# process one directory (incl sub-directories)
> +# Process one directory (including sub-directories).
> dir_filelist() {
> header "$1"
>
> srcdir=$(echo "$1" | sed -e 's://*:/:g')
> dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LC_ALL=C sort)
>
> - # If $dirlist is only one line, then the directory is empty
> + # If $dirlist is only one line, then the directory is empty.
> if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
> print_mtime "$1"
>
> @@ -179,7 +181,7 @@ input_file() {
> done
> fi
> elif [ -d "$1" ]; then
> - # If a directory is specified then add all files in it to fs
> + # If a directory is specified, then add all files in it to the
> file system.
> dir_filelist "$1"
> else
> echo " ${prog}: Cannot open '$1'" >&2
> @@ -202,26 +204,26 @@ while [ $# -gt 0 ]; do
> arg="$1"
> shift
> case "$arg" in
> - "-l") # files included in initramfs - used by kbuild
> + "-l") # files included in initramfs--used by kbuild
> dep_list="$1"
> echo "deps_initramfs := \\" > $dep_list
> shift
> ;;
> - "-o") # generate cpio image named $1
> + "-o") # Generate a cpio image named $1.
> output="-o $1"
> shift
> ;;
> - "-u") # map $1 to uid=0 (root)
> + "-u") # Map $1 to uid=0 (root).
> root_uid="$1"
> [ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0)
> shift
> ;;
> - "-g") # map $1 to gid=0 (root)
> + "-g") # Map $1 to gid=0 (root).
> root_gid="$1"
> [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
> shift
> ;;
> - "-d") # date for file mtimes
> + "-d") # Date for file mtimes
> timestamp="$(date -d"$1" +%s || :)"
> if test -n "$timestamp"; then
> timestamp="-t $timestamp"
> @@ -237,7 +239,7 @@ while [ $# -gt 0 ]; do
> "-"*)
> unknown_option
> ;;
> - *) # input file/dir - process it
> + *) # input file/dir -- process it
> input_file "$arg"
> ;;
> esac
> @@ -245,6 +247,6 @@ while [ $# -gt 0 ]; do
> esac
> done
>
> -# If output_file is set we will generate cpio archive
> -# we are careful to delete tmp files
> +# If the output_file is set, we will generate cpio archive.
> +# We are careful to delete tmp files.
> usr/gen_init_cpio $output $timestamp $cpio_list
> --
> Jack Grube
>
>
> On Wed, Nov 5, 2025 at 1:06 PM Jack Grube <jrg72@njit.edu> wrote:
> >
> > This patch rewrites comments to be more descriptive and as complete sentences;
> > it also tweaks the usage function's output is also adjusted to make it more readable
> > when using the -h flag.
> > I ran the script with the -h option to verify that the usage output remains correct,
> > but no other testing was performed as no core logic was changed.
> > Lastly, I added an SPDX license identifier for any tools that may depend on that.
> > I welcome feedback there are any areas for improvement.
> >
> >
> > diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh
> > index 4490d496f374..7eba2fddf0ef 100755
> > --- a/usr/gen_initramfs.sh
> > +++ b/usr/gen_initramfs.sh
> > @@ -1,8 +1,8 @@
> > #!/bin/sh
> > -# SPDX-License-Identifier: GPL-2.0-or-later
> > # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
> > # Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
> > -# Released under the terms of the GNU GPL.
> > +#
> > +# Released under the terms of the GNU GPL
> > #
> > # Generate a cpio packed initramfs. It uses gen_init_cpio to generate
> > # the cpio archive.
> > @@ -18,15 +18,15 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
> > -o <file> Create initramfs file named <file> by using gen_init_cpio
> > -l <dep_list> Create dependency list named <dep_list>
> > -u <uid> User ID to map to user ID 0 (root).
> > - <uid> is only meaningful if <cpio_source> is a
> > - directory. "squash" forces all files to uid 0.
> > + <uid> is only meaningful if <cpio_source> is a
> > + directory. "squash" forces all files to uid 0.
> > -g <gid> Group ID to map to group ID 0 (root).
> > - <gid> is only meaningful if <cpio_source> is a
> > - directory. "squash" forces all files to gid 0.
> > + <gid> is only meaningful if <cpio_source> is a
> > + directory. "squash" forces all files to gid 0.
> > -d <date> Use date for all file mtime values
> > <cpio_source> File list or directory for cpio archive.
> > - If <cpio_source> is a .cpio file it will be used
> > - as direct input to initramfs.
> > + If <cpio_source> is a .cpio file it will be used
> > + as direct input to initramfs.
> >
> > All options except -o and -l may be repeated and are interpreted
> > sequentially and immediately. -u and -g states are preserved across
> > @@ -35,9 +35,8 @@ to reset the root/group mapping.
> > EOF
> > }
> >
> > -
> > # awk style field access
> > -# $1 -- field number; the rest is the argument string.
> > +# $1 - field number; rest is argument string
> > field() {
> > shift $1 ; echo $1
> > }
> > @@ -45,7 +44,7 @@ field() {
> > filetype() {
> > local argv1="$1"
> >
> > - # The symlink test must come before the file test.
> > + # symlink test must come before file test
> > if [ -L "${argv1}" ]; then
> > echo "slink"
> > elif [ -f "${argv1}" ]; then
> > @@ -82,9 +81,9 @@ list_parse() {
> > echo "$1" | sed 's/:/\\:/g; s/$/ \\/' >> $dep_list
> > }
> >
> > -# For each file, print a line in following format:
> > +# for each file print a line in following format
> > # <filetype> <name> <path to file> <octal mode> <uid> <gid>
> > -# For links, devices, etc., the format differs. See gen_init_cpio for details.
> > +# for links, devices etc the format differs. See gen_init_cpio for details
> > parse() {
> > local location="$1"
> > local name="/${location#${srcdir}}"
> > @@ -144,14 +143,14 @@ header() {
> > printf "\n#####################\n# $1\n" >> $cpio_list
> > }
> >
> > -# Process one directory (including sub-directories).
> > +# process one directory (incl sub-directories)
> > dir_filelist() {
> > header "$1"
> >
> > srcdir=$(echo "$1" | sed -e 's://*:/:g')
> > dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LC_ALL=C sort)
> >
> > - # If $dirlist is only one line, then the directory is empty.
> > + # If $dirlist is only one line, then the directory is empty
> > if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
> > print_mtime "$1"
> >
> > @@ -180,7 +179,7 @@ input_file() {
> > done
> > fi
> > elif [ -d "$1" ]; then
> > - # If a directory is specified, then add all files in it to the file system.
> > + # If a directory is specified then add all files in it to fs
> > dir_filelist "$1"
> > else
> > echo " ${prog}: Cannot open '$1'" >&2
> > @@ -203,26 +202,26 @@ while [ $# -gt 0 ]; do
> > arg="$1"
> > shift
> > case "$arg" in
> > - "-l") # files included in initramfs--used by kbuild
> > + "-l") # files included in initramfs - used by kbuild
> > dep_list="$1"
> > echo "deps_initramfs := \\" > $dep_list
> > shift
> > ;;
> > - "-o") # Generate a cpio image named $1.
> > + "-o") # generate cpio image named $1
> > output="-o $1"
> > shift
> > ;;
> > - "-u") # Map $1 to uid=0 (root).
> > + "-u") # map $1 to uid=0 (root)
> > root_uid="$1"
> > [ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0)
> > shift
> > ;;
> > - "-g") # Map $1 to gid=0 (root).
> > + "-g") # map $1 to gid=0 (root)
> > root_gid="$1"
> > [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
> > shift
> > ;;
> > - "-d") # Date for file mtimes
> > + "-d") # date for file mtimes
> > timestamp="$(date -d"$1" +%s || :)"
> > if test -n "$timestamp"; then
> > timestamp="-t $timestamp"
> > @@ -238,7 +237,7 @@ while [ $# -gt 0 ]; do
> > "-"*)
> > unknown_option
> > ;;
> > - *) # input file/dir -- process it
> > + *) # input file/dir - process it
> > input_file "$arg"
> > ;;
> > esac
> > @@ -246,6 +245,6 @@ while [ $# -gt 0 ]; do
> > esac
> > done
> >
> > -# If the output_file is set, we will generate cpio archive.
> > -# We are careful to delete tmp files.
> > +# If output_file is set we will generate cpio archive
> > +# we are careful to delete tmp files
> > usr/gen_init_cpio $output $timestamp $cpio_list
> >
>
>
> --
> Jack Grube
> B.S. Computer Science, 2026.
> Ying Wu College of Computing, NJIT.
> Secretary — Newman Catholic Club, 2023–24; President 2024–26
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-09 13:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 18:06 [PATCH] usr/gen_initramfs.sh: (cosmetic) improve comments and formatting Jack Grube
2025-11-05 18:27 ` Grube, Jack
2025-12-09 13:07 ` Nicolas Schier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox