Linux设备驱动程序(LDD)中snull的编译问题

本文主要针对Linux设备驱动程序LDD中的snull程序在编译时遇到的问题进行总结和解答,特别是在debian6.0上,内核版本2.6.32的情况。常见问题包括内核源代码树缺失、CFLAGS变更为EXTRA_CFLAGS、头文件和结构体变更等。解决方案包括正确构造内核源代码树、修改Makefile和snull.c源文件,以适配新内核接口。本文还提供了修改后的文件和patch文件供下载。
摘要由CSDN通过智能技术生成

对LDD中snull程序,编译的时候会有许多问题,鉴于网上还没有合适的解决办法,做此总结,整理知识。本文在debian6.0上运行通过,内核版本为2.6.32。

学习LDD中网络驱动程序部分,理解snull程序的原理很有必要。snull不依赖于硬件,数据包的收发都属于内存操作,但对整个网络驱动程序原理已经做了很好的阐述。程序并不复杂,相比e100.c;8139too.c;pci-skeleton.c,容易理解的多。作者写这本书的时候尚是2.6.11的年代,与现在内核版本相比,有些接口发生了变化,这是snull编译失败的直接原因。本文将描述snull的修改方法,并指出发生变化的接口。本文在debian6.0上运行通过,内核版本为2.6.32。

本文提供了修改完成后的makefile和snull.c,并生成了patch文件。

 


本文内容

1)常见问题

2)正确的snull编译方法

3)文件下载


一 常见问题

    这是我自己遇到的,和网上看到的部分问题,现一一阐述原因,并在第二段(见下文)中阐述解决方法。 如果在这些问题之外,还有问题,清大家留言,方便讨论。至于详细的接口变化,我会另写文章,一一说明。

 

    1)错误描述:

make -C /lib/modules/2.6.32-5-686/build M=/home/xiebiwei/dev/code/Ldd/snull modules
make: *** /lib/modules/2.6.32-5-686/build: No such file or directory.  Stop.
make: *** [default] Error 2

            问题原因:没有安装内核源代码树,或者是安装了内核源代码树后,没有修改makefile中的kerneldir。

 

     2)错误描述:

make -C /lib/modules/2.6.32/build M=/home/xiebiwei/dev/code/Ldd/snull modules
make[1]: Entering directory `/usr/src/linux-source-2.6.32'
scripts/Makefile.build:49: *** CFLAGS was changed in "/home/xiebiwei/dev/code/Ldd/snull/Makefile". Fix it to use EXTRA_CFLAGS.  Stop.
make[1]: *** [_module_/home/xiebiwei/dev/code/Ldd/snull] Error 2
make[1]: Leaving directory `/usr/src/linux-source-2.6.32'
make: *** [default] Error 2

            问题原因:内核版本不同,最近版本已经把CFLAGS变为EXTRA_CFLAGS

 

      3)错误描述:

make -C /lib/modules/2.6.32/build M=/home/xiebiwei/dev/code/Ldd/snull modules
make[1]: Entering directory `/usr/src/linux-source-2.6.32'
  CC [M]  /home/xiebiwei/dev/code/Ldd/snull/snull.o
/home/xiebiwei/dev/code/Ldd/snull/snull.c:18:26: error: linux/config.h: No such file or directory
/home/xiebiwei/dev/code/Ldd/snull/snull.c: In function ‘snull_poll’:
/home/xiebiwei/dev/code/Ldd/snull/snull.c:289: error: ‘struct net_device’ has no member named ‘quota’
/home/xiebiwei/dev/code/Ldd/snull/snull.c:289: warning: type defaults to ‘int’ in declaration of ‘_min1’
/home/xiebiwei/dev/code/Ldd/snull/snull.c:289: error: ‘struct net_device’ has no member named ‘quota’
/home/xiebiwei/dev/code/Ldd/snull/snull.c:319: error: ‘struct net_device’ has no member named ‘quota’
/home/xiebiwei/dev/code/Ldd/snull/snull.c:321: error: implicit declaration of function ‘netif_rx_complete’
/home/xiebiwei/dev/code/Ldd/snull/snull.c: In function ‘snull_napi_interrupt’:
/home/xiebiwei/dev/code/Ldd/snull/snull.c:406: error: implicit declaration of function ‘netif_rx_schedule’
/home/xiebiwei/dev/code/Ldd/snull/snull.c: In function ‘snull_init’:
/home/xiebiwei/dev/code/Ldd/snull/snull.c:647: error: ‘struct net_device’ has no member named ‘open’
/home/xiebiwei/dev/code/Ldd/snull/snu

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值