Simplify mpool_get() and mpool_write() by using pread() and pwrite()

instead of lseek()/_read() and lseek()/_write().

PR:		bin/54276
Submitted by:	<dnelson@allantgroup.com>
This commit is contained in:
das 2004-01-20 00:40:35 +00:00
parent 43a6cd5e20
commit 16839accd2

View File

@ -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;