| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kvm.c,v 1.104 2018/11/05 00:43:30 mrg Exp $ */ | | 1 | /* $NetBSD: kvm.c,v 1.105 2020/03/08 00:06:42 chs Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1989, 1992, 1993 | | 4 | * Copyright (c) 1989, 1992, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software developed by the Computer Systems | | 7 | * This code is derived from software developed by the Computer Systems |
8 | * Engineering group at Lawrence Berkeley Laboratory under DARPA contract | | 8 | * Engineering group at Lawrence Berkeley Laboratory under DARPA contract |
9 | * BG 91-66 and contributed to Berkeley. | | 9 | * BG 91-66 and contributed to Berkeley. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
33 | * SUCH DAMAGE. | | 33 | * SUCH DAMAGE. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | #if defined(LIBC_SCCS) && !defined(lint) | | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | #if 0 | | 38 | #if 0 |
39 | static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94"; | | 39 | static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94"; |
40 | #else | | 40 | #else |
41 | __RCSID("$NetBSD: kvm.c,v 1.104 2018/11/05 00:43:30 mrg Exp $"); | | 41 | __RCSID("$NetBSD: kvm.c,v 1.105 2020/03/08 00:06:42 chs Exp $"); |
42 | #endif | | 42 | #endif |
43 | #endif /* LIBC_SCCS and not lint */ | | 43 | #endif /* LIBC_SCCS and not lint */ |
44 | | | 44 | |
45 | #include <sys/param.h> | | 45 | #include <sys/param.h> |
46 | #include <sys/lwp.h> | | 46 | #include <sys/lwp.h> |
47 | #include <sys/proc.h> | | 47 | #include <sys/proc.h> |
48 | #include <sys/ioctl.h> | | 48 | #include <sys/ioctl.h> |
49 | #include <sys/stat.h> | | 49 | #include <sys/stat.h> |
50 | #include <sys/sysctl.h> | | 50 | #include <sys/sysctl.h> |
51 | | | 51 | |
52 | #include <sys/core.h> | | 52 | #include <sys/core.h> |
53 | #include <sys/exec.h> | | 53 | #include <sys/exec.h> |
54 | #include <sys/kcore.h> | | 54 | #include <sys/kcore.h> |
| @@ -342,27 +342,32 @@ _kvm_open(kvm_t *kd, const char *uf, con | | | @@ -342,27 +342,32 @@ _kvm_open(kvm_t *kd, const char *uf, con |
342 | if ((kd->vmfd = open(_PATH_KMEM, flag | O_CLOEXEC, 0)) < 0) { | | 342 | if ((kd->vmfd = open(_PATH_KMEM, flag | O_CLOEXEC, 0)) < 0) { |
343 | _kvm_syserr(kd, kd->program, "%s", _PATH_KMEM); | | 343 | _kvm_syserr(kd, kd->program, "%s", _PATH_KMEM); |
344 | goto failed; | | 344 | goto failed; |
345 | } | | 345 | } |
346 | kd->alive = KVM_ALIVE_FILES; | | 346 | kd->alive = KVM_ALIVE_FILES; |
347 | if ((kd->swfd = open(sf, flag | O_CLOEXEC, 0)) < 0) { | | 347 | if ((kd->swfd = open(sf, flag | O_CLOEXEC, 0)) < 0) { |
348 | if (errno != ENXIO) { | | 348 | if (errno != ENXIO) { |
349 | _kvm_syserr(kd, kd->program, "%s", sf); | | 349 | _kvm_syserr(kd, kd->program, "%s", sf); |
350 | goto failed; | | 350 | goto failed; |
351 | } | | 351 | } |
352 | /* swap is not configured? not fatal */ | | 352 | /* swap is not configured? not fatal */ |
353 | } | | 353 | } |
354 | } else { | | 354 | } else { |
355 | kd->fdalign = DEV_BSIZE; /* XXX */ | | 355 | if (S_ISCHR(st.st_mode)) { |
| | | 356 | kd->fdalign = DEV_BSIZE; |
| | | 357 | } else { |
| | | 358 | kd->fdalign = 1; |
| | | 359 | } |
| | | 360 | |
356 | /* | | 361 | /* |
357 | * This is a crash dump. | | 362 | * This is a crash dump. |
358 | * Initialize the virtual address translation machinery. | | 363 | * Initialize the virtual address translation machinery. |
359 | * | | 364 | * |
360 | * If there is no valid core header, fail silently here. | | 365 | * If there is no valid core header, fail silently here. |
361 | * The address translations however will fail without | | 366 | * The address translations however will fail without |
362 | * header. Things can be made to run by calling | | 367 | * header. Things can be made to run by calling |
363 | * kvm_dump_mkheader() before doing any translation. | | 368 | * kvm_dump_mkheader() before doing any translation. |
364 | */ | | 369 | */ |
365 | if (_kvm_get_header(kd) == 0) { | | 370 | if (_kvm_get_header(kd) == 0) { |
366 | if (_kvm_initvtop(kd) < 0) | | 371 | if (_kvm_initvtop(kd) < 0) |
367 | goto failed; | | 372 | goto failed; |
368 | } | | 373 | } |