[Toybox] Entering the home stretch on ifconfig...

Rob Landley rob at landley.net
Mon Jun 10 21:10:04 PDT 2013


On 06/10/2013 04:39:55 AM, Bastian Bittorf wrote:
> * Rob Landley <rob at landley.net> [10.06.2013 11:26]:
> > On 06/07/2013 01:11:50 AM, Bastian Bittorf wrote:
> > >* Rob Landley <rob at landley.net> [07.06.2013 07:57]:
> > >> It looks like show_iface() enumerates /proc/net/dev and then  
> calls
> > >> readconf() to do ioctl() based enumeration. The /proc one gives
> > >us RX
> > >> bytes and such, the ioctl gives us a "virtual interface" (ala  
> lo:0 I
> > >
> > >dont use the deprecated one, but /sys/class/net/
> > >or even "better" via netlink.
> >
> > I didn't write this code, I'm just cleaning it up. Patches welcome.
> >
> > Where is it deprecated? Documentation/filesystems/proc.txt currently
> > says (line 1029):
> 
> [...]
> 
> true...seems to be an "unwritten law". at least
> https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
> says: "_The_ filesystem for exporting kernel objects."

The reason that's unwritten is it's not true.

Yes, sysfs started as a way to export kobjects (note that kobject was a  
structure introduced with the new driver model in 2.4, and not  
everything in the kernel was a kobject). But /proc predates it by many  
years, and has numerous important exports added before sysfs existed.

At a design level, they can't make /proc go away without making "ps" go  
away, because the original reason for proc (which it's still good at)  
is /proc/$PID directories. So you can't have a complete system without  
/proc mounted: a subset of what /proc does is things /proc is very good  
at. (Exporting the process list was its original job.)

Beyond that, proc was the first synthetic filesystem and for years was  
the only place to add things like /proc/mounts. Those exports are A)  
already there, B) not in the one-file-one-value format sysfs exports.  
Maybe these days days the'd create a /dev node for the  
kernel-maintained mtab or have devtmpfs export a magic file, but they  
already did this and the one we have works fine.

In theory, /proc/$PID, /proc/sys, and the rest of proc could be broken  
into 3 filesystems and union mounted together (I suggested this years  
ago), but union mounts remain slow to merge (even though we're FINALLY  
getting some progress) and it turns out breaking up the hairball just  
to glue it back together doesn't actually improve matters. In practice  
/proc/filesystems and /proc/meminfo and /proc/modules and such are  
working existing exports that do their job just fine and aren't going  
anywhere. There's a moratorium on adding _more_ of them (since libfs  
made creating new filesystems easy, see https://lwn.net/Articles/57369/  
for historical notes) but gratuitously moving /proc/version to sysfs  
wouldn't serve any purpose.

tl;dr version: "it's in /proc" doesn't mean "it's obsolete".

Rob


More information about the Toybox mailing list