passing string parameter to module - Linux

This is a discussion on passing string parameter to module - Linux ; Hello, I faced a problem passing a string argument to module as parameter of 'insmod'. Let's say, I have the following bit of code (kernel 2.4.18): #define __KERNEL__ #define MODULE #include #include #include static char mac[18]; MODULE_PARM(mac, "c18"); static int ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: passing string parameter to module

  1. passing string parameter to module

    Hello,

    I faced a problem passing a string argument to module as parameter of
    'insmod'. Let's say, I have the following bit of code (kernel 2.4.18):

    #define __KERNEL__
    #define MODULE

    #include
    #include
    #include

    static char mac[18];

    MODULE_PARM(mac, "c18");

    static int __init probe_init(void)
    {
    printk(KERN_ALERT "mac=, %18s\n", mac);
    return 0;
    }

    static void __exit probe_exit(void)
    {
    /* unregister facilities */
    }

    module_init(probe_init);
    module_exit(probe_exit);
    ....

    I compiled the module with the following flags:

    #gcc -W -Wall -I/usr/src/linux-2.4.18-14/include/ -c probe.c -o probe.o

    and load it:

    #insmod probe.o mac=00:00:11:11:22:22
    probe.o: string too long for mac (max 17)

    Where is the problem? I guess 18 is more then enough for storing MAC address
    and terminating NULL.

    Thanks in advance for help.

    With best regards, Roman Mashak. E-mail: mrv@tusur.ru



  2. Re: passing string parameter to module

    In article , Roman Mashak wrote:

    >Where is the problem? I guess 18 is more then enough for storing MAC address
    >and terminating NULL.


    Did you try making it bigger?

    --
    http://www.spinics.net/lists/

  3. Re: passing string parameter to module

    Hello, ellis@no.spam!
    You wrote on Mon, 08 Jan 2007 07:20:15 -0000:

    ??>> Where is the problem? I guess 18 is more then enough for storing MAC
    ??>> address and terminating NULL.

    e> Did you try making it bigger?
    Yes, I tried 19 and it worked out. I'm confused because all example codes I
    followed used 18 for MAC address length.

    With best regards, Roman Mashak. E-mail: mrv@tusur.ru



+ Reply to Thread