Date: Thu, 8 Apr 1999 14:34:34 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Michel de Ruiter cc: "'DJGPP workers'" Subject: RE: fflush question In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Thu, 8 Apr 1999, Michel de Ruiter wrote: > > DOS/Windows do this as well--mostly. The problem you bumped into is a > > very subtle case: > > Which is why nobody encountered it as a problem, I guess. I did ;-). When I was porting Tar, I found out that a feature whereby Tar detects that somebody is trying to put the archive being created into the archive itself doesn't work, because it was relying on the inode number. Now, you might know that in plain DOS the inode returned by the DJGPP implementation of `fstat' is the starting cluster number of the file. The problem: an empty file doesn't have any clusters allocated, so its inode is not the real one. The solution: write a few bytes to the file and fsync the handle, before calling `fstat'. > BTW, should fflush be corrected for this bug, as DJ suggested? I don't know. I asked Alain Magloire about a related issue in another thread (the one about fflush(stdin)). I also asked people to try your test program on Unix and see if it works on all its flavors. I want to see the answers before I make up my mind, and I hope others will tell what they think as well.