On Fri, Oct 06, 2006 at 07:37:23PM +0200, Stefan Seyfried wrote:
> On Fri, Oct 06, 2006 at 03:54:08PM +0200, Stefan Seyfried wrote:
> > Hi,
> > 
> > i just had an idea :-)
> 
> ok, so how about this:

it does not work.
 
> Index: s2ram.c
> ===================================================================
> RCS file: /cvsroot/suspend/suspend/s2ram.c,v
> retrieving revision 1.45
> diff -u -p -r1.45 s2ram.c
> --- s2ram.c   20 Sep 2006 16:23:51 -0000      1.45
> +++ s2ram.c   6 Oct 2006 17:32:56 -0000
> @@ -10,11 +10,15 @@
>  #include <getopt.h>
>  #include <errno.h>
>  #include <string.h>
> +#include <sys/ioctl.h>
> +#include <syscall.h>
> +#include <unistd.h>
>  
>  #define S2RAM
>  #include "vbetool/vbetool.h"
>  #include "vt.h"
>  #include "s2ram.h"
> +#include "swsusp.h"
>  
>  static void *vbe_buffer;
>  /* Flags set from whitelist */
> @@ -192,9 +196,15 @@ int s2ram_prepare(void)
>  }
>  
>  /* Actually enter the suspend. May be ran on frozen system. */
> -int s2ram_do(void)
> +int s2ram_do(int frozen, int snapshot_fd)
>  {
>       int ret = 0;
> +     if (frozen) {
> +             printf("calling suspend_to_ram ioctl\n");
> +             ret = suspend_to_ram(snapshot_fd);
> +             goto out;
> +     }
> +
>       FILE *f = fopen("/sys/power/state", "w");
>       if (!f) {
>               printf("/sys/power/state does not exist; what kind of ninja 
> mutant machine is this?\n");
> @@ -211,6 +221,7 @@ int s2ram_do(void)
>               ret = errno;
>               perror("s2ram_do");
>       }
> + out:
>       return ret;
>  } 
>  
> @@ -267,7 +278,7 @@ static void usage(void)
>  int main(int argc, char *argv[])
>  {
>       int i, id = -1, ret = 0, test_mode = 0, force = 0;
> -     int active_console = -1;
> +     int active_console = -1, snapshot_fd = -1, frozen = 0;
>       struct option options[] = {
>               { "test",       no_argument,            NULL, 'n'},
>               { "help",       no_argument,            NULL, 'h'},
> @@ -354,13 +365,24 @@ int main(int argc, char *argv[])
>       printf("Switching from vt%d to vt1\n", active_console);
>       chvt(1);
>  
> +     snapshot_fd = open("/dev/snapshot", O_RDONLY);
> +     if (snapshot_fd < 0)
> +             fprintf(stderr, "s2ram: Could not open the snapshot device\n");
> +     else
> +             frozen = !freeze(snapshot_fd);
> +
> +     fprintf(stderr, "frozen: %d\n", frozen);
>       ret = s2ram_hacks();
>       if (ret)
>               goto out;
> -     ret = s2ram_do();
> +     ret = s2ram_do(frozen, snapshot_fd);
>       s2ram_resume();
>  
>   out:
> +     if (frozen)
> +             unfreeze(snapshot_fd);
> +     if (snapshot_fd > 0)
> +             close(snapshot_fd);

usually it segfaults somewhere around here. Or more exactly, since i
tried reordering the stuff, it segfaults in the first glibc function
used. Not always, but every second or third suspend.


>       /* if we switched consoles before suspend, switch back */
>       if (active_console > 0) {
>               printf("switching back to vt%d\n", active_console);

i moved this one up between unfreeze() and close(snapshot_fd), and then it
segfaulted in printf or in the chvt() following it.

> I think i need to link statically and use some mlockall() or something.

I tried this both and it did not work.

But if i switched back to vt7 manually (only tried from X), everything else
worked fine, just the s2ram segfaulted before switching back to vt7.
-- 
Stefan Seyfried                  \ "I didn't want to write for pay. I
QA / R&D Team Mobile Devices      \ wanted to be paid for what I write."
SUSE LINUX Products GmbH, Nürnberg \                    -- Leonard Cohen

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Suspend-devel mailing list
Suspend-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to