Hello,
This patch enables the user to press "r" during snapshot writing,
in order to reboot and not shutdown.
One more step toward suspend2 functionality... :)
Best Regards,
Alon Bar-Lev.
diff -urNp suspend.org/splash.c suspend/splash.c
--- suspend.org/splash.c 2007-05-12 23:37:47.000000000 +0300
+++ suspend/splash.c 2007-07-20 18:28:51.000000000 +0300
@@ -51,13 +51,13 @@ static int prepare_abort(struct termios
return ret;
}
-static int key_pressed(const char key)
+static char key_pressed(void)
{
char c;
- if (read(0, &c, 1) > 0 && c == key)
- return 1;
+ if (read(0, &c, 1) == 0)
+ return 0;
- return 0;
+ return c;
}
static void restore_abort(struct termios *oldtrm)
diff -urNp suspend.org/splash.h suspend/splash.h
--- suspend.org/splash.h 2007-05-12 23:37:47.000000000 +0300
+++ suspend/splash.h 2007-07-20 18:29:42.000000000 +0300
@@ -25,7 +25,7 @@ struct splash {
void (*read_password) (char *, int);
int (*dialog) (const char *);
int (*prepare_abort) (struct termios *, struct termios *);
- int (*key_pressed) (const char key);
+ char (*key_pressed) (void);
void (*restore_abort) (struct termios *);
};
diff -urNp suspend.org/suspend.c suspend/suspend.c
--- suspend.org/suspend.c 2007-05-13 23:16:53.000000000 +0300
+++ suspend/suspend.c 2007-07-20 18:41:32.000000000 +0300
@@ -489,11 +487,18 @@ static int save_image(struct swap_map_ha
if (!(nr_pages % m)) {
printf("\b\b\b\b%3d%%", nr_pages / m);
splash.progress(20 + (nr_pages / m) * 0.75);
- if (abort_possible &&
- splash.key_pressed(ABORT_KEY_CODE)) {
- printf(" aborted!\n");
- return -EINTR;
+ switch (splash.key_pressed()) {
+ case ABORT_KEY_CODE:
+ if (abort_possible) {
+ printf(" aborted!\n");
+ return -EINTR;
+ }
+ break;
+ case REBOOT_KEY_CODE:
+ printf (" reboot
enabled\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
+ strcpy (shutdown_method,
"reboot");
+ break;
}
}
if (!(nr_pages % writeout_rate))
diff -urNp suspend.org/swsusp.h suspend/swsusp.h
--- suspend.org/swsusp.h 2007-03-16 18:02:23.000000000 +0200
+++ suspend/swsusp.h 2007-07-20 18:33:42.000000000 +0300
@@ -216,3 +216,5 @@ struct buf_block {
#define ABORT_KEY_CODE 127
#define ABORT_KEY_NAME "backspace"
+#define REBOOT_KEY_CODE 'r'
+#define REBOOT_KEY_NAME "r"
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Suspend-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/suspend-devel