On 2012-06-21 03:36, malcolmlewis wrote:
> Hi
> Probably why rpmbuild isn’t supported anymore? Post the changes your
> wanting to suspend.c I’m assuming it’s 11.4 your building for?
Yep.
I’m modifying this function only, some printf statement (search for the
word “step”). What I have done is copying the binary “s2disk” to place,
without building the rpm. It works, I see the strings printed to the
screen. I hibernated and restored five times, no crash - which is bad, I
wanted it to crash to find where it does. If it does beyond the step 1.5
then I don’t know where else to print.
It is ugly code, it has GOTOS! One of them and I would have failed my
exams… times most have “achanged”.
> int suspend_system(int snapshot_fd, int resume_fd, int test_fd)
> {
> loff_t avail_swap;
> unsigned long image_size;
> int attempts, in_suspend, error = 0;
> char message[SPLASH_GENERIC_MESSAGE_SIZE];
>
> avail_swap = check_free_swap(snapshot_fd);
> if (avail_swap > pref_image_size)
> image_size = pref_image_size;
> else
> image_size = avail_swap;
> if (!avail_swap) {
> suspend_error("Not enough swap space for suspend");
> return ENOSPC;
> }
>
> error = freeze(snapshot_fd);
>
> /* This a hack for a bug in bootsplash. Apparently it will
> * drop to 'verbose mode' after the freeze() call.
> */
> splash.switch_to();
> splash.progress(15);
>
> if (error) {
> suspend_error("Freeze failed.");
> goto Unfreeze;
> }
>
> if (test_fd >= 0) {
> printf("%s: Running in test mode
", my_name);
> error = write_image(snapshot_fd, resume_fd, test_fd);
> if (error)
> error = -error;
> reset_signature(resume_fd);
> free_swap_pages(snapshot_fd);
> goto Unfreeze;
> }
>
> if (shutdown_method == SHUTDOWN_METHOD_PLATFORM) {
> if (platform_prepare(snapshot_fd)) {
> suspend_error("Unable to use platform hibernation "
> "support, using shutdown mode.");
> shutdown_method = SHUTDOWN_METHOD_SHUTDOWN;
> }
> }
>
> sprintf(message, "Snapshotting system - step 1.0");
> printf("%s: %s
", my_name, message);
> splash.set_caption(message);
> attempts = 2;
> do {
> sprintf(message, "Snapshotting system - step 1.1");
> printf("%s: %s
", my_name, message);
> if (set_image_size(snapshot_fd, image_size)) {
> error = errno;
> break;
> }
> sprintf(message, "Snapshotting system - step 1.2");
> printf("%s: %s
", my_name, message);
> if (atomic_snapshot(snapshot_fd, &in_suspend)) {
> error = errno;
> break;
> }
> sprintf(message, "Snapshotting system - step 1.3");
> printf("%s: %s
", my_name, message);
> if (!in_suspend) {
> /* first unblank the console, see console_codes(4) */
> printf("\e[13]");
> printf("%s: returned to userspace
", my_name);
> free_snapshot(snapshot_fd);
> break;
> }
>
> sprintf(message, "Snapshotting system - step 1.4");
> printf("%s: %s
", my_name, message);
> error = write_image(snapshot_fd, resume_fd, -1);
> if (error) {
> free_swap_pages(snapshot_fd);
> free_snapshot(snapshot_fd);
> image_size = 0;
> error = -error;
> if (error != ENOSPC)
> break;
> } else {
> splash.progress(100);
> #ifdef CONFIG_BOTH
> if (s2ram) {
> /* If we die (and allow system to continue)
> * between now and reset_signature(), very bad
> * things will happen. */
> error = suspend_to_ram(snapshot_fd);
> if (error)
> goto Shutdown;
> reset_signature(resume_fd);
> free_swap_pages(snapshot_fd);
> free_snapshot(snapshot_fd);
> goto Unfreeze;
> }
> Shutdown:
> #endif
> close(resume_fd);
> suspend_shutdown(snapshot_fd);
> }
> sprintf(message, "Snapshotting system - step 1.5");
> printf("%s: %s
", my_name, message);
>
> } while (--attempts);
>
> /* We get here during the resume or when we failed to suspend.
> * Remember, suspend_shutdown() never returns!
> */
> if (shutdown_method == SHUTDOWN_METHOD_PLATFORM)
> platform_finish(snapshot_fd);
>
> Unfreeze:
> unfreeze(snapshot_fd);
> /* ugly hack, because "user aborted suspend" is not really
> * an error.
> */
> if (error == EINTR)
> return 0;
> return error;
> }
–
Cheers / Saludos,
Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)