我正在查看 linux 内核模块中的以下代码:
static int proc_read_kernel(char *buffer, char **start, off_t offset, int length,int *eof, void *data)
{
int len=0;
struct mem_rw_t *mem= (struct mem_rw_t *)data;
switch(mem->flag)
{
从上面的代码它切换到另一个具有长度检查的函数,如下所示
static int func1(char *buffer, char **start, off_t offset, int length)
{
printk ("The value for len is %d\n\r",len);
printk ("The value for length is %d\n\r",length);
if(len > length)
goto list_finished;
上述代码的输出如下所示。看起来 len 的长度大于最后一个值的长度,并且 proc read 无法正常工作:
The value for len is 0
The value for length is 3072
The value for len is 398
The value for length is 3072
The value for len is 796
The value for length is 3072
The value for len is 796
The value for length is 3072
The value for len is 1537
The value for length is 3072
The value for len is 1777
The value for length is 3072
The value for len is 1777
The value for length is 3072
The value for len is 2029
The value for length is 3072
The value for len is 2427
The value for length is 3072
The value for len is 3120
The value for length is 3072
<4>proc_file_read: Read count exceeded
有什么建议可以消除上述错误吗?