FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Kernel

 
 
LinkBack Thread Tools
 
Old 03-04-2010, 06:35 PM
David Cantrell
 
Default Improve reboot modes in init.c and shutdown.c. (#564297).

From: Ales Kozumplik <akozumpl@redhat.com>

Stop the kernel correctly on HALT (so that we dont see 'kernel panic, they
killed init' on i386 and on s390 one gets easy access to manual IPL).

Introduce a new reboot method that does allow us to see the backtrace and
doesn't scroll the screen up with useless unmount info.
---
loader/init.c | 8 +++---
loader/init.h | 5 +++-
loader/shutdown.c | 63 +++++++++++++++++++++++++++++++++++-----------------
3 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/loader/init.c b/loader/init.c
index 19fc31d..d8f5eb5 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -513,8 +513,8 @@ int main(int argc, char **argv) {
pid_t installpid, childpid;
int waitStatus;
int fd = -1;
- int doReboot = 0;
int doShutdown =0;
+ reboot_action shutdown_method = HALT;
int isSerial = 0;
char * console = NULL;
int doKill = 1;
@@ -851,6 +851,7 @@ int main(int argc, char **argv) {

if (!WIFEXITED(waitStatus) ||
(WIFEXITED(waitStatus) && WEXITSTATUS(waitStatus))) {
+ shutdown_method = DELAYED_REBOOT;
printf("install exited abnormally [%d/%d] ", WIFEXITED(waitStatus),
WEXITSTATUS(waitStatus));
if (WIFSIGNALED(waitStatus)) {
@@ -858,11 +859,10 @@ int main(int argc, char **argv) {
}
printf("
");
} else {
- doReboot = 1;
+ shutdown_method = REBOOT;
}

- expected_exit = 1;
- shutDown(doKill, doReboot?REBOOT:HALT);
+ shutDown(doKill, shutdown_method);

return 0;
}
diff --git a/loader/init.h b/loader/init.h
index 733bc8e..e1e5b70 100644
--- a/loader/init.h
+++ b/loader/init.h
@@ -22,7 +22,10 @@
typedef enum {
REBOOT,
POWEROFF,
- HALT
+ HALT,
+ /* gives user a chance to read the trace before scrolling the text out
+ with disk unmounting and termination info */
+ DELAYED_REBOOT
} reboot_action;

#endif /* INIT_H */
diff --git a/loader/shutdown.c b/loader/shutdown.c
index 774e11a..3b481f2 100644
--- a/loader/shutdown.c
+++ b/loader/shutdown.c
@@ -62,35 +62,56 @@ static void performUnmounts(void) {
}

static void performReboot(reboot_action rebootAction) {
- if (rebootAction == POWEROFF) {
+ switch (rebootAction) {
+ case POWEROFF:
printf("powering off system
");
- sleep(2);
+ sleep(2);
reboot(RB_POWER_OFF);
- } else if (rebootAction == REBOOT) {
- printf("rebooting system
");
- sleep(2);
-
+ break;
+ case REBOOT:
+ printf("rebooting system
");
+ sleep(2);
#if USE_MINILIBC
- reboot(0xfee1dead, 672274793, 0x1234567);
+ reboot(0xfee1dead, 672274793, 0x1234567);
#else
- reboot(RB_AUTOBOOT);
+ reboot(RB_AUTOBOOT);
#endif
- }
+ break;
+ case HALT:
+ printf("halting system
");
+ reboot(RB_HALT_SYSTEM);
+ break;
+ default:
+ break;
+ }
}

-void shutDown(int doKill, reboot_action rebootAction) {
- if (doKill) {
- performUnmounts();
- performTerminations();
- }
-
- if ((rebootAction == POWEROFF || rebootAction == REBOOT) && doKill) {
- performReboot(rebootAction);
- }
+static void performDelayedReboot()
+{
+ printf("The system will be rebooted when you press Ctrl-C or Ctrl-Alt-Delete.
");
+ while (1) {
+ sleep(1);
+ }
+}

- printf("you may safely reboot your system
");
- exit(0);
- return;
+void shutDown(int doKill, reboot_action rebootAction)
+{
+ static int reentered = 0;
+
+ if (reentered) {
+ performUnmounts();
+ performTerminations();
+ performReboot(rebootAction);
+ }
+ reentered = 1;
+ if (rebootAction != DELAYED_REBOOT && doKill) {
+ performUnmounts();
+ performTerminations();
+ performReboot(rebootAction);
+ } else {
+ performDelayedReboot();
+ }
+ exit(0);
}

#ifdef AS_SHUTDOWN
--
1.6.6.1

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

Thread Tools




All times are GMT. The time now is 04:25 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org