涉及的结构如下。结构节点 { int a; 诠释 b; }
struct ioctl_node {
struct node **ptr;
int count; //Stores the no of pointers this ptr is pointing to.
};
在用户空间中,我用 .ioctl_node 填充了一个结构count = 3
。And ptr[0]
andptr[2]
指向两个 node 类型的结构体,而ptr[1]
is NULL
. 我希望将其传递给内核。我已发出 ioctl 调用以将此信息从用户空间传递到内核空间。
我在内核空间中做了以下事情。
struct ioctl_node k_node;
copy_from_user(&k_node, arg, sizeof(struct ioctl_node)) //arg is the source
//k_node.count is showing the right value what I have set in the user space.
struct node *tmp = NULL;
然后我做了,copy_from_user(&tmp, k_node.ptr, sizeof(struct node *)
这个电话也成功了。但是,我很难**ptr
在内核空间中正确复制完整内容。任何人都可以帮忙,我怎么能做到这一点。我应该如何执行下一个 copy_from_user 来复制所有内容。我试过了,但它给出了复制错误。