Question on /proc API & bug in sysctl

eranian@chorus.fr
Wed, 20 Mar 96 10:03:49 MET DST


Dear Linux hacker,

During the last months I have developed a few extra kernel modules involving
addition of entries in /proc. If I have time during April I will release them
to the Linux community. During this development I faced several problems
with the interface provided by the procfs to module developers. I wanted
to easily add entry in /proc (root of the proc filesystem) without modifying
the current kernel sources (same include files, source C source files).

There are mainly two problems :

o Selecting an inode number (without conflict with other entries)

o Attaching the new entry to the filesystem

Looking in the recent sources and especially since the development of the
sysctl interface to /proc, the kernel implements a facility to dynamically
add entries to /proc. The function is proc_register_dynamic(). This function
dynamically selects an inode number using a bitvector. The inode is attached
to the directory provided as argument.

This function is great as long as you develop in-kernel code, now when you
want to use it in a module, you find a big problem. This function is currently
not exported by the kernel (not present in procfs_syms.c). Exporting
this function is not enough, you certainly need to export the proc_root
directory entry if you want to be able to attach your entry in a directory
different from proc_net (/proc/net) or proc_scsi (/proc/scsi).

So my question is as follows:

o Is there is good reason for not exporting these two symbols ?

If there is no reason , please do export them in the next kernel
patch (I may be able to send the patch to Linus).

I as personally applied a corresponding patch, and it works well.

regards,

PS:
While looking at the code of the sysctl in /proc I found several
problems. The interface provided is buggy. By this I mean that it
does not respect the interface for file access. There should be
no difference between accessing a normal file in an ext2 filesystem
(for instance) and a file in /proc.

To show the bug, just try to do a simple dd in /proc/sys/kernel/ostype
(for instance):
dd if=/proc/sys/kernel/ostype of=/dev/tty bs=1 skip=3

You will see that whatever skip you provide you will always get
the string from the beginning. THIS IS NOT CORRECT AND DOES NOT
RESPECT THE INTERFACE.

I know this a kind of details but you may come to a problem when
new BIG entries will be added to this directory along with
companion program to display contents.

You may not come to the problem with cat as it uses a 4KB buffer !