我正在尝试向 Linux 添加一些东西task_struct
。
在这个区域中,我从用户那里复制了一个字符串并尝试将它存储在我的结构中。
我尝试通过添加printk
将打印复制的字符串来调试我的代码。
这是代码的调试部分:
newTODO->TODO_description=(char*)(kmalloc(in_description_size+1,0));
if( newTODO->TODO_description){
kfree(newTODO);
return -1;
}
res=copy_from_user(newTODO->TODO_description, in_TODO_description, in_description_size);
if (res) // error copying from user space, 1 or more char werent copied.
{
printk(KERN_ALERT "function: create element failed to copy from user\n");
return -EFAULT;
}
newTODO->TODO_description[in_description_size]='\o';
printk(KERN_ALERT "the copied string is: %s \n",newTODO->TODO_description);
对我来说必须重要的印刷品是
printk(KERN_ALERT "the copied string is: %s \n",newTODO->TODO_description);
它会起作用吗?
了解 printk:
每当调用 printk 时,我什么时候从终端运行我的测试文件,它会将输出打印到工作终端?