All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Vivek Goyal <vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH 1/3] Add an exception handle check function
Date: Fri, 21 Dec 2012 17:30:04 +0800	[thread overview]
Message-ID: <50D42C1C.7060508@redhat.com> (raw)
In-Reply-To: <76d7b2f339455dcea6a2827b004bfcd9c6fa2315.1356080083.git.bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Sorry, cc Vivek and Dave.


On 12/21/2012 04:55 PM, Baoquan He wrote:
> In some cases, exception happened, default handling is called. However,
> user may not like the handling, want to specify a handler for these
> exceptions.
>
> Add an exception handle check function. Call it where exceptions happened,
> and specify a extra special handler. If user want the special handler handles
> this exception, related cmdline is added.
>
> Then Dracut will check the cmdline, if related cmdline exists, call the
> specified handler; if not, call the default handler.
>
> The function can be called like below:
> exception_handle_check -h continue_on_fail
>
> Signed-off-by: Baoquan He<bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>   modules.d/99base/dracut-lib.sh |   40 ++++++++++++++++++++++++++++++++++++++++
>   1 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
> index cc6c7e8..35ed3a3 100755
> --- a/modules.d/99base/dracut-lib.sh
> +++ b/modules.d/99base/dracut-lib.sh
> @@ -938,6 +938,46 @@ emergency_shell()
>       [ -e /run/initramfs/.die ]&&  exit 1
>   }
>
> +exception_handle_check()
> +{
> +    local action_wanted
> +    if [ "$1" = "-h" ]; then
> +        [ $# -le 1 ]&&  echo "No exception handler specified"&&  emergency_shell
> +        action_wanted=$2;
> +        case "$action_wanted" in
> +        continue_on_fail)
> +            ;;
> +        reboot)
> +            ;;
> +        emergency_shell)
> +            ;;
> +        *)
> +            echo "Wrong exception handler input: $action_wanted"
> +            action_wanted=emergency_shell
> +        esac
> +    else
> +        action_wanted=emergency_shell
> +    fi
> +
> +    case "$action_wanted" in
> +    continue_on_fail)
> +        action=$(getarg rd.exceptionhandler=)
> +        [ -z "$action" -o  "$action" != "continue_on_fail" ]&&  emergency_shell
> +        ;;
> +    emergency_shell)
> +        emergency_shell
> +        ;;
> +    reboot)
> +        reboot -f
> +        ;;
> +    *) #default
> +        ##impossible come here
> +        ;;
> +    esac
> +
> +    return 0
> +}
> +
>   # Retain the values of these variables but ensure that they are unexported
>   # This is a POSIX-compliant equivalent of bash's "export -n"
>   export_n()

  parent reply	other threads:[~2012-12-21  9:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21  8:55 [PATCH 1/3] Add an exception handle check function Baoquan He
     [not found] ` <76d7b2f339455dcea6a2827b004bfcd9c6fa2315.1356080083.git.bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-12-21  8:55   ` [PATCH 2/3] Specify a special handler when initqueue timeout Baoquan He
2012-12-21  8:55   ` [PATCH 3/3] Add a special handler when mount rootfs failed Baoquan He
     [not found]     ` <d98a268350d0f13f6dd4d464a1a21517668eeb57.1356080083.git.bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-12-31  8:12       ` Baoquan
2012-12-21  9:30   ` Baoquan [this message]
2013-01-15  7:22   ` [PATCH 1/3] Add an exception handle check function Baoquan
2013-01-17 10:03   ` Dave Young
     [not found]     ` <50F7CC85.5060303-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-01-18  2:06       ` Dave Young
2013-01-24  3:12       ` Baoquan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50D42C1C.7060508@redhat.com \
    --to=bhe-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.