more fun with procfs (netfilter)

From: Alexander Viro (viro@math.psu.edu)
Date: Mon Nov 19 2001 - 02:13:20 EST


% cat /proc/net/ip_conntrack |od -c
0000000 t c p 6 1 2 1 0 7
[snip]
0005137
% od -c </proc/net/ip_conntrack
0000000
% cat /proc/net/ip_tables_names | od -c -w8
0000000 n a t \n f i l t
0000010 e r \n
0000013
% od -c -w8 </proc/net/ip_tables_names
0000000 n a t \n
0000004

Reason: netfilter procfs files try to fit entire records into the user
buffer. Do a read shorter than record size and you've got zero. And
read() returning 0 means you-know-what...

BTW, from strace output in cpuinfo bug report SuSE bash does reads by 128
bytes. Which means that while read i; do echo $i; done </proc/net/ip_conntrack
will come out empty (lots of lines are longer than 160 characters).

I'll try to see if seq_file is suitable there, but in any case something
needs to be done - read() should return 0 _only_ at EOF and 128 bytes
definitely counts as reasonable buffer size.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Nov 23 2001 - 21:00:19 EST