All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH] split emergency_shell function
Date: Wed, 01 Aug 2012 14:42:36 +0200	[thread overview]
Message-ID: <5019243C.40308@redhat.com> (raw)
In-Reply-To: <20120801100751.GA13552-je1gSBvt1Td3da3rpXeqgR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>

pushed

Am 01.08.2012 12:07, schrieb Dave Young:
> 
> Kdump dracut hooks need to enter emergency shell, currently it directly call
> "sh -i -l", with recent dracut this does not work anymore without proper ctty.
> 
> It will be convinient to seperate a standalone function _emergency_shell for
> dracut modules to call.
> 
> ---
>  modules.d/99base/dracut-lib.sh |   58 ++++++++++++++++++++++-------------------
>  1 file changed, 32 insertions(+), 26 deletions(-)
> 
> --- dracut.orig/modules.d/99base/dracut-lib.sh
> +++ dracut/modules.d/99base/dracut-lib.sh
> @@ -864,6 +864,37 @@ wait_for_loginit()
>      rm -f /run/initramfs/loginit.pipe /run/initramfs/loginit.pid
>  }
>  
> +_emergency_shell()
> +{
> +    local _name="$1"
> +    if [ -x /lib/systemd/systemd ]; then
> +        > /.console_lock
> +        echo "PS1=\"$_name:\${PWD}# \"" >/etc/profile
> +        systemctl start emergency.service
> +        debug_off
> +        while [ -e /.console_lock ]; do sleep 1; done
> +        debug_on
> +    else
> +        echo "Dropping to debug shell."
> +        echo
> +        export PS1="$_name:\${PWD}# "
> +        [ -e /.profile ] || >/.profile
> +
> +        _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
> +        if [ -z "$_ctty" ]; then
> +            _ctty=console
> +            while [ -f /sys/class/tty/$_ctty/active ]; do
> +                _ctty=$(cat /sys/class/tty/$_ctty/active)
> +                _ctty=${_ctty##* } # last one in the list
> +            done
> +            _ctty=/dev/$_ctty
> +        fi
> +        [ -c "$_ctty" ] || _ctty=/dev/tty1
> +        strstr "$(setsid --help 2>/dev/null)" "ctty" && CTTY="-c"
> +        setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
> +    fi
> +}
> +
>  emergency_shell()
>  {
>      local _ctty
> @@ -883,32 +914,7 @@ emergency_shell()
>      echo
>  
>      if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
> -        if [ -x /lib/systemd/systemd ]; then
> -            > /.console_lock
> -            echo "PS1=\"$_rdshell_name:\${PWD}# \"" >/etc/profile
> -            systemctl start emergency.service
> -            debug_off
> -            while [ -e /.console_lock ]; do sleep 1; done
> -            debug_on
> -        else
> -            echo "Dropping to debug shell."
> -            echo
> -            export PS1="$_rdshell_name:\${PWD}# "
> -            [ -e /.profile ] || >/.profile
> -
> -            _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
> -            if [ -z "$_ctty" ]; then
> -                _ctty=console
> -                while [ -f /sys/class/tty/$_ctty/active ]; do
> -                    _ctty=$(cat /sys/class/tty/$_ctty/active)
> -                    _ctty=${_ctty##* } # last one in the list
> -                done
> -                _ctty=/dev/$_ctty
> -            fi
> -            [ -c "$_ctty" ] || _ctty=/dev/tty1
> -            strstr "$(setsid --help 2>/dev/null)" "ctty" && CTTY="-c"
> -            setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
> -        fi
> +        _emergency_shell $_rdshell_name
>      else
>          warn "$action has failed. To debug this issue add \"rd.shell\" to the kernel command line."
>          # cause a kernel panic
> --
> To unsubscribe from this list: send the line "unsubscribe initramfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

      parent reply	other threads:[~2012-08-01 12:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-01 10:07 [PATCH] split emergency_shell function Dave Young
     [not found] ` <20120801100751.GA13552-je1gSBvt1Td3da3rpXeqgR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2012-08-01 12:42   ` Harald Hoyer [this message]

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=5019243C.40308@redhat.com \
    --to=harald-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@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.