[Pm-utils] [Patch] add userspace suspend signature to pm-reset-swap

Stefan Seyfried seife at suse.de
Tue Feb 20 10:36:48 PST 2007


Hi,

This adds the userspace suspend signature to pm-reset-swap.c, it also
fixes the "always reset the signature, regardless if there is a suspend
image" problem, that could easily corrupt a filesystem if the wrong
partition is given.
The printf for "no signature found" is not really necessary, but i found
it useful :-)

Index: src/pm-reset-swap.c
===================================================================
RCS file: /cvs/pm-utils/pm-utils/src/pm-reset-swap.c,v
retrieving revision 1.1
diff -u -p -r1.1 pm-reset-swap.c
--- src/pm-reset-swap.c	29 Jan 2007 21:49:45 -0000	1.1
+++ src/pm-reset-swap.c	20 Feb 2007 17:15:10 -0000
@@ -95,7 +95,8 @@ int check_resume_block(FILE *dev, off_t 
     if (fread(buf, sizeof (char), 10, dev) != 10)
         return -1;
 
-    if (!strncmp(buf, "S1SUSPEND", 9))
+    if (!strncmp(buf, "S1SUSPEND", 9) ||
+        !strncmp(buf, "ULSUSPEND", 9))
         return 1;
 
     return 0;
@@ -148,7 +149,7 @@ int main(int argc, char *argv[])
         fclose(dev);
         return 2;
     }
-    rc = 1;
+
     if (rc == 1) {
         if (clear_resume_block(dev, 0)) {
             fprintf(stderr, "Could not clear swap signature on \"%s\": %m\n",
@@ -156,7 +157,8 @@ int main(int argc, char *argv[])
             fclose(dev);
             return 1;
         }
-    }
+    } else
+        fprintf(stderr, "no suspend signature found\n");
         
     fclose(dev);
     return 0;
-- 
Stefan Seyfried

"Any ideas, John?"
"Well, surrounding them's out." 


More information about the Pm-utils mailing list