Re: Introducing a poweroff(8) command

From: Giorgos Keramidas (keramida_at_ceid.upatras.gr)
Date: 08/21/04

  • Next message: Brian Somers: "Re: Introducing a poweroff(8) command"
    Date: Sat, 21 Aug 2004 23:22:52 +0300
    To: freebsd-arch@freebsd.org
    
    

    On 2004-08-21 22:16, Giorgos Keramidas <keramida@freebsd.org> wrote:
    > Hi guys,
    >
    > In response to PR misc/70476 about `halt -p' I wrote a simple patch to
    > introduce a "poweroff" command that will default to "halt -p" behavior
    > and inhibit the need for changing the default behavior of halt(8).
    >
    > o Does this look ok to you all?
    >
    > o Should I suggest using it as a workaround of the behavior
    > described in the PR?

    It would be nice if I also included the patch :-?

    %%%
    Add a hard link to reboot(8) called "poweroff" which defaults to the
    same behavior as "halt -p". Also fix a related bug while here. When
    called as "halt -p" the previous reboot program would not disallow the
    use of -d for saving kernel dumps (it would inhibit dumps without the
    -p option though).

    Index: Makefile
    ===================================================================
    RCS file: /home/ncvs/src/sbin/reboot/Makefile,v
    retrieving revision 1.13
    diff -u -r1.13 Makefile
    --- Makefile 22 Mar 2004 00:52:27 -0000 1.13
    +++ Makefile 21 Aug 2004 18:45:36 -0000
    @@ -14,8 +14,8 @@
     MLINKS+= boot_i386.8 boot.8
     .endif
     
    -LINKS= ${BINDIR}/reboot ${BINDIR}/halt ${BINDIR}/reboot ${BINDIR}/fastboot \
    - ${BINDIR}/reboot ${BINDIR}/fasthalt
    +LINKS= ${BINDIR}/reboot ${BINDIR}/halt ${BINDIR}/reboot ${BINDIR}/poweroff \
    + ${BINDIR}/reboot ${BINDIR}/fastboot ${BINDIR}/reboot ${BINDIR}/fasthalt
     
     SCRIPTS= nextboot.sh
     
    Index: reboot.8
    ===================================================================
    RCS file: /home/ncvs/src/sbin/reboot/reboot.8,v
    retrieving revision 1.22
    diff -u -r1.22 reboot.8
    --- reboot.8 9 Apr 2004 19:58:35 -0000 1.22
    +++ reboot.8 17 Aug 2004 22:04:34 -0000
    @@ -34,6 +34,7 @@
     .Sh NAME
     .Nm reboot ,
     .Nm halt ,
    +.Nm poweroff ,
     .Nm fastboot ,
     .Nm fasthalt
     .Nd stopping and restarting the system
    @@ -41,6 +42,9 @@
     .Nm halt
     .Op Fl lnqp
     .Op Fl k Ar kernel
    +.Nm poweroff
    +.Op Fl lnqp
    +.Op Fl k Ar kernel
     .Nm
     .Op Fl dlnqp
     .Op Fl k Ar kernel
    @@ -52,7 +56,8 @@
     .Op Fl k Ar kernel
     .Sh DESCRIPTION
     The
    -.Nm halt
    +.Nm halt ,
    +.Nm poweroff
     and
     .Nm
     utilities flush the file system cache to disk, send all running processes
    @@ -91,9 +96,10 @@
     This option is intended for applications such as
     .Xr shutdown 8 ,
     that call
    -.Nm
    -or
    +.Nm ,
     .Nm halt
    +or
    +.Nm poweroff
     and log this themselves.
     .It Fl n
     The file system cache is not flushed.
    @@ -106,6 +112,9 @@
     This option should probably not be used.
     .It Fl p
     The system will turn off the power if it can.
    +This is the default action if
    +.Nm poweroff
    +is called.
     If the power down action fails, the system
     will halt or reboot normally, depending on whether
     .Nm halt
    Index: reboot.c
    ===================================================================
    RCS file: /home/ncvs/src/sbin/reboot/reboot.c,v
    retrieving revision 1.20
    diff -u -r1.20 reboot.c
    --- reboot.c 9 Apr 2004 19:58:35 -0000 1.20
    +++ reboot.c 17 Aug 2004 21:55:57 -0000
    @@ -70,9 +70,13 @@
             char *kernel, *p;
             const char *user;
     
    - if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) {
    + p = rindex(*argv, '/') ? p + 1 : *argv;
    + if (strcmp(p, "halt") == 0) {
                     dohalt = 1;
                     howto = RB_HALT;
    + } else if (strcmp(p, "poweroff") == 0) {
    + dohalt = 1;
    + howto = RB_POWEROFF;
             } else
                     howto = 0;
             kflag = lflag = nflag = qflag = 0;
    @@ -108,6 +112,8 @@
     
             if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT))
                     errx(1, "cannot dump (-d) when halting; must reboot instead");
    + if ((howto & (RB_DUMP | RB_POWEROFF)) == (RB_DUMP | RB_POWEROFF))
    + errx(1, "cannot dump (-d) when powering off; must reboot instead");
             if (geteuid()) {
                     errno = EPERM;
                     err(1, NULL);
    %%%
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: Brian Somers: "Re: Introducing a poweroff(8) command"

    Relevant Pages

    • Re: Introducing a poweroff(8) command
      ... > retrieving revision 1.13 ... > +.Nm poweroff ... > -.Nm halt ... > utilities flush the file system cache to disk, ...
      (freebsd-arch)
    • Re: Chrony on an Isolated Machine
      ... >> Also look in the config file for your kernel (some put it into ... You created and compiled that rtl kernel somewhere. ... >> You do not want to remove halt altogether. ... It uses the hwclock command. ...
      (comp.os.linux.networking)
    • [RFC PATCH 26/35] Add Xen subarch reboot support
      ... Add remote reboot capability, so that a virtual machine can be ... halted or 'powered off' by external management tools. ... * HALT is the same as POWEROFF, ...
      (Linux-Kernel)
    • Mandrake 9.1 and 9.2 install problem
      ... It halt the system, no response from keyboard, I have to reboot it. ... I then tried the alt1 kernel, which is the kernel 2.2.19, it works ... The Mandrake 9.1 error database showed that there is a bug in kernel ... file to install from network, but it halt at same stage as 9.1 does, ...
      (comp.os.linux.misc)
    • Re: init troubles with custom install .. perhaps a kernel bug?
      ... > mount a remote share from which to run scripts installing a ghost ... > information I get is when in verbose logging mode, it reaches the halt ... however it seems that the kernel process terminates ... I also inserted a print statement at the start of init, ...
      (freebsd-hackers)

  • Quantcast