diff options
author | Renato Botelho <renato@netgate.com> | 2015-12-01 08:32:21 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-12-01 08:32:21 -0200 |
commit | 695ea8099809439ed40fe35451df301d75e2b39e (patch) | |
tree | f5d371838e7b09643ac854d4c84c96d401175010 /sbin | |
parent | 2572e1a27934f3539d0356653fcac9aa6b03b80e (diff) | |
parent | ff68307fb48ebed764757b9f0ff301df2f3d8825 (diff) | |
download | FreeBSD-src-695ea8099809439ed40fe35451df301d75e2b39e.zip FreeBSD-src-695ea8099809439ed40fe35451df301d75e2b39e.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dumpon/dumpon.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c index eebcc69..1ecbff3 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) |