我正在开发示例内核模块driver.ko。我想用模块参数data_node指定BlockSize结构的块大小。当我单独运行insmod driver.ko时,它可以工作,但是当我指定BlockSize insmod driver.ko BlockSize = 10时,我得到了这个错误:
Error: could not insert module driver.ko: Invalid parametersmodinfo -p ./driver.ko命令给我以下内容:
BlockSize: size of buffer (int)driver.c
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/cdev.h>
#include <linux/kdev_t.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <linux/mutex.h>
#include <linux/device.h>
#include <linux/slab.h>
/* parametter */
static int BlockNumber = 8;
static int BlockSize = 512;
module_param( variable name, type, permission); */
module_param(BlockSize, int, S_IRUGO);
MODULE_PARM_DESC(BlockSize , " size of buffer");
/* using 'k' as magic number */
#define SAMPLE_IOC_MAGIC 'k'
#define SAMPLE_IOCRESET _IOWR(SAMPLE_IOC_MAGIC, 0, int)
#define SAMPLE_IOC_MAXNR 0
struct cdev* my_cdev;
dev_t dev;
static int size_to_read;
/* Macro used to compute the minimum */
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
/* data buffer structure */
typedef struct dnode
{
int bufSize;
char *buffer;
struct dnode *next;
} data_node;
/* liste stucture */
typedef struct lnode
{
data_node *head;
data_node *cur_write_node;
data_node *cur_read_node;
int cur_read_offset;
int cur_write_offset;
}liste;
code ..........................。。
发布于 2014-08-08 17:52:59
似乎模块参数应该在名称和值之间没有空格地传递,即您应该使用:
insmod driver.ko BlockSize=10这有点道理,因为在命令行中,"BlockSize=10“本身是*argv[]中的一个条目,可以作为块传递给内核,而"BlockSize = 10”则是三个不同的条目("BlockSize“、"=”、"10"),有些人必须编写代码才能重新连接。
https://stackoverflow.com/questions/25208531
复制相似问题