From 16839accd25390c4a4eacbb59c2d098888d2d4b6 Mon Sep 17 00:00:00 2001 From: das Date: Tue, 20 Jan 2004 00:40:35 +0000 Subject: [PATCH] Simplify mpool_get() and mpool_write() by using pread() and pwrite() instead of lseek()/_read() and lseek()/_write(). PR: bin/54276 Submitted by: --- lib/libc/db/mpool/mpool.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c index 698fa8a52a0c..e3af051ccfab 100644 --- a/lib/libc/db/mpool/mpool.c +++ b/lib/libc/db/mpool/mpool.c @@ -207,9 +207,8 @@ mpool_get(mp, pgno, flags) ++mp->pageread; #endif off = mp->pagesize * pgno; - if (lseek(mp->fd, off, SEEK_SET) != off) - return (NULL); - if ((nr = _read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) { + nr = pread(mp->fd, bp->page, mp->pagesize, off); + if (nr != mp->pagesize) { if (nr >= 0) errno = EFTYPE; return (NULL); @@ -381,9 +380,7 @@ mpool_write(mp, bp) (mp->pgout)(mp->pgcookie, bp->pgno, bp->page); off = mp->pagesize * bp->pgno; - if (lseek(mp->fd, off, SEEK_SET) != off) - return (RET_ERROR); - if (_write(mp->fd, bp->page, mp->pagesize) != mp->pagesize) + if (pwrite(mp->fd, bp->page, mp->pagesize, off) != mp->pagesize) return (RET_ERROR); bp->flags &= ~MPOOL_DIRTY;