aboutsummaryrefslogtreecommitdiff
path: root/sbin/dumpon
diff options
context:
space:
mode:
authorSteven Hartland <smh@FreeBSD.org>2015-11-23 14:06:21 +0000
committerSteven Hartland <smh@FreeBSD.org>2015-11-23 14:06:21 +0000
commit45a9027de435d38be0bdeff83921d26419e2267e (patch)
treebcd62e6c7419409a8200944cb240043201d0e516 /sbin/dumpon
parent477f6d2e17803fbc354c4d5e504da5be216bcfd2 (diff)
downloadsrc-45a9027de435d38be0bdeff83921d26419e2267e.tar.gz
src-45a9027de435d38be0bdeff83921d26419e2267e.zip
Fix dumpon compatibility with dumpdev kenv
The dumpdev kenv supports devices without the /dev/ prefix, fix dumpon to also support this which is required after r288153. MFC after: 1 week Sponsored by: Multiplay
Notes
Notes: svn path=/head/; revision=291207
Diffstat (limited to 'sbin/dumpon')
-rw-r--r--sbin/dumpon/dumpon.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c
index eebcc694e68d..1ecbff3a6383 100644
--- a/sbin/dumpon/dumpon.c
+++ b/sbin/dumpon/dumpon.c
@@ -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)