Date: Tue, 25 Jul 2017 00:28:29 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r321447 - stable/11/sbin/savecore Message-ID: <201707250028.v6P0STIp076077@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Tue Jul 25 00:28:29 2017 New Revision: 321447 URL: https://svnweb.freebsd.org/changeset/base/321447 Log: MFC r320896: Add a subroutine for comparing kerneldump identifiers. Modified: stable/11/sbin/savecore/savecore.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/savecore/savecore.c ============================================================================== --- stable/11/sbin/savecore/savecore.c Tue Jul 25 00:28:23 2017 (r321446) +++ stable/11/sbin/savecore/savecore.c Tue Jul 25 00:28:29 2017 (r321447) @@ -308,6 +308,13 @@ check_space(const char *savedir, off_t dumpsize, int b return (1); } +static bool +compare_magic(const struct kerneldumpheader *kdh, const char *magic) +{ + + return (strncmp(kdh->magic, magic, sizeof(kdh->magic)) == 0); +} + #define BLOCKSIZE (1<<12) #define BLOCKMASK (~(BLOCKSIZE-1)) @@ -534,7 +541,7 @@ DoFile(const char *savedir, const char *device) } memcpy(&kdhl, temp, sizeof(kdhl)); istextdump = 0; - if (strncmp(kdhl.magic, TEXTDUMPMAGIC, sizeof kdhl) == 0) { + if (compare_magic(&kdhl, TEXTDUMPMAGIC)) { if (verbose) printf("textdump magic on last dump header on %s\n", device); @@ -548,8 +555,7 @@ DoFile(const char *savedir, const char *device) if (force == 0) goto closefd; } - } else if (memcmp(kdhl.magic, KERNELDUMPMAGIC, sizeof kdhl.magic) == - 0) { + } else if (compare_magic(&kdhl, KERNELDUMPMAGIC)) { if (dtoh32(kdhl.version) != KERNELDUMPVERSION) { syslog(LOG_ERR, "unknown version (%d) in last dump header on %s", @@ -568,8 +574,7 @@ DoFile(const char *savedir, const char *device) if (force == 0) goto closefd; - if (memcmp(kdhl.magic, KERNELDUMPMAGIC_CLEARED, - sizeof kdhl.magic) == 0) { + if (compare_magic(&kdhl, KERNELDUMPMAGIC_CLEARED)) { if (verbose) printf("forcing magic on %s\n", device); memcpy(kdhl.magic, KERNELDUMPMAGIC,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707250028.v6P0STIp076077>