OpenSolaris

Printable Version Enter a New Search
Bug ID 6756293
Synopsis poweroff and halt commands broken by fast reboot feature
State 10-Fix Delivered (Fix available in build)
Category:Subcategory kernel:boot-x86
Keywords Fastreboot | opensolaris | oss-request
Sponsor
Submitter jk
Responsible Engineer Konstantin Ananyev
Reported Against snv_100
Duplicate Of
Introduced In solaris_nevada
Commit to Fix snv_101
Fixed In snv_101
Release Fixed solaris_nevada(snv_101)
Related Bugs 6714038
Submit Date 6-October-2008
Last Update Date 22-October-2008
Description
Category
   kernel
Sub-Category
   boot-x86
Description
   
Since my hardware seems to support the new fast reboot feature, I tried to
make fast reboot the default, by creating the /etc/fastreboot file.
That did break the poweroff and halt commands; poweroff and halt commands will
fast reboot the system instead of powering off or halting the system.
Another problem is that the usage message for halt / poweroff doesn't
tell us about the new fast reboot -f and -e options, but the commands 
accepts them anyway.  And "halt -f" fast reboots, instead of halting.
Suggested fixes:
================
diff --git a/usr/src/cmd/halt/halt.c b/usr/src/cmd/halt/halt.c
--- a/usr/src/cmd/halt/halt.c
+++ b/usr/src/cmd/halt/halt.c
@@ -1134,6 +1134,7 @@
 uintptr_t mdep = NULL;
 int cmd, fcn, c, aval, r;
 const char *usage;
+const char *optstring;
 zoneid_t zoneid = getzoneid();
 int need_check_zones = 0;
 char bootargs_buf[BOOTARGS_MAX];
@@ -1149,19 +1150,23 @@
 
 if (strcmp(cmdname, "halt") == 0) {
 (void) audit_halt_setup(argc, argv);
+optstring = "dlnqy";
 usage = gettext("usage: %s [ -dlnqy ]\n");
 cmd = A_SHUTDOWN;
 fcn = AD_HALT;
 } else if (strcmp(cmdname, "poweroff") == 0) {
 (void) audit_halt_setup(argc, argv);
+optstring = "dlnqy";
 usage = gettext("usage: %s [ -dlnqy ]\n");
 cmd = A_SHUTDOWN;
 fcn = AD_POWEROFF;
 } else if (strcmp(cmdname, "reboot") == 0) {
 (void) audit_reboot_setup();
 #if defined(__i386)
+optstring = "dlnqyfe:";
 usage = gettext("usage: %s [ -dlnqfe: ] [ boot args ]\n");
 #else
+optstring = "dlnqy";
 usage = gettext("usage: %s [ -dlnq ] [ boot args ]\n");
 #endif
 cmd = A_SHUTDOWN;
@@ -1172,7 +1177,7 @@
 return (1);
 }
 
-while ((c = getopt(argc, argv, "dlnqyfe:")) != EOF) {
+while ((c = getopt(argc, argv, optstring)) != EOF) {
 switch (c) {
 case 'd':
 if (zoneid == GLOBAL_ZONEID)
@@ -1247,9 +1252,9 @@
 }
 
 /*
- * Check whether fast  reboot is the default operating mode
+ * Check whether fast reboot is the default operating mode
  */
-if (!fast_reboot)
+if (fcn == AD_BOOT && !fast_reboot)
 fast_reboot = is_fastboot_default(euid);
 
 if (bename && !fast_reboot){
Frequency
   Always
Regression
   No
Steps to Reproduce
   
touch /etc/fastreboot
poweroff
halt -f
poweroff -f
Expected Result
   
"poweroff" command with /etc/fastreboot file present:
System is powered off.
"halt -f" / "poweroff -f": a command usage error message should be shown.
Actual Result
   
System reboots (fast reboot).
Error Message(s)
   
Test Case
   
Workaround
   
Don't create the /etc/fastreboot file, use "reboot -f"
Submitter wants to work on bug
   Yes
Additional configuration information
   SXCE build 95, bfu'ed to current opensolaris (2008-10-2)
Work Around
N/A
Comments
N/A