From edwin@mavetju.org  Thu Feb 14 09:25:35 2008
Return-Path: <edwin@mavetju.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1188D16A417
	for <freebsd-gnats-submit@freebsd.org>; Thu, 14 Feb 2008 09:25:35 +0000 (UTC)
	(envelope-from edwin@mavetju.org)
Received: from mail5out.barnet.com.au (mail5.barnet.com.au [202.83.178.78])
	by mx1.freebsd.org (Postfix) with ESMTP id 4F17313C4DB
	for <freebsd-gnats-submit@freebsd.org>; Thu, 14 Feb 2008 09:25:34 +0000 (UTC)
	(envelope-from edwin@mavetju.org)
Received: by mail5out.barnet.com.au (Postfix, from userid 1001)
	id 88D302218828; Thu, 14 Feb 2008 20:25:33 +1100 (EST)
Received: from mail5auth.barnet.com.au (mail5.barnet.com.au [202.83.178.78])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail5auth.barnet.com.au", Issuer "*.barnet.com.au" (verified OK))
	by mail5.barnet.com.au (Postfix) with ESMTP id 3CA0121B1CF5
	for <freebsd-gnats-submit@freebsd.org>; Thu, 14 Feb 2008 20:25:33 +1100 (EST)
Received: from k7.mavetju (k7.mavetju.org [10.251.1.18])
	by mail5auth.barnet.com.au (Postfix) with ESMTP id 7E6D42218804
	for <freebsd-gnats-submit@freebsd.org>; Thu, 14 Feb 2008 20:25:32 +1100 (EST)
Received: by k7.mavetju (Postfix, from userid 1001)
	id 578352A1; Thu, 14 Feb 2008 20:25:32 +1100 (EST)
Message-Id: <20080214092532.GL3944@k7.mavetju>
Date: Thu, 14 Feb 2008 20:25:32 +1100
From: Edwin Groothuis <edwin@mavetju.org>
To: FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
Subject: [grog@lemis.com: bin/120114: [patch] sbin/reboot - add features available in Solaris.]

