From owner-p4-projects@FreeBSD.ORG Sun Jul 15 21:07:07 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 4EF8416A408; Sun, 15 Jul 2007 21:07:07 +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 103CE16A400; Sun, 15 Jul 2007 21:07:07 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id BED9F13C48D; Sun, 15 Jul 2007 21:07:06 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.13.8/8.13.4) with ESMTP id l6FL6P2U017602; Sun, 15 Jul 2007 15:06:25 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sun, 15 Jul 2007 15:06:29 -0600 (MDT) Message-Id: <20070715.150629.-457441111.imp@bsdimp.com> To: gcooper@freebsd.org From: "M. Warner Losh" In-Reply-To: <200707152008.l6FK8Nr8028280@repoman.freebsd.org> References: <200707152008.l6FK8Nr8028280@repoman.freebsd.org> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Sun, 15 Jul 2007 15:06:25 -0600 (MDT) Cc: perforce@freebsd.org Subject: Re: PERFORCE change 123550 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: Sun, 15 Jul 2007 21:07:07 -0000 In message: <200707152008.l6FK8Nr8028280@repoman.freebsd.org> Garrett Cooper writes: : http://perforce.freebsd.org/chv.cgi?CH=123550 : : Change 123550 by gcooper@optimus-revised_pkgtools on 2007/07/15 20:07:45 : : Quite simply, works with read, but not fread. Or maybe it's just me :)? : : Affected files ... : : .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#4 edit : : Differences ... : : ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#4 (text+ko) ==== : : @@ -223,7 +223,7 @@ : : contents = (char *)malloc(sb.st_size + 1); : : - if ((int) fread(contents, sb.st_size, 1, fd) == FAIL) { : + if (read(fileno(fd), contents, sb.st_size) == FAIL) { : cleanup(0); : errx(2, "%s: short read on '%s' - did not get %lld bytes", __func__, : fname, (long long)sb.st_size); The functions fread() and fwrite() advance the file position indicator for the stream by the number of bytes read or written. They return the number of objects read or written. If an error occurs, or the end-of- file is reached, the return value is a short object count (or zero). vs If successful, the number of bytes actually read is returned. Upon read- ing end-of-file, zero is returned. Otherwise, a -1 is returned and the global variable errno is set to indicate the error. /me guesses FAIL is defined to be -1... Warner