/proc cleanup proposal

From: jmcmullan@linuxcare.com
Date: Tue Mar 07 2000 - 10:52:34 EST


  Having seen the big /proc vs /devfs cleanup shenangins, I've got a
silly idea - why not name this new kernel Linux 3.0? I mean, with
/devfs, there's a whole lot of change going on, we've got
(one.... MORE... TIME!!!) a new IP filtering system, the USB stuff,
new resource management, SoftNet, the new Block I/O substructure, etc.

  With a major number change, we can blow away the current /proc
structure, and replace it with something that works...

  Just off the top of my head, I'd like to see this major stucture
(names can be changed if needed, it's the structure that counts)

  If this sounds like a good idea, and people would like it, I'll
start working on a patch. If not, there's always 2.5.x...

        /proc/self Pointer to self process
        /proc/process/{0,1,34,55,3232,etc.}/* Pre-process data

        /proc/hardware Hardware related status (busses, drivers, etc)

        /proc/hardware/bus/{isa,pci,scsi,etc.} Busses
        /proc/hardware/bus/pci/0/status Textual status
        /proc/hardware/bus/pci/0/sys/* Bus single-value ctrl

        /proc/hardware/driver/{ne,aic7xxx,etc.} Drivers
        /proc/hardware/driver/ne/1/status Textual status
        /proc/hardware/driver/ne/1/sys/* Driver single-value ctrl

        /proc/hardware/status/{irq,dma,ioports,etc.} Stats

        /proc/kernel/ Linux kernel related items
        /proc/kernel/vm/{kmalloc,slab,etc.}/{status,sys} Virtual memory
        /proc/kernel/net/{ipv4,ipx,etc.}/{status,sys} Network
        /proc/kernel/tty/{ppp,tty,etc.}/{status,sys} TTY line disciplines
        /proc/kernel/fs/{nfs,ext2,etc.}/{status,sys} Filesystems
        etc..

And would use calls like:

....init_module...
 procpci=proc_hardware_bus_create("pci");
 proc_hardware_bus_add(procpci,PROC_SYSCTL,PROC_TYPE_INT,0,&pci_io_latency,
                                                "pci-io-latency","PCI io latency");
 proc_hardware_bus_add(procpci,PROC_SYSCTL,PROC_TYPE_INT,4,pci_irq_order,
                                                "pci-irq-order","PCI irq order");
 proc_hardware_bus_add(procpci,PROC_STATUS,PROC_TYPE_STRING,0,pci_chipset,
                                                "pci-chipset-name","PCI chipset name");
 proc_hardware_bus_add(procpci,PROC_STATUS,PROC_TYPE_HEX_INT,0,pci_chipset_id,
                                                "pci-chipset-id","PCI chipset id");
 ...

....cleanup_module....
 proc_hardware_bus_unlink(procpci);
....

          A similar set of routines for the kernel...

        All PROC_SYSCTL values would be single files in /proc/*/sys, and
the PROC_STATUS values would be read-only from /proc/*/status. /proc/*/status
will also contain the PROC_SYSCTL values, for easy reference.

        All /proc/*/status files would be formatted like the following
tab-delimited file:

$ cat /proc/hardware/bus/pci/0/status
#name value type len comment
pci-io-latency 10 int - PCI io latency
pci-irq-order 9,10,11,12 int 4 PCI io latency
pci-chipset-name 440lx string - PCI chipset name
pci-chipset-id 0x6723 int - PCI chipset id
....

        All /proc/*/sys files would be formatted like the following
typescript illustrates, and would be named as <name>,<type>,<len>
such that if the type (or length of an array) changes, referring
programs will break instantly (leading to fixes :^)

----------- Singlevalue --------------
$ cat /proc/hardware/bus/pci/0/sys/pci-io-latency,int,-
10

$ echo 0x20 >/proc/hardware/bus/pci/0/sys/pci-io-latency,int,-
$ cat /proc/hardware/bus/pci/0/sys/pci-io-latency,int,-
32

$ echo 20 >/proc/hardware/bus/pci/0/sys/pci-io-latency,int,-
$ cat /proc/hardware/bus/pci/0/sys/pci-io-latency,int,-
20
 
$ echo 020 >/proc/hardware/bus/pci/0/sys/pci-io-latency,int,-
$ cat /proc/hardware/bus/pci/0/sys/pci-io-latency,int,-
16

$ echo HiThere >/proc/hardware/bus/pci/0/sys/pci-io-latency,int,-
bash: /proc/hardware/bus/pci/0/sys/pci-io-latency,int,-: Invalid argument
$ cat /proc/hardware/bus/pci/0/sys/pci-io-latency,int,-
16

------------ Multivalue -------------
$ cat /proc/hardware/bus/pci/0/sys/pci-irq-order,int,4
9 10 11 12

$ echo 7 5 12 11>/proc/hardware/bus/pci/0/sys/pci-irq-order,int,4
$ cat /proc/hardware/bus/pci/0/sys/pci-irq-order,int,4
7 5 12 11

                --- Not enough data ----
$ echo 10 11>/proc/hardware/bus/pci/0/sys/pci-irq-order,int,4
bash: /proc/hardware/bus/pci/0/sys/pci-irq-order,int,4: Invalid argument

                --- Too much data ----
$ echo 10 11 7 5 12>/proc/hardware/bus/pci/0/sys/pci-irq-order,int,4
bash: /proc/hardware/bus/pci/0/sys/pci-irq-order,int,4: Invalid argument

-- 
Jason McMullan, Senior Linux Consultant, Linuxcare, Inc.
412.422.8077 tel, 415.701.0792 fax
jmcmullan@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.

- 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 Mar 07 2000 - 21:00:22 EST