From owner-p4-projects@FreeBSD.ORG Mon Jul 16 12:27:09 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 215B716A403; Mon, 16 Jul 2007 12:27:09 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E85DB16A402 for ; Mon, 16 Jul 2007 12:27:08 +0000 (UTC) (envelope-from gcooper@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id D758C13C4A3 for ; Mon, 16 Jul 2007 12:27:08 +0000 (UTC) (envelope-from gcooper@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6GCR8iD073148 for ; Mon, 16 Jul 2007 12:27:08 GMT (envelope-from gcooper@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6GCR8WB073145 for perforce@freebsd.org; Mon, 16 Jul 2007 12:27:08 GMT (envelope-from gcooper@FreeBSD.org) Date: Mon, 16 Jul 2007 12:27:08 GMT Message-Id: <200707161227.l6GCR8WB073145@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gcooper@FreeBSD.org using -f From: Garrett Cooper To: Perforce Change Reviews Cc: Subject: PERFORCE change 123587 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2007 12:27:09 -0000 http://perforce.freebsd.org/chv.cgi?CH=123587 Change 123587 by gcooper@optimus-revised_pkgtools on 2007/07/16 12:26:44 - Check to make sure read(2) returns the stat'ed file length, instead of a non-(-1) value. - Use write(2) instead of fwrite(2) based on results from my "fat" tool. Hopefully this results in a 30% to 3-fold speedup. Affected files ... .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#8 edit Differences ... ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#8 (text+ko) ==== @@ -223,7 +223,7 @@ contents = (char *)malloc(sb.st_size + 1); - if (read(fileno(fd), contents, sb.st_size) == -1) { + if (read(fileno(fd), contents, sb.st_size) != sb.st_size) { cleanup(0); errx(2, "%s: short read on '%s' - did not get %lld bytes", __func__, fname, (long long)sb.st_size); @@ -280,10 +280,10 @@ errx(2, "%s: cannot fopen '%s' for writing", __func__, name); } len = strlen(str); - if (fwrite(str, 1, len, fp) != len) { + if (write(fileno(fp), str, len) != len) { cleanup(0); - errx(2, "%s: short fwrite on '%s', tried to write %ld bytes", - __func__, name, (long)len); + errx(2, "%s: short fwrite on '%s', tried to write %lld bytes", + __func__, name, (long long)len); } if (fclose(fp)) { cleanup(0);