From owner-freebsd-hackers Mon Nov 22 12:42:15 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mta3.rcsntx.swbell.net (mta3.rcsntx.swbell.net [151.164.30.27]) by hub.freebsd.org (Postfix) with ESMTP id CDD2615375 for ; Mon, 22 Nov 1999 12:42:01 -0800 (PST) (envelope-from chris@holly.dyndns.org) Received: from holly.dyndns.org ([216.62.157.60]) by mta3.rcsntx.swbell.net (Sun Internet Mail Server sims.3.5.1999.09.16.21.57.p8) with ESMTP id <0FLM00BD59FC9K@mta3.rcsntx.swbell.net> for freebsd-hackers@FreeBSD.ORG; Mon, 22 Nov 1999 14:40:24 -0600 (CST) Received: (from chris@localhost) by holly.dyndns.org (8.9.3/8.9.3) id OAA84070; Mon, 22 Nov 1999 14:41:16 -0600 (CST envelope-from chris) X-URL: http://www.FreeBSD.org/~chris/ Date: Mon, 22 Nov 1999 14:41:15 -0600 From: Chris Costello Subject: Re: A file with holes - a bug? In-reply-to: To: Zhihui Zhang Cc: freebsd-hackers@FreeBSD.ORG Reply-To: chris@calldei.com Message-id: <19991122144115.L78478@holly.calldei.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii User-Agent: Mutt/0.96.4i X-Operating-System: FreeBSD 4.0-CURRENT (i386) References: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Nov 22, 1999, Zhihui Zhang wrote: > lseek(fileno(fp), 3 * 8192, SEEK_CUR); > If I remove the fflush(fp), then the characters 0x30-0x39 will be all > written at the end of the file (use hexdump to find out), not as expected > (one at the beginning and the other at the end). It seems to me that the > first for loop happens AFTER the lseek() statement without fflush(). Can > anyone explain this to me? I am using FreeBSD 3.3-Release. That line (as quoted) where you use lseek is broken. Use fseek instead. Use only one method to access files. Either stdio or the open/read/write syscalls. -- |Chris Costello |If a group of N persons implements a COBOL compiler, there will be N-1 |passes. Someone in the group has to be the manager. -- T. Cheatham `---------------------------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message