>Number:         120637
>Category:       bin
>Synopsis:       Re: bin/120114: [patch] sbin/reboot - add features available in Solaris.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    edwin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 14 09:30:00 UTC 2008
>Closed-Date:    Thu Feb 14 14:28:44 UTC 2008
>Last-Modified:  Thu Feb 14 14:28:44 UTC 2008
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 ----- Forwarded message from Greg 'groggy' Lehey <grog@lemis.com> -----
 
 Date: Thu, 14 Feb 2008 11:04:33 +1030
 From: Greg 'groggy' Lehey <grog@lemis.com>
 To: Edwin Groothuis <edwin@mavetju.org>
 Subject: bin/120114: [patch] sbin/reboot - add features available in Solaris.
 
 On Saturday,  9 February 2008 at 21:51:32 +1100, Edwin Groothuis wrote:
 >
 > Here you go, courtesy of callum who did have the patience to explain
 > the same problem he had with the initial interpretation of what you
 > said.
 
 basename(3) is clear.  Sorry if you misunderstood, but the numbers are
 important.
 
 > Index: nextboot.8
 > ===================================================================
 > RCS file: /home/ncvs/src/sbin/reboot/nextboot.8,v
 > retrieving revision 1.4
 > diff -u -r1.4 nextboot.8
 > --- nextboot.8	12 Dec 2002 17:25:56 -0000	1.4
 > +++ nextboot.8	9 Feb 2008 10:48:53 -0000
 > @@ -32,25 +32,28 @@
 >  .Nd "specify an alternate kernel and boot flags for the next reboot"
 >  .Sh SYNOPSIS
 >  .Nm
 > -.Op Fl f
 > +.Op Fl fc
 >  .Op Fl o Ar options
 > -.Fl k Ar kernel
 > +.Op Fl b Ar bootfile
 > +.Op Fl k Ar kernel
 >  .Nm
 >  .Fl D
 >  .Sh DESCRIPTION
 >  The
 >  .Nm
 > -utility allows specifying an alternate kernel and/or boot flags for the
 > -next time the machine is booted.
 > +utility allows specifying an alternate kernel, kernel bootfile and/or boot
 > +flags for the next time the machine is booted.
 
 and/or is ugly.  How about "or"?
 
 >  Once the
 >  .Xr loader 8
 > -loads in the new kernel
 > -information, it is deleted so in case the new kernel hangs the machine,
 > -once it is rebooted, the machine will automatically revert to its previous
 > -configuration.
 > +loads in the new kernel information, it is disabled so in case the
 > +new kernel hangs the machine, once it is rebooted, the machine will
 > +automatically revert to its previous configuration.
 
 I don't understand this text.  What do you mean by "disabled"?  Not
 the same as "deleted"?  Looking at nextboot.conf, it appears to be the
 value of the nextboot_enable variable in nextboot.conf.  But you need
 to say that.  You also need to say how to reenable it.
 
 Also, it's not clear from the text whether this disables the
 information or the loader.  How about s/it/the information/?
 
 >  .Pp
 >  The options are as follows:
 > -.Bl -tag -width ".Fl o Ar options"
 > +.Bl -tag -width ".Fl b Ar bootfile"
 > +.It Fl c
 > +Picks the kernel directory and bootfile from the kern.bootfile
 > +sysctl variable.
 
 Pick or picks, not Picks.  I'd go for Pick because it matches the
 other options.
 
 You should also revise the BUGS section.  It's obviously written from
 the viewpoint of the unnamed author (though Gordon seems to have
 written the code too), and it suggests that all the code is in
 loader(8), which is just plain wrong.  I'd remove the first paragraph
 and significantly revise the second.
 
 This man page is also very confused about what it means by "kernel".
 After looking at it, it's clear that it refers to a kernel directory.
 It should say so.
 
 > Index: nextboot.sh
 > ===================================================================
 > RCS file: /home/ncvs/src/sbin/reboot/nextboot.sh,v
 > retrieving revision 1.3
 > diff -u -r1.3 nextboot.sh
 > --- nextboot.sh	18 Jan 2006 04:48:45 -0000	1.3
 > +++ nextboot.sh	9 Feb 2008 10:48:53 -0000
 > @@ -8,14 +8,21 @@
 >  delete="NO"
 >  force="NO"
 >  nextboot_file="/boot/nextboot.conf"
 > +continue="NO"
 >
 >  display_usage() {
 > -	echo "Usage: nextboot [-f] [-o options] -k kernel"
 > +	echo "Usage: nextboot [-cf] [-o options] [-b bootfile] [-k kernel]"
 >  	echo "       nextboot -D"
 >  }
 >
 > -while getopts "Dfk:o:" argument ; do
 > +while getopts "b:cDfk:o:" argument ; do
 >  	case "${argument}" in
 > +	b)
 > +		bootfile="${OPTARG}"
 > +		;;
 > +	c)
 > +		continue="YES"
 > +		;;
 
 Why continue?  Firstly it's a reserved word, and secondly it doesn't
 describe the action of picking the info well.  Maybe "current"?
 
 > Index: reboot.8
 > ===================================================================
 > RCS file: /home/ncvs/src/sbin/reboot/reboot.8,v
 > retrieving revision 1.24
 > diff -u -r1.24 reboot.8
 > --- reboot.8	22 Nov 2006 13:12:34 -0000	1.24
 > +++ reboot.8	9 Feb 2008 10:48:53 -0000
 > @@ -73,9 +85,20 @@
 >  supported only when rebooting, and it has no effect unless a dump
 >  device has previously been specified with
 >  .Xr dumpon 8 .
 > -.It Fl k Ar kernel
 > -Boot the specified
 > +.It Fl k Ar kernel-directory
 > +Boot from the specified
 > +.Ar kernel-directory
 > +on the next system boot.
 > +If the kernel boots successfully, the
 > +.Em default
 > +kernel will be booted on successive boots, this is a one-shot option.
 > +If the boot fails, the system will continue attempting to boot
 >  .Ar kernel
 > +until the boot process is interrupted and a valid kernel booted.
 > +This may change in the future.
 > +.It Fl b Ar kernel-name
 > +Boot the specified
 > +.Ar kernel-name
 >  on the next system boot.
 
 This is messy.  I suppose we need to keep the -k option for backward
 compatibility, but it should be possible to do things like:
 
   reboot -b kernel.debug
 
 to reboot from ${current_kernel_dir}/kernel.debug, and
 
   reboot -b GENERIC/kernel
 
 to reboot from ${current_kernel_dir}/kernel.debug, and
 
   reboot -b GENERIC/
 
 to reboot from boot/GENERIC/kernel (replacing the -k option), and
 
   reboot -b /boot/kernel/kernel.debug
 
 to be completely explicit.  This last one might be convenient for
 scripts.  I'd suggest allowing either -b or -k, not both.  This seems
 to match the comments in sys/boot/forth/support.4th:
 
    \ Try to load a kernel; the kernel name is taken from one of
    \ the following lists, as ordered:
    \
    \   1. The "bootfile" environment variable
    \   2. The "kernel" environment variable
    \
    \ Flags are passed, if provided.
    \
    \ The kernel will be loaded from a directory computed from the
    \ path given. Two directories will be tried in the following order:
    \
    \   1. /boot/path
    \   2. path
    \
 
 > +.It Fl o
 > +This option allows the passing of kernel flags for the next boot.
 
 How?  Which flags?  I see this was in nextboot too, but I didn't
 notice it there.  You need more description here.
 
 > +Reboot the system into single user mode:
 > +.Pp
 > +.Dl "reboot -o -s"
 > +.Dl "reboot -- -s"
 
 Why are there two different ways of doing this?  You should also
 either describe the -- construct under DESCRIPTION, or, better, remove
 it (unless there's some difference I haven't understood).
 
 > Index: reboot.c
 > ===================================================================
 > RCS file: /home/ncvs/src/sbin/reboot/reboot.c,v
 > retrieving revision 1.26
 > diff -u -r1.26 reboot.c
 > --- reboot.c	2 Aug 2006 13:05:38 -0000	1.26
 > +++ reboot.c	9 Feb 2008 10:48:53 -0000
 > +	if (cflag) {
 > +		int max = sizeof(sysctl_bootfile) - 1;
 > +		char *c;
 > +		if (sysctlbyname("kern.bootfile", sysctl_bootfile, &max, NULL,
 > +		    0) < 0)
 > +			errx(1, "sysctl: kern.bootfile");
 > +
 > +		/*
 > +		 * Split /boot/kernel/kernel.debug into kernel and kernel.debug
 > +		 * This can go wrong when the kernel is booted from outside
 > +		 * /boot/, in that case kernel is keeps clear but bootfile is
 > +		 * pointing to the value returned by the sysctl.
 > +		 */
 > +		if (strncmp(sysctl_bootfile, "/boot/", 6) == 0) {
 > +			c = basename(sysctl_bootfile);
 > +			if (c != NULL)
 > +				bootfile = strdup(c);
 > +			c = dirname(sysctl_bootfile);
 > +			if (c != NULL)
 > +				c = basename(c);
 > +			if (c != NULL)
 > +				kernel = strdup(c);
 > +		} else
 > +			bootfile = sysctl_bootfile;
 > +	}
 
 This is still wrong.  As you say, it can go wrong if it's not in
 /boot, which apparently loader(8) supports.  But what if it's set to,
 say, "kernel/kernel"?  That can happen:
 
   # sysctl kern.bootfile
   kern.bootfile: kernel/kernel
 
 What happens if you write kernel/kernel as bootfile to nextboot.conf?
 
 So, still work to be done.
 
 Another ugliness in reboot(8) is that it has a -p option.  What for?
 Some time that should be disabled.
 
 Also, one thing missing from both nextboot and reboot is a -P option
 to specify selecting a different boot partition.  On my systems, for
 example, I have two boot partitions.  When I upgrade, I switch to the
 "other" partition, so I have to manually change it for reboot.  Your
 current changes don't address this problem, and it should be possible
 to do.  You don't have to implement this now, but it's worth thinking
 about.
 
 Greg
 --
 Finger grog@Freebsd.org for PGP public key.
 See complete headers for address and phone numbers.
 
 
 
 ----- End forwarded message -----
 
 -- 
 Edwin Groothuis      |            Personal website: http://www.mavetju.org
 edwin@mavetju.org    |              Weblog: http://www.mavetju.org/weblog/
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Thu Feb 14 14:27:25 UTC 2008 
State-Changed-Why:  
Misfiled followup to bin/120114; content migrated. 


Responsible-Changed-From-To: gnats-admin->edwin 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Feb 14 14:27:25 UTC 2008 
Responsible-Changed-Why:  
Let track any followup from grog, if any. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=120637 
>Unformatted:
