Messages in this thread | | | Date | Mon, 24 Aug 1998 11:39:46 +0700 | From | Alex Riedel <> | Subject | Re: Bug in kernel or libc !? |
| |
<HTML> Marc Slemko wrote: <BLOCKQUOTE TYPE=CITE>Why do you think there is any bug?
<P>[...] <BR> bank = fopen("test","r+");
<P>You open a file using stdio.
<P> fseek(bank,0L,0); <BR> fread(buf,512,1,bank); <BR> fseek(bank,0L,0);
<P>You read the data from it then to back to the start.
<P> //fflush(bank); //uncoment this for bugfix
<P> ftruncate( fileno(bank), 0 );</BLOCKQUOTE> fseek(bank,0L,0); //back to the startfwrite(buf,512,1,bank); //i write data to start <BR>//hier file test is 512 bytes len. <BR>lseek(fileno(bank),0L,2); //go to the end <BR>//after lseek file test truncated.
<P>On Solaris without "fflush" this works fine. <BR>This is not my program. I just ported this prog. from Solaris to Linux. <BLOCKQUOTE TYPE=CITE>
<P>You do something bad by improperly using stdio; before you can do anything <BR>with fileno() you need to fflush the stream. The Solaris man page for <BR>stdio has a reasonable discussion of this.</BLOCKQUOTE> This is feature? or bug? <BLOCKQUOTE TYPE=CITE>
<P>Any behaviour now is undefined because you are mixing stdio and non-stdio <BR>on the same descriptor without proper caution.
<P>- <BR>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in <BR>the body of a message to majordomo@vger.rutgers.edu <BR>Please read the FAQ at <A HREF="http://www.altern.org/andrebalsa/doc/lkml-faq.html">http://www.altern.org/andrebalsa/doc/lkml-faq.html</A></BLOCKQUOTE> <PRE>--
Alex Riedel</PRE> </HTML>
| |