So I am doing some work on a linux kernel for class and I am trying to implement a function but first I must define a struct in kernel space. I am getting an error but I am not too sure the cause.
I assume it has something to do with the struct I defined at the beginning but I can't seem to find any issues with it.
UPDATE: Ok I have solved one of the problems. So I will be updating my code snippet and marking lines that are specified in the errors. Line 24 is the line right after the end of the struct.
Here is what I am doing:
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/klist.h>
#include <linux/errno.h>
#include <asm/uaccess.h>
#include <linux/slab.h>
/********************************************
*This function adds a new item to the queue
*
*If not enough memory return -ENOMEM
*If there is an error accessing the upper space point return -efault
*If len is negative return -EINVAL
*Returns 0 on success
******************************/
struct dataNode
{
const void * data;
int length;
struct list_head * mylist;
}
asmlinkage long sys_writeMsgQueue421(const void __user *data, long len) //**Line 24**//
{
newNode->data = pdata;
newNode->length = len;
//****Need to add to the linked list****//
printk("This was passed in: %p and %ld \n",data , len);
return 0;
}
asmlinkage long sys_readMsgQueue421(void)
{
printk("This is the read function!\n");
return 0;
}
asmlinkage long sys_emptyMsgQueue421(void)
{
printk("This is the clear function!\n");
return 0;
}
And I am getting the following errors when I run the make command:
CC msgQueue421/msgQueue421.o msgQueue421/msgQueue421.c:24:1: warning: ‘regparm’ attribute only applies to function types [-Wattributes] msgQueue421/msgQueue421.c:24:12: error: expected ‘;’, identifier or ‘(’ before ‘long’ make[1]: * [msgQueue421/msgQueue421.o] Error 1 make: * [msgQueue421] Error 2
Any idea what I'm doing wrong?