diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-18 09:08:39 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-18 09:08:39 +0000 |
commit | 87a316979eadfa099f50a4ed7b87a1ccce28a79c (patch) | |
tree | 2406351125f931f916afdbd638ecd09836394905 /lib/libkvm/kvm_proc.c | |
parent | 7455da347fc3acc4d774b691e5a3015a15f0b4aa (diff) |
Convert lseek/{read,write} pairs into pread and pwrite.
from my todo list, work by Jonathon Fletcher <jonathon.fletcher@pobox.com>.
Diffstat (limited to 'lib/libkvm/kvm_proc.c')
-rw-r--r-- | lib/libkvm/kvm_proc.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c index 3f2117d058f..6980f46e1ca 100644 --- a/lib/libkvm/kvm_proc.c +++ b/lib/libkvm/kvm_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc.c,v 1.6 2000/06/18 17:59:54 niklas Exp $ */ +/* $OpenBSD: kvm_proc.c,v 1.7 2001/05/18 09:08:38 art Exp $ */ /* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -77,7 +77,7 @@ #if 0 static char sccsid[] = "@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93"; #else -static char *rcsid = "$OpenBSD: kvm_proc.c,v 1.6 2000/06/18 17:59:54 niklas Exp $"; +static char *rcsid = "$OpenBSD: kvm_proc.c,v 1.7 2001/05/18 09:08:38 art Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -222,19 +222,13 @@ _kvm_uread(kd, p, va, cnt) if (KREAD(kd, addr, &pg)) return NULL; - if (lseek(kd->pmfd, pg.phys_addr, SEEK_SET) < 0) - return NULL; - - if (read(kd->pmfd, (void *)kd->swapspc, (size_t)kd->nbpg) - != kd->nbpg) + if (_kvm_pread(kd, kd->pmfd, (void *)kd->swapspc, (size_t)kd->nbpg, (off_t)pg.phys_addr) != kd->nbpg) { return NULL; + } } else { - if (lseek(kd->swfd, (off_t)(anon.an_swslot * kd->nbpg), - SEEK_SET) < 0) - return NULL; - if (read(kd->swfd, (void *)kd->swapspc, (size_t)kd->nbpg) - != kd->nbpg) + if (_kvm_pread(kd, kd->swfd, (void *)kd->swapspc, (size_t)kd->nbpg, (off_t)(anon.an_swslot * kd->nbpg)) != kd->nbpg) { return NULL; + } } #else @@ -334,10 +328,9 @@ _kvm_readfromcore(kd, object, offset) seekpoint = mem.phys_addr; - if (lseek(kd->pmfd, seekpoint, 0) == -1) - return (-1); - if (read(kd->pmfd, kd->swapspc, kd->nbpg) != kd->nbpg) + if (_kvm_pread(kd, kd->pmfd, kd->swapspc, kd->nbpg, (off_t)seekpoint) != kd->nbpg) { return (-1); + } return (1); } @@ -413,10 +406,9 @@ _kvm_readfrompager(kd, vmop, offset) /* Calculate the physical address and read the page. */ seekpoint = dbtob(swb.swb_block) + (offset & ~(kd->nbpg -1)); - if (lseek(kd->swfd, seekpoint, 0) == -1) - return (-1); - if (read(kd->swfd, kd->swapspc, kd->nbpg) != kd->nbpg) + if (_kvm_pread(kd, kd->swfd, kd->swapspc, kd->nbpg, (off_t)seekpoint) != kd->nbpg) { return (-1); + } return (1); } |