Re: [PATCH 1/4] Have linuxrc.s390 callable as "reboot" or "shutdown", just like init.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/23/2009 09:40 PM, Chris Lumens wrote:
> ---
>  loader/linuxrc.s390 |   18 +++++++++---------
>  scripts/mk-images   |    8 ++++----
>  2 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/loader/linuxrc.s390 b/loader/linuxrc.s390
> index a3ee665..26dc90f 100644
> --- a/loader/linuxrc.s390
> +++ b/loader/linuxrc.s390
> @@ -92,8 +92,8 @@ function checkipv4()
> 
>  function doshutdown()
>  {
> -    echo $"about to exec shutdown"
> -    exec /sbin/shutdown
> +    echo $"about to exec halt"
> +    exec /sbin/halt

This hunk seems to introduce an endless loop with linuxrc.s390 calling
itself.
linuxrc.s390 does not implement the following but I think it should
because shutdown does only work on being exec'ed by the init process
with PID 1:

loader/init.c:

/* reboot handler */
static void sigintHandler(int signum) {
    termReset();
        shouldReboot = 1;
    shutDown(getKillPolicy(), REBOOT);
}

/* halt handler */
static void sigUsr1Handler(int signum) {
    termReset();
    shutDown(getKillPolicy(), HALT);
}

/* poweroff handler */
static void sigUsr2Handler(int signum) {
    termReset();
    shutDown(getKillPolicy(), POWEROFF);
}

...

int main(int argc, char **argv) {
...
    if (!strncmp(basename(argv[0]), "poweroff", 8)) {
        printf("Running poweroff...\n");
        fd = getInitPid();
        if (fd > 0)
            kill(fd, SIGUSR2);
        doExit(0);
    } else if (!strncmp(basename(argv[0]), "halt", 4)) {
        printf("Running halt...\n");
        fd = getInitPid();
        if (fd > 0)
            kill(fd, SIGUSR1);
        doExit(0);
    } else if (!strncmp(basename(argv[0]), "reboot", 6)) {
        printf("Running reboot...\n");
        fd = getInitPid();
        if (fd > 0)
            kill(fd, SIGINT);
        doExit(0);
    }
...

>      exit 0
>  }
> 
> @@ -109,8 +109,8 @@ function doreboot()
>          popd >/dev/null 2>&1
>      fi
> 
> -    echo $"about to exec shutdown -r"
> -    exec /sbin/shutdown -r
> +    echo $"about to exec reboot"
> +    exec /sbin/reboot

same as for doshutdown()

>      exit 0
>  }
> 
> @@ -2702,6 +2702,11 @@ function final_check() {
> 
>  ### MAIN ###
> 
> +case "${0/.*\//}" in
> +    "reboot")   doreboot ;;
> +    "shutdown") doshutdown ;;

Missing poweroff case to get it in line with init.c?

To resemble init.c this should probaby kill the real init (1st instance
of linurxc.s390) with the appropriate SIGUSR.

> +esac
> +
>  init_main
>  udev_setup
> 
> @@ -3054,11 +3059,6 @@ EOF
> 
>      echo -n $$ > /var/run/init.pid
> 
> -    # shutdown (halt) on SIGUSR1
> -    trap doshutdown SIGUSR1
> -    # reboot on SIGUSR2
> -    trap doreboot SIGUSR2
> -

To resemble init.c this should probably stay in place.

>      startinetd
> 
>      if [ -n "$RUNKS" ]; then
> diff --git a/scripts/mk-images b/scripts/mk-images
> index aefc5b0..475f904 100755
> --- a/scripts/mk-images
> +++ b/scripts/mk-images
> @@ -634,17 +634,17 @@ makeinitrd() {
>      instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/$LOADERBIN $MBD_DIR /sbin/loader
>      if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
>          instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/init $MBD_DIR /sbin/init
> -        ln -s ./init $MBD_DIR/sbin/reboot
> -        ln -s ./init $MBD_DIR/sbin/halt
> -        ln -s ./init $MBD_DIR/sbin/poweroff
>      else
> -        instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/shutdown $MBD_DIR /sbin/shutdown

shutdown is still required since linuxrc.s390 cannot call the native
function shutDown() itself

>          instbin $IMGPATH /usr/lib/anaconda-runtime/loader/linuxrc.s390 $MBD_DIR /sbin/init
>          instbin $IMGPATH /usr/lib/anaconda-runtime/loader/lsznet.raw $MBD_DIR /sbin/lsznet
>          instbin $IMGPATH /usr/lib/anaconda-runtime/loader/controlunits.sh $MBD_DIR /sbin/controlunits
>          instbin $IMGPATH /usr/sbin/dasdfmt $MBD_DIR /sbin/dasdfmt
>      fi
> 
> +    ln -s ./init $MBD_DIR/sbin/reboot
> +    ln -s ./init $MBD_DIR/sbin/halt
> +    ln -s ./init $MBD_DIR/sbin/poweroff
> +
>      if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
>         install -m 644 $KEYMAPS $MBD_DIR/etc/keymaps.gz
>         install -m 644 $SCREENFONT $MBD_DIR/etc/screenfont.gz

Steffen

Linux on System z Development

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux