From: Karel Zak Date: Tue, 6 Nov 2007 01:40:49 +0000 (+0100) Subject: mkswap: linux_version() code consolidation X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8023c83bd54670ede6ad7e4e940ab6d578414106;p=util-linux mkswap: linux_version() code consolidation Signed-off-by: Karel Zak --- diff --git a/disk-utils/Makefile.am b/disk-utils/Makefile.am index ab44a330..4b8f55c4 100644 --- a/disk-utils/Makefile.am +++ b/disk-utils/Makefile.am @@ -7,7 +7,7 @@ sbin_PROGRAMS = mkfs mkswap blockdev fsck.minix mkfs.minix mkfs.bfs fsck_minix_SOURCES = fsck.minix.c bitops.h minix.h mkfs_minix_SOURCES = mkfs.minix.c bitops.h minix.h mkfs_bfs_SOURCES = mkfs.bfs.c -mkswap_SOURCES = mkswap.c swapheader.h +mkswap_SOURCES = mkswap.c swapheader.h ../lib/linux_version.c usrbinexec_PROGRAMS = fdformat isosize diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index b1cc6e74..d61075b5 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -46,6 +46,7 @@ #include #endif +#include "linux_version.h" #include "swapheader.h" #include "xstrncpy.h" #include "nls.h" @@ -70,24 +71,8 @@ static unsigned long badpages = 0; static int check = 0; static int version = -1; -#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r)) - #define SELINUX_SWAPFILE_TYPE "swapfile_t" -static int -linux_version_code(void) { - struct utsname my_utsname; - int p, q, r; - - if (uname(&my_utsname) == 0) { - p = atoi(strtok(my_utsname.release, ".")); - q = atoi(strtok(NULL, ".")); - r = atoi(strtok(NULL, ".")); - return MAKE_VERSION(p,q,r); - } - return 0; -} - #ifdef __sparc__ # ifdef __arch64__ # define is_sparc64() 1 @@ -597,7 +582,7 @@ main(int argc, char ** argv) { version = 1; else /* use version 1 as default, if possible */ - if (linux_version_code() < MAKE_VERSION(2,1,117)) + if (get_linux_version() < KERNEL_VERSION(2,1,117)) version = 0; else if (pagesize < 2048) version = 0; @@ -619,9 +604,9 @@ main(int argc, char ** argv) { if (version == 0) maxpages = V0_MAX_PAGES; - else if (linux_version_code() >= MAKE_VERSION(2,3,4)) + else if (get_linux_version() >= KERNEL_VERSION(2,3,4)) maxpages = PAGES; - else if (linux_version_code() >= MAKE_VERSION(2,2,1)) + else if (get_linux_version() >= KERNEL_VERSION(2,2,1)) maxpages = V1_MAX_PAGES; else maxpages = V1_OLD_MAX_PAGES;