Hi Jovi,

/* this is the data variable where we receive the data written by sysctl
interface */
static char event_handler[256];
static struct ctl_table_header *handler_header_table;

static struct ctl_table my_event_table[] = {
    {
        .ctl_name           = KERN_EVENT_HANDLER,        /* this needs to be
defined in linux/sysctl.h */
        .procname           = "event_handler",                         /*
this is the name by which the file will be created in /proc/sys/kernel */
        .data               = &event_handler,
/* data variable */
        .maxlen             = sizeof(event_handler),
        .mode               = 0644,
        .proc_handler       = &proc_dostring,
        .strategy           = &sysctl_string,
    },
    { },
};

static struct ctl_table my_root_table[] = {
    {
        .ctl_name           = CTL_KERN,                           /* create
entry in the /proc/sys/kernel */
        .procname           = "kernel",
        .maxlen             = 0,
        .mode               = 0555,
        .child              = my_event_table,                        /* here
we specify our child table */
    },

    { },
};

static int __init my_handler_init(void)
{
    .................
    .................
    .................
    handler_header_table = register_sysctl_table(my_root_table);
/* register the entry */
    if (!handler_header_table)
        return -ENOMEM;
    .................
    .................
    .................

}

static void __exit my_handler_exit(void)
{
    .................
    .................
    .................
    unregister_sysctl_table(handler_header_table);
    .................
    .................
    .................

}

Thanks and Regards,
Prasad.

On Sat, Aug 9, 2008 at 8:34 AM, Jovi Jia <[EMAIL PROTECTED]> wrote:

> I am really confused by the method of registering a sysctl table.I can
> register it normally on linux-2.4 with the function
> register_sysctl_table(struct ctl_table,int),but failed with
> register_sysctl_table(struct ctl_table) & register_sysctl_paths(struct
> ctl_path,struct ctl_table) on linux-2.6.25.9 with error message:"sysctl
> table check failed, /net/xxx Unknown sysctl binary path".
> in summary,I made the
> struct ctl_path net_ipv4_ctl_path[] = {
>     { .procname = "net", .ctl_name = CTL_NET, },
>     { .procname = "xxx", .ctl_name = an_int, },
>     { },
> };
>
> if any solutions & materials about it are really appreciated!
>

Reply via email to