summaryrefslogtreecommitdiffstats
path: root/lib/libc/db
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-03-28 06:05:53 +0000
committerdelphij <delphij@FreeBSD.org>2009-03-28 06:05:53 +0000
commitf7cf5b5c6b97a7dd0ef0fde271a9e196d96f601c (patch)
tree95e580a5840acc0c1a9a3e1476529dc1a7c6f0dc /lib/libc/db
parent13f44a2a242d0a0c1ccb45ecb1ffdee19a0c6f8a (diff)
downloadFreeBSD-src-f7cf5b5c6b97a7dd0ef0fde271a9e196d96f601c.zip
FreeBSD-src-f7cf5b5c6b97a7dd0ef0fde271a9e196d96f601c.tar.gz
Use pread(2) and pwrite(2) instead of lseek(2) + read(2) / write(2).
Obtained from: NetBSD via OpenBSD
Diffstat (limited to 'lib/libc/db')
-rw-r--r--lib/libc/db/hash/hash.c3
-rw-r--r--lib/libc/db/hash/hash_page.c6
2 files changed, 3 insertions, 6 deletions
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c
index 263c1b0..4cd6fc3 100644
--- a/lib/libc/db/hash/hash.c
+++ b/lib/libc/db/hash/hash.c
@@ -495,8 +495,7 @@ flush_meta(HTAB *hashp)
whdrp = &whdr;
swap_header_copy(&hashp->hdr, whdrp);
#endif
- if ((lseek(fp, (off_t)0, SEEK_SET) == -1) ||
- ((wsize = _write(fp, whdrp, sizeof(HASHHDR))) == -1))
+ if ((wsize = pwrite(fp, whdrp, sizeof(HASHHDR), (off_t)0)) == -1)
return (-1);
else
if (wsize != sizeof(HASHHDR)) {
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c
index 6ca2826..d564613 100644
--- a/lib/libc/db/hash/hash_page.c
+++ b/lib/libc/db/hash/hash_page.c
@@ -520,8 +520,7 @@ __get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk,
page = BUCKET_TO_PAGE(bucket);
else
page = OADDR_TO_PAGE(bucket);
- if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) ||
- ((rsize = _read(fd, p, size)) == -1))
+ if ((rsize = pread(fd, p, size, (off_t)page << hashp->BSHIFT)) == -1)
return (-1);
bp = (u_int16_t *)p;
if (!rsize)
@@ -587,8 +586,7 @@ __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
page = BUCKET_TO_PAGE(bucket);
else
page = OADDR_TO_PAGE(bucket);
- if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) ||
- ((wsize = _write(fd, p, size)) == -1))
+ if ((wsize = pwrite(fd, p, size, (off_t)page << hashp->BSHIFT)) == -1)
/* Errno is set */
return (-1);
if (wsize != size) {
OpenPOWER on IntegriCloud