Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libkvm make kvm_pread use the mapped buffer if it is ava...



details:   https://anonhg.NetBSD.org/src/rev/de3d3ea130bf
branches:  trunk
changeset: 931635:de3d3ea130bf
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Apr 28 00:19:23 2020 +0000

description:
make kvm_pread use the mapped buffer if it is available.

diffstat:

 lib/libkvm/kvm.c |  13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r 77ab40cb455c -r de3d3ea130bf lib/libkvm/kvm.c
--- a/lib/libkvm/kvm.c  Tue Apr 28 00:12:01 2020 +0000
+++ b/lib/libkvm/kvm.c  Tue Apr 28 00:19:23 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kvm.c,v 1.106 2020/04/28 00:12:01 christos Exp $       */
+/*     $NetBSD: kvm.c,v 1.107 2020/04/28 00:19:23 christos Exp $       */
 
 /*-
  * Copyright (c) 1989, 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)kvm.c      8.2 (Berkeley) 2/13/94";
 #else
-__RCSID("$NetBSD: kvm.c,v 1.106 2020/04/28 00:12:01 christos Exp $");
+__RCSID("$NetBSD: kvm.c,v 1.107 2020/04/28 00:19:23 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -177,6 +177,15 @@
        ssize_t rv;
        off_t doff;
 
+       if (kd->dump_mem != MAP_FAILED) {
+               if (size + off > kd->dump_size) {
+                       errno = EINVAL;
+                       return -1;
+               }
+               memcpy(buf, (char *)kd->dump_mem + off, size);
+               return size;
+       }
+
        /* If aligned nothing to do. */
        if (((off % kd->fdalign) | (size % kd->fdalign)) == 0) {
                return pread(fd, buf, size, off);



Home | Main Index | Thread Index | Old Index