如何在内核模式下将char *转换为char []

时间:2013-10-25 22:24:29

标签: linux-kernel kernel

这是我的linux内核代码     当我尝试将char * name的val设置为我的struct中的字段时,我得到null     stuct中的值始终为null,但是如果我明确设置person-> key_day =“11”;我没有得到空值。我想以某种方式从char * day和char * name获取值,分配给person-> key_day和person-> value_name。请帮助

     typedef struct _birthday {
     char *key_day;
     char *value_name;
        struct list_head list;
    }birthday;

    birthday *person;

    /* Declare and init the head of the linked list. */

    LIST_HEAD(birthday_list);

    void mymap(char *day , char *name)
    {

            /* Request malloc to the kernel. */
            person = kmalloc(sizeof(*person), GFP_KERNEL);

            /* Assign value to the struct. */
            person->key_day =  day;
            person->value_name = name;

            /* Init the list within the struct. */
            INIT_LIST_HEAD(&person->list);

            /* Add this struct to the tail of the list. */
            list_add_tail(&person->list, &birthday_list);

            //This print statement gives me null value.
            printk("\n New Entry %s , %s" , person->key_day , person->value_name );
    }

0 个答案:

没有答案