Hello, I implemented a new system call and added new structure in kernel space. The structure uses linked lists found in include/linux/list and elements of the list have a field which is a pointer to a task_struct. Thus I added in the kernel tree a file new.h which looks like: ---- BEGIN ---- include/linux/elsa.h ---- #ifndef __LINUX_ELSA_H #define __LINUX_ELSA_H #include <linux/list.h> #include <linux/sched.h> /* * sys_elsa() interface. * * int sys_elsa(int opcode, unsigned int arg0, * unsigned int arg1, unsigned int arg2) */ enum elsa_opcode {BANK_INIT,BANK_ALLOC,BANK_FREE,BANK_ADD,BANK_REMOVE}; struct bank_root_s { unsigned int next_id; /* next available bank identifier */ struct list_head head; /* head of the list of bank */ }; struct elsa_bank_s { unsigned int id; /* the bank identifier */ struct list_head banks; /* list of available banks */ struct list_head head; /* head of the list of datas in the bank */ }; struct elsa_data_s { struct task_struct *process; /* the process information */ struct list_head datas; /* link between datas in a bank */ struct list_head banks; /* used by a process to link banks that contains it */ }; #endif /* !(__LINUX_ELSA_H) */ ---- END --- include/linux/elsa.h --- I compiled my new kernel and booted it. The problem occurs when I try to use the new system call. I wrote a small program test.c : ---- BEGIN ---- test.c ---- #include <linux/elsa.h> #include <asm-i386/unistd.h> #include <errno.h> _syscall3(long, elsa, unsigned int, opcode, unsigned int, arg1, unsigned int, arg2); int main(){return 0;} ---- END ---- test.c ---- When I compiled it with gcc-3.2.2 I have the following errors: ... [0] guill@nuptse:/tmp$ gcc -I/home/thouveng/Projects/ELSA_CVS/linux-2.6.5-elsa/include -c toto.c In file included from /home/thouveng/Projects/ELSA_CVS/linux-2.6.5-elsa/include/linux/elsa.h:12, from toto.c:1: /home/thouveng/Projects/ELSA_CVS/linux-2.6.5-elsa/include/linux/list.h:604:2: warning: #warning "don't include kernel headers in userspace" In file included from /home/thouveng/Projects/ELSA_CVS/linux-2.6.5-elsa/include/linux/config.h:4, from /home/thouveng/Projects/ELSA_CVS/linux-2.6.5-elsa/include/linux/sched.h:6, from /home/thouveng/Projects/ELSA_CVS/linux-2.6.5-elsa/include/linux/elsa.h:13, from toto.c:1: /usr/include/linux/autoconf.h:1:2: #error Invalid kernel header included in userspace ... Knowing that the only thing that the user should know in order to use the system call is the existance of the strucutre "bank_root_s" and "opcode", I change my header file with the following one: ---- NEW HEADER FILE ---- #ifndef __LINUX_ELSA_H #define __LINUX_ELSA_H struct bank_root_s; enum elsa_opcode {BANK_INIT,BANK_ALLOC,BANK_FREE,BANK_ADD,BANK_REMOVE}; /* * sys_elsa() interface. * * int sys_elsa(int opcode, unsigned int arg0, * unsigned int arg1, unsigned int arg2) */ #ifdef __KERNEL__ #include <linux/list.h> #include <linux/sched.h> struct bank_root_s { unsigned int next_id; /* next available bank identifier */ struct list_head head; /* head of the list of bank */ }; struct elsa_bank_s { unsigned int id; /* the bank identifier */ struct list_head banks; /* list of available banks */ struct list_head head; /* head of the list of datas in the bank */ }; struct elsa_data_s { struct task_struct *process; /* the process information */ struct list_head datas; /* link between datas in a bank */ struct list_head banks; /* used by the processus to link banks that contains it */ }; #endif /* !(__KERNEL__) */ #endif /* !(__LINUX_ELSA_H) */ ---- END OF NEW HEADER FILE ---- Now, I can compile the test program. Therefore, my question is : Is it a correct solution or is there other solution that allows to not include kernel header in a user program? Thanks for your help Guillaume -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/