问题
I'm working on a linux project. I need to pass a linked list to the kernel from a userspace program. I have used the kernel way of implementing linked lists in userspace. I have defined a structure as follows:
struct time{
int val;
struct list_head* list;
};
The variable for this strucure would be:
struct time mylist;
I have given the input data and used list_add function found in linux/include/list.h to link the structures. This mylist is a part of another structure:
struct params{
int data1;
struct time* mylist;
};
Suppose I get all the data and store it in,
struct params param;
Now if I pass ¶m
to a system call, and use copy_from_user()
function there, will I be able to access the list ? I read that I cannot dereference a pointer in kernel space (which points to a data in userspace) and that I'll have to use copy_from_user
function again in Linux Kernel: copy_from_user - struct with pointers. Could anyone suggest me a possible way of passing this list to the kernel space ?
来源:https://stackoverflow.com/questions/24408888/passing-linked-list-via-copy-from-user