【发布时间】:2012-08-26 05:24:36
【问题描述】:
涉及的结构如下所示。 结构节点{ 诠释一个; 诠释 b; }
struct ioctl_node {
struct node **ptr;
int count; //Stores the no of pointers this ptr is pointing to.
};
在用户空间中,我使用count = 3 填充了一个ioctl_node 结构。
而ptr[0] 和ptr[2] 指向两个节点类型的结构,而ptr[1] 是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 来复制所有内容。我试过了,但它给出了复制错误。
【问题讨论】:
-
你不能改变你的规范来复制一个连续的内存区域吗?如果某些内部指针出错,你会怎么做?
标签: c linux linux-kernel