lkml.org 
[lkml]   [1998]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Bug in kernel or libc !?
<HTML>
Marc Slemko wrote:
<BLOCKQUOTE TYPE=CITE>Why do you think there is any bug?

<P>[...]
<BR>&nbsp;bank = fopen("test","r+");

<P>You open a file using stdio.

<P>&nbsp;fseek(bank,0L,0);
<BR>&nbsp;fread(buf,512,1,bank);
<BR>&nbsp;fseek(bank,0L,0);

<P>You read the data from it then to back to the start.

<P>&nbsp;//fflush(bank); //uncoment this for bugfix

<P>&nbsp;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>&nbsp;

<P>You do something bad by improperly using stdio; before you can do anything
<BR>with fileno() you need to fflush the stream.&nbsp; The Solaris man
page for
<BR>stdio has a reasonable discussion of this.</BLOCKQUOTE>
This is feature? or bug?
<BLOCKQUOTE TYPE=CITE>&nbsp;

<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>
&nbsp;
<PRE>--&nbsp;

Alex Riedel</PRE>
&nbsp;</HTML>
\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.035 / U:1.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site