Bug 65055

Summary: stat on fifo always returns st_size=0, but worked in previous versions
Product: [Retired] Red Hat Linux Reporter: Doug Bolling <ddjbolling>
Component: kernelAssignee: Arjan van de Ven <arjanv>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: bbrock, pedro.pascual
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-06-27 22:25:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Doug Bolling 2002-05-16 20:12:41 UTC
Description of Problem:

Executing fstat on a named pipe (fifo) always returns 0 when running Linux 
version 2.4.7-10 ( RedHat 7.2 ).  Under Linux version 2.2.17-14 ( RedHat 7.0 ), 
the same fstat always returned the correct number of unread bytes in the fifo.

Version-Release number of selected component (if applicable):

kernel version 2.4.7-10

How Reproducible:

Here is the source code necessary to reproduce

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

int main( int ac, char * av[] )
{
        struct stat     s;

        sleep( 5 );

        fstat( 0, &s);
        printf( "bytes:%u\n", s.st_size );
}


Steps to Reproduce:
1.  Compile the above source using "gcc -o <filename> <filename>.c"
2.  At a linux prompt, enter %> echo "12345" | ./<filename>
3.  It should print 'bytes:6' when working properly.  
Actual Results:

bytes:0

Expected Results:

bytes:6

Additional Information:

You can also change the string length in the echo to get different values when 
running on the older version of linux mentioned above.  

Bug #60395 actually described the same problem, but provided a bogus 
explanation as to the cause of the problem.  The information we get from this 
test program is that the stat always returns correct sizes on previous versions 
of Linux, not random values as the developer stated in bug #60395.  If the 
statements in bug #60395 are supposed to be accurate, how in the world do you 
get the number of unread bytes in the fifo before doing the actual read???