On Friday 27 July 2007, Rafael J. Wysocki wrote:
> Apart from this you should also clear the PLATFORM_SUSPEND flag in the image
> header. Otherwise, resume will be confused if shutdown_method is originally
> set to "platform".
OK.
What do you think about this one?
I passed the header to save_image, but left the number of pages as-is, although
it can be retrieved from the header now.
Best Regards,
Alon Bar-Lev.
---
Index: splash.c
===================================================================
RCS file: /cvsroot/suspend/suspend/splash.c,v
retrieving revision 1.7
diff -u -B -r1.7 splash.c
--- splash.c 12 May 2007 20:37:47 -0000 1.7
+++ splash.c 27 Jul 2007 20:16:53 -0000
@@ -51,13 +51,13 @@
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)
Index: splash.h
===================================================================
RCS file: /cvsroot/suspend/suspend/splash.h,v
retrieving revision 1.5
diff -u -B -r1.5 splash.h
--- splash.h 12 May 2007 20:37:47 -0000 1.5
+++ splash.h 27 Jul 2007 20:16:53 -0000
@@ -25,7 +25,7 @@
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 *);
};
Index: suspend.c
===================================================================
RCS file: /cvsroot/suspend/suspend/suspend.c,v
retrieving revision 1.80
diff -u -B -r1.80 suspend.c
--- suspend.c 13 May 2007 20:16:53 -0000 1.80
+++ suspend.c 27 Jul 2007 20:16:55 -0000
@@ -447,7 +445,7 @@
*/
static int save_image(struct swap_map_handle *handle,
- unsigned int nr_pages)
+ struct swsusp_info *header, unsigned int nr_pages)
{
unsigned int m, writeout_rate;
int ret, abort_possible;
@@ -489,11 +487,19 @@
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");
+ header->image_flags &=
~PLATFORM_SUSPEND;
+ break;
}
}
if (!(nr_pages % writeout_rate))
@@ -647,7 +653,7 @@
#endif
if (!error) {
gettimeofday(&begin, NULL);
- error = save_image(&handle, header->pages - 1);
+ error = save_image(&handle, header, header->pages - 1);
}
}
if (!error) {
Index: swsusp.h
===================================================================
RCS file: /cvsroot/suspend/suspend/swsusp.h,v
retrieving revision 1.34
diff -u -B -r1.34 swsusp.h
--- swsusp.h 16 Mar 2007 16:02:23 -0000 1.34
+++ swsusp.h 27 Jul 2007 20:16:55 -0000
@@ -216,3 +216,5 @@
#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: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Suspend-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/suspend-devel