当前位置: 技术问答>linux和unix
insmod 错误 -1 Invalid module format
来源: 互联网 发布时间:2016-06-14
本文导语: 查看系统信息为: disagrees about version of symbol struct_module 当前运行内核版本是 Linux version 2.6.18-1.2798.fc6 (brewbuilder@hs20-bc2-3.build.redhat.com) (gcc version 4.1.1 20061011 (Red Hat 4.1.1-30)) #1 SMP Mon Oct 16 14:54:20 EDT 2006 ...
查看系统信息为: disagrees about version of symbol struct_module
当前运行内核版本是 Linux version 2.6.18-1.2798.fc6 (brewbuilder@hs20-bc2-3.build.redhat.com) (gcc version 4.1.1 20061011 (Red Hat 4.1.1-30)) #1 SMP Mon Oct 16 14:54:20 EDT 2006
源码下载的是:2.6.18.1
程序为
#include
#include
#include /* everything... */
#define DEVICE_NAME "demo"
#define demo_MAJOR 249
#define demo_MINOR 0
#define MAX_BUF_LEN 20
//MODULE_LICENSE("GPL");
#ifdef UTS_RELEASE
#undef UTS_RELEASE
#endif
#define UTS_RELEASE "2.6.18-1"
static char drv_buf[20];
static int demo_open(struct inode *inode, struct file *file)
{
//MOD_INC_USE_COUNT;
//sprintf(drv_buf,"device open sucess!n");
//printk("device open sucess!n");
return 0;
}
static int demo_release(struct inode *inode, struct file *filp)
{
//MOD_DEC_USE_COUNT;
//printk("device releasen");
return 0;
}
static ssize_t demo_read(struct file *filp, char *buffer, size_t count, loff_t *ppos)
{
if(count > MAX_BUF_LEN)
count=MAX_BUF_LEN;
//copy_to_user(buffer, drv_buf,count);
printk("user read data from drivern");
return count;
}
static ssize_t demo_write(struct file *filp,const char *buffer, size_t count)
{
//copy_from_user(drv_buf , buffer, count);
printk("user write data to drivern");
//your code here
return count;
}
static struct file_operations demo_fops =
{
write: demo_write,
read: demo_read,
open: demo_open,
release: demo_release,
};
static int demo_init(void)
{
int result;
/*SET_MODULE_OWNER(&demo_fops);*/
result = register_chrdev(demo_MAJOR, "demo", &demo_fops);
if (result
当前运行内核版本是 Linux version 2.6.18-1.2798.fc6 (brewbuilder@hs20-bc2-3.build.redhat.com) (gcc version 4.1.1 20061011 (Red Hat 4.1.1-30)) #1 SMP Mon Oct 16 14:54:20 EDT 2006
源码下载的是:2.6.18.1
程序为
#include
#include
#include /* everything... */
#define DEVICE_NAME "demo"
#define demo_MAJOR 249
#define demo_MINOR 0
#define MAX_BUF_LEN 20
//MODULE_LICENSE("GPL");
#ifdef UTS_RELEASE
#undef UTS_RELEASE
#endif
#define UTS_RELEASE "2.6.18-1"
static char drv_buf[20];
static int demo_open(struct inode *inode, struct file *file)
{
//MOD_INC_USE_COUNT;
//sprintf(drv_buf,"device open sucess!n");
//printk("device open sucess!n");
return 0;
}
static int demo_release(struct inode *inode, struct file *filp)
{
//MOD_DEC_USE_COUNT;
//printk("device releasen");
return 0;
}
static ssize_t demo_read(struct file *filp, char *buffer, size_t count, loff_t *ppos)
{
if(count > MAX_BUF_LEN)
count=MAX_BUF_LEN;
//copy_to_user(buffer, drv_buf,count);
printk("user read data from drivern");
return count;
}
static ssize_t demo_write(struct file *filp,const char *buffer, size_t count)
{
//copy_from_user(drv_buf , buffer, count);
printk("user write data to drivern");
//your code here
return count;
}
static struct file_operations demo_fops =
{
write: demo_write,
read: demo_read,
open: demo_open,
release: demo_release,
};
static int demo_init(void)
{
int result;
/*SET_MODULE_OWNER(&demo_fops);*/
result = register_chrdev(demo_MAJOR, "demo", &demo_fops);
if (result