]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
swapon, swapheader, mkswap: move swap signature to header
authorSami Kerola <kerolasa@iki.fi>
Fri, 25 Apr 2014 23:50:30 +0000 (00:50 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 6 May 2014 08:16:54 +0000 (10:16 +0200)
Both swapon and mkswap need to know what is valid device signature, so
share the value.

[kzak@redhat.com: - use SWAP_SIGNATURE_SZ properly in write_signature()]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/mkswap.c
include/swapheader.h
sys-utils/swapon.c

index 830b14c0638a4bcb9cade1270d73d0829c81fb96..06ec15aee6681ff290c0688c8daa75ef04e7806f 100644 (file)
@@ -177,7 +177,7 @@ write_signature(char *sig)
 {
        char *sp = (char *) signature_page;
 
-       strncpy(sp + pagesize - 10, sig, 10);
+       strncpy(sp + pagesize - SWAP_SIGNATURE_SZ, sig, SWAP_SIGNATURE_SZ);
 }
 
 static void
@@ -611,7 +611,7 @@ main(int argc, char **argv) {
        printf(_("Setting up swapspace version %d, size = %llu KiB\n"),
                version, goodpages * pagesize / 1024);
 
-       write_signature("SWAPSPACE2");
+       write_signature(SWAP_SIGNATURE);
        write_uuid_and_label(uuid, opt_label);
 
        offset = 1024;
index e56d93f3a1a6ba022ee3a3c22678c47a8a0ea34b..1d91e41cee9c1acf483d31cf4250a757c7aed818 100644 (file)
@@ -4,6 +4,8 @@
 #define SWAP_VERSION 1
 #define SWAP_UUID_LENGTH 16
 #define SWAP_LABEL_LENGTH 16
+#define SWAP_SIGNATURE "SWAPSPACE2"
+#define SWAP_SIGNATURE_SZ (sizeof(SWAP_SIGNATURE) - 1)
 
 #include <stdint.h>
 
index b88b7ec63ae33543d1928754c14a1f7e8a998107..4f98500efeb709a50baa0d61b38372359ea4016e 100644 (file)
@@ -76,9 +76,6 @@ enum {
        SIG_SWSUSPEND
 };
 
-#define SWAP_SIGNATURE         "SWAPSPACE2"
-#define SWAP_SIGNATURE_SZ      (sizeof(SWAP_SIGNATURE) - 1)
-
 static int all;
 static int priority = -1;      /* non-prioritized swap by default */
 static int discard;            /* don't send swap discards by default */