Date: Mon, 30 Nov 2015 09:13:04 +0000 (UTC) From: Steven Hartland <smh@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r291480 - stable/10/sbin/dumpon Message-ID: <201511300913.tAU9D4n0046946@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: smh Date: Mon Nov 30 09:13:04 2015 New Revision: 291480 URL: https://svnweb.freebsd.org/changeset/base/291480 Log: MFC r291207: Fix dumpon compatibility with dumpdev kenv Sponsored by: Multiplay Modified: stable/10/sbin/dumpon/dumpon.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/dumpon/dumpon.c ============================================================================== --- stable/10/sbin/dumpon/dumpon.c Mon Nov 30 09:02:28 2015 (r291479) +++ stable/10/sbin/dumpon/dumpon.c Mon Nov 30 09:13:04 2015 (r291480) @@ -152,16 +152,31 @@ main(int argc, char *argv[]) usage(); if (strcmp(argv[0], "off") != 0) { - fd = open(argv[0], O_RDONLY); + char tmp[PATH_MAX]; + char *dumpdev; + + if (strncmp(argv[0], _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) { + dumpdev = argv[0]; + } else { + i = snprintf(tmp, PATH_MAX, "%s%s", _PATH_DEV, argv[0]); + if (i < 0) { + err(EX_OSERR, "%s", argv[0]); + } else if (i >= PATH_MAX) { + errno = EINVAL; + err(EX_DATAERR, "%s", argv[0]); + } + dumpdev = tmp; + } + fd = open(dumpdev, O_RDONLY); if (fd < 0) - err(EX_OSFILE, "%s", argv[0]); - check_size(fd, argv[0]); + err(EX_OSFILE, "%s", dumpdev); + check_size(fd, dumpdev); u = 0; i = ioctl(fd, DIOCSKERNELDUMP, &u); u = 1; i = ioctl(fd, DIOCSKERNELDUMP, &u); if (i == 0 && verbose) - printf("kernel dumps on %s\n", argv[0]); + printf("kernel dumps on %s\n", dumpdev); } else { fd = open(_PATH_DEVNULL, O_RDONLY); if (fd < 0)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511300913.tAU9D4n0046946>