[PATCH openbmc v6 07/18] initfs: update: Don't exec sh or sulogin on error just exit 1
Andrew Jeffery
andrew at aj.id.au
Thu Jun 23 14:58:05 AEST 2016
On Wed, 2016-06-22 at 19:30 -0500, OpenBMC Patches wrote:
> From: "Milton D. Miller II" <miltonm at us.ibm.com>
>
> When update was written it was exec'd from the shutdown script
> and hence took over pid 1. Since exiting in that environment was
> a panic situation, the script instead started a rescue shell with
> its output presumably on the console.
>
> The calling convention was updated to be a simple invocation in
> commit dbacf104885c ("obmc-initfs: run update as a sub-script")
> but the error handling was not updated. That error handling is
> now becoming a hinderance
hindrance
> to use from additional environments so
> change it.
>
> Signed-off-by: Milton Miller <miltonm at us.ibm.com>
> ---
> .../obmc-phosphor-initfs/files/obmc-update.sh | 23 ++++++----------------
> 1 file changed, 6 insertions(+), 17 deletions(-)
>
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> index aa8fd89..f8e551c 100755
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> @@ -2,9 +2,6 @@
>
> echo update: "$@"
>
> -export PS1=update-sh#\
> -# exec /bin/sh
> -
> cd /
> if ! test -r /proc/mounts || ! test -f /proc/mounts
> then
> @@ -21,12 +18,12 @@ then
> mkdir -p /dev
> mount -t devtmpfs dev dev
> fi
> -while grep mtd /proc/mounts
> -do
> +
> +if grep mtd /proc/mounts
> +then
> echo 1>&2 "Error: A mtd device is mounted."
> - sulogin
> - # exec /bin/sh
> -done
> + exit 1
> +fi
>
> findmtd() {
> m=$(grep -xl "$1" /sys/class/mtd/*/name)
> @@ -130,7 +127,7 @@ do
> if test -z "$m"
> then
> echo 1>&2 "Unable to find mtd partiton for ${f##*/}."
> - exec /bin/sh
> + exit 1
Is there any value differentiating between the failure cases? I.e.
could we `exit 2` here instead?
It is just a thought and I am not overly fussed by it.
> fi
> done
>
> @@ -173,11 +170,3 @@ then
> fi
>
> exit
> -
> -# NOT REACHED without edit
> -# NOT REACHED without edit
> -
> -echo "Flash completed. Inspect, cleanup and reboot -f to continue."
> -
> -export PS1=update-sh#\
> -exec /bin/sh
Reviewed-by: Andrew Jeffery <andrew at aj.id.au>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160623/2f5c5e56/attachment-0001.sig>
More information about the openbmc
mailing list