PROBLEM: fstat(2) returns st_size==0 for non-empty FIFO.

Previous thread: [GIT]: Netwokring by David Miller on Tuesday, September 9, 2008 - 4:16 pm. (1 message)

Next thread: [PATCH 1/5] x86: make intel.c has 64bit support code by Yinghai Lu on Tuesday, September 9, 2008 - 4:40 pm. (6 messages)
From: John Wenker
Date: Tuesday, September 9, 2008 - 4:05 pm

A colleague has run into a problem.  We assume it's a kernel issue.  Here 
is the pertinent bug report data.

[1.] One line summary of the problem:
fstat(2) returns st_size == 0 for a FIFO that is known to have data in it.

[2.] Full description of the problem/report:
When using a FIFO, fstat(2) (and stat(2)) returns a 'struct stat' with the 
st_size field equal to zero, at a time when the FIFO is known to have data 
in it.  Problem occurs with Linux 2.6.16 kernel (see more below), but does 
not occur on 2.4.20.

[3.] Keywords (i.e., modules, networking, kernel):
stat, fstat, FIFO, struct stat, st_size, system call, write

[4.] Kernel version (from /proc/version):
Linux version 2.6.16.13-4-default (geeko@buildhost) (gcc version 4.1.0 
(SUSE Linux)) #1 Wed May 3 04:53:23 UTC 2006

Note: Problem does _not_ occur on Linux version 2.4.20-8 
(bhcompile@porky.devel.redhat.com) (gcc version 3.2.2 2003022 (Red Hat 
Linux 3.2.2-5)) #1 Thu Mar 13 17:54:28 EST 2003

[5.] Output of Oops.. message (if applicable) with symbolic information 
     resolved (see Documentation/oops-tracing.txt)
No oops.  Problem doesn't cause system crash, only affects behavior of 
user applications.

[6.] A small shell script or example program which triggers the
     problem (if possible)
I don't know if this qualifies as "small", but there is a 'C' program 
attached that will reproduce the problem (fifo.c).



[7.] Environment
[7.1.] Software (add the output of the ver_linux script here)
See attached file (ver-linux.out).



[7.2.] Processor information (from /proc/cpuinfo):
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 79
model name      : AMD Athlon(tm) 64 Processor 3500+
stepping        : 2
cpu MHz         : 1000.000
cache size      : 512 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
cmov pat pse36 clflush mmx fxsr sse sse2 ...
From: Alejandro Riveira
Date: Wednesday, September 10, 2008 - 2:19 am

El Tue, 9 Sep 2008 16:05:06 -0700

 FWIW
 $ LC_ALL=C ./fifo test
 Enter a string to write into the FIFO: Hello World!        
 fifo: WARNING - 0 (of 14 requested) bytes written into FIFO.
 0 bytes in FIFO.
 $ uname -r                                                                                
--

From: Andreas Schwab
Date: Wednesday, September 10, 2008 - 2:24 am

st_size has no meaning except for regular files and symlinks.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
--

Previous thread: [GIT]: Netwokring by David Miller on Tuesday, September 9, 2008 - 4:16 pm. (1 message)

Next thread: [PATCH 1/5] x86: make intel.c has 64bit support code by Yinghai Lu on Tuesday, September 9, 2008 - 4:40 pm. (6 messages)