From: Sami Kerola Date: Fri, 25 Apr 2014 23:50:30 +0000 (+0100) Subject: swapon, swapheader, mkswap: move swap signature to header X-Git-Tag: v2.25-rc1~234 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24f83f7392a1e90e7db8567a675fdcd8f2e3e623;p=thirdparty%2Futil-linux.git swapon, swapheader, mkswap: move swap signature to header 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 Signed-off-by: Karel Zak --- diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index 830b14c063..06ec15aee6 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -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; diff --git a/include/swapheader.h b/include/swapheader.h index e56d93f3a1..1d91e41cee 100644 --- a/include/swapheader.h +++ b/include/swapheader.h @@ -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 diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index b88b7ec63a..4f98500efe 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -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 */