error: variable ‘scull_fops’ has initializer but incomplete type
Please reply me regarding this errors.
the source code and the error file are as below.
#define MODULE
#include <linux/module.h>
#include<linux/fs.h>
#include<linux/kernel.h>
#include<linux/slab.h>
//#include<linux/ioctl.h>
//#include</usr/include/error.h>
MODULE_LICENSE("GFP_KERNEL");
#define MAJ_NUM 45
#define READ 5
#define WRITE 6
#define DEVICE_NAME "raj"
unsigned long *test;
int scull_open(struct inode *inode, struct file *file)
{
printk("In open function\n");
// MOD_INC_USE_COUNT;
return 0;
}
int scull_release(struct inode *inode, struct file *file)
{
printk("In Release function \n");
// MOD_DEC_USE_COUNT;
}
struct file_operations *f_op;
struct file_operations scull_fops = {
.open = scull_open,
.release = scull_release,
};
int init_module(void)
{
unsigned long result;
result=register_chrdev(MAJ_NUM,"raj",&f_op);
if(result <0)
{
printk("Can't get Major number %d\n",MAJ_NUM);
return result;
}
if(MAJ_NUM==0) MAJ_NUM=result;
printk("Hello \n");
test=(unsigned long *)kmalloc(1024*5,"GFP_KERNEL");
printk("test=%x",&test);
return 0;
}
void cleanup_module(void)
{
unregister_chrdev(MAJ_NUM,"raj");
printk("Cleanup Over \n");
}
new.c:7:23: error: linux/slab.h: No such file or directory
new.c:18: warning: ‘struct file’ declared inside parameter list
new.c:18: warning: its scope is only this definition or declaration, which is probably not what you want
new.c:18: warning: ‘struct inode’ declared inside parameter list
new.c:25: warning: ‘struct file’ declared inside parameter list
new.c:25: warning: ‘struct inode’ declared inside parameter list
new.c:34: error: variable ‘scull_fops’ has initializer but incomplete type
new.c:35: error: unknown field ‘open’ specified in initializer
new.c:35: warning: excess elements in struct initializer
new.c:35: warning: (near initialization for ‘scull_fops’)
new.c:36: error: unknown field ‘release’ specified in initializer
new.c:36: warning: excess elements in struct initializer
new.c:36: warning: (near initialization for ‘scull_fops’)
new.c: In function ‘init_module’:
new.c:50: error: invalid lvalue in assignment
[root@localhost check]#
|