Skip to contentSkip to conversation

Confused about create_proc_entry

DISCUSSION RuoMu Hu 1 participant 2 messages Jun 7, 2008 – Jun 8, 2008 1 message not in the archive VFS

lore
Share & tools
lore

RuoMu Hu

author
#0 lore raw

Hi!

I'm writing a kernel module to add a file under /proc/sys/kernel, but alway fail to create_proc_entry "sys/kernel/test".

I found that in proc_create() in fs/proc/generic.c (2.6.25.4):

/* At this point there must not be any '/' characters beyond *fn */

       if (strchr(fn, '/'))
               goto out;

So you cannot create_proc_entry with a name containing "/", but acturally create_proc_entry with "sysvipc/test" succeeds, and there are much other codes in the kernel that do this, e.g.:

fs/nfsd/nfsctl.c:        entry = create_proc_entry("fs/nfs/exports", 0, NULL);
fs/proc/proc_tty.c:    create_proc_read_entry("tty/ldiscs", 0, NULL, tty_ldiscs_read_proc, NULL);

I got pretty confused. Any idea? and is it possible to create a file in /proc/sys/kernel ? How?

Thanks!
Romu

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#2 lore raw
Quoted 4 lines · Narendra Prasad Madanapalli

Hi Romu,

I have done small research on the same problem and the details are as follows:
1. Before registering a file into /proc/sys/ you want to add the file entry details in <linux-kernel-ver>/kernel/sysctl_check.c

What do you mean by "registering a file"? By create_proc_entry() or register_sysctl_table()?

Another question: Is it possible to add an entry in /proc/sys/kernel by register_sysctl_table() without adding an entry to the kern_table[] array in kernel/sysctl.c?

Your research really helped. Thanks.

Best regards,
Romu