From owner-svn-src-head@FreeBSD.ORG Sat Mar 28 06:05:54 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F4A81065672; Sat, 28 Mar 2009 06:05:54 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D6318FC0C; Sat, 28 Mar 2009 06:05:54 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2S65scL086322; Sat, 28 Mar 2009 06:05:54 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2S65sxf086320; Sat, 28 Mar 2009 06:05:54 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200903280605.n2S65sxf086320@svn.freebsd.org> From: Xin LI Date: Sat, 28 Mar 2009 06:05:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190486 - head/lib/libc/db/hash X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Mar 2009 06:05:54 -0000 Author: delphij Date: Sat Mar 28 06:05:53 2009 New Revision: 190486 URL: http://svn.freebsd.org/changeset/base/190486 Log: Use pread(2) and pwrite(2) instead of lseek(2) + read(2) / write(2). Obtained from: NetBSD via OpenBSD Modified: head/lib/libc/db/hash/hash.c head/lib/libc/db/hash/hash_page.c Modified: head/lib/libc/db/hash/hash.c ============================================================================== --- head/lib/libc/db/hash/hash.c Sat Mar 28 05:57:27 2009 (r190485) +++ head/lib/libc/db/hash/hash.c Sat Mar 28 06:05:53 2009 (r190486) @@ -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)) { Modified: head/lib/libc/db/hash/hash_page.c ============================================================================== --- head/lib/libc/db/hash/hash_page.c Sat Mar 28 05:57:27 2009 (r190485) +++ head/lib/libc/db/hash/hash_page.c Sat Mar 28 06:05:53 2009 (r190486) @@ -520,8 +520,7 @@ __get_page(HTAB *hashp, char *p, u_int32 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 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) {