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が呼び出されるたびにターミナルからテストファイルを実行すると、出力が作業中のターミナルに出力されますか?