Re: getting more that 4K out of a proc file? [PATCH]

From: Rusty Russell (rusty@linuxcare.com.au)
Date: Sun Feb 13 2000 - 20:09:10 EST


In message <200002131849.TAA11136@oboe.it.uc3m.es> you write:
> "A month of sundays ago Mike Galbraith wrote:"
> > That section of code is beautiful if you're reading an array :)
>
> No it's not. Out of annoyance at its obscurantism I've spent a few
> hours un-obscuring it. As far as I can see, there are three main modes
> of use of that code, all but one undocumented. There might be six
> modes. Can you look over the patch below and make sure that it
> preserves the functionality exactly? I didn't make semantic changes.
> Only comments and restructuring, and abstraction (reverse engineering)
> to make the modes explicit by putting in variables "style" and "mode"
> that control them.

Hi Peter,

        I put the startpos hack in originally (as shown in comment):
for reading firewall rules (which can be variable length), I wanted to
store the rule *number* in the file offset, not the number of bytes
offset, but didn't want to hack the internal proc interface. I didn't
try to use it to read > 3k.

        The current proc system is a crock of shit: unless you use it
for a single variable per file (the trivial case) it's hopeless.
Also, it's messy as all hell (as you've pointed out).

        Think about it: the very concept of `human readable' output by
the kernel is flawed. What language do humans speak? There isn't
much motiviation to try to fix something that isn't really fixable.

        That's why iptables ran screaming back to getsockopt()
(eg. you can't get a snapshot of firewall counters in 2.2 without
stopping all networking first).

Shit, did I just reopen the /proc wars? Sorry...
Rusty.
PS. I apologize if I broke the Kernel Code of Conduct by saying `shit'
    above. I don't know what the fuck came over me.

--
Hacking time.

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



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:26 EST