I am attempting to add a system call to my linux kernel and it would be advantageous to use the built-in linked list as I am modifying the task_struct (by adding a linked list), and the task_struct already has quite a few struct list_head's in there for other purposes. For uniformity, I would like to stick with this data structure.
My issue is that I really don't fully understand how to use this structure. I see that they have "struct list_head children" for example. However, the implementation of this structure is simple a "*next" and "*last".
I've looked into examples online and every single one says, well make
struct node{
int data;
struct list_head list;
};
But wouldn't this indicate that the data structure I should be including in my task_struct should be
struct node list;
?
I don't quite understand how I would initialize the structure to contain the data I would like it to contain if I use list_head.
Essentially I want to add a linked list of system calls and tack them on to the process in the form of a linked list of char* (readable format).
For now, the semantics of obtaining the system call information is unimportant... I just need to figure out how to get the linked list working with the task_struct.
Edit: For example of what I am trying to do:
I've obtained a list of system calls performed by a function. I am keeping these in separate char* variables. I would like to add a list within the processes task_struct that keeps track of all of these system calls.
For example
Process 'abc' calls printf ~> equates to "WriteScreen" getchar ~> equates to "ReadKey"
I now have a userland piece of code that has these two strings. I call a system call that I will write (once per tag) to "tag" the process with these system calls.
After both calls, the task_struct of 'abc' has a list
abc->task_struct->tag_list
This list contains "WriteScreen" and "ReadKey".
Later I will use these tags to print a list of processes that have called WriteScreen, ReadKey, etc. The implementation of these will happen after I find out how to use the list to appropriately store the strings attached to a process.