Skip to content
Advertisement

Add syscalls to linux kernel

I’m new in working with kernel. I want to add a linked list to my kernel, and I try to fix it like this link : Linux Kernel Programming–Linked List

here is code’s that I added to sys.c :

syscall defenition:

SYSCALL_DEFINE1(init_process_list,pid_t,ppid)
{
 LIST_HEAD(processList);
 struct scallNode* newNode;
 newNode = kmalloc(sizeof(*newNode), GFP_KERNEL);
 newNode->ID = ppid;
 INIT_LIST_HEAD(&newNode -> list);
 list_add_tail(&newNode -> list , &processList.list);
 printk(KERN_INFO "INIT PROCESS UID: %un", ppid);
 return 0; 
}

and my struct for linked list:

struct scallNode{
    int ID;
    struct file_struct ffs;
    struct task_struct ts;
    struct list_head list;
};
struct scallNode processList;

and when I compile the kernel, I saw this error:

error: ‘struct list_head’ has no member named ‘list’   list_add_tail(&newNode -> list , &processList.list);

thanks for your replies.

that error disappeared, but another one is still exist.

kernel/sys.c:2136:24: error: field ‘fs’ has incomplete type      struct file_struct fs;

again thanks for your replies.

Advertisement

Answer

The list_add_tail function is

void list_add_tail(struct list_head *new, struct list_head *head);

The second param should a pointer to a struct list_head so just use like this:

list_add_tail(&newNode -> list , &processList);
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement