Structures involved are like the following. struct node { int a; int b; }
struct ioctl_node {
struct node **ptr;
int count; //Stores the no of pointers this ptr is pointing to.
};
In user space, I have populated a structure of ioctl_node with count = 3.
And ptr[0] and ptr[2] is pointing to two structs of type node, whereas ptr[1] is NULL. I want this to be passed to kernel.
I have issued ioctl call to pass this info from user space to kernel space.
I did the following in kernel space.
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;
I then did, copy_from_user(&tmp, k_node.ptr, sizeof(struct node *) and this call is also returning success.
But, I am having difficulty, in copying the full contents of **ptr properly in kernel space.
Can anybody plese help, how can I be able to do that. How should I do the next copy_from_user to copy all the contents. I tried, but its giving copy error.