Linux下编写和加载 .ko 文件(编写linux驱动)
一、.ko 文件介绍
.ko文件是kernel object文件(内核模块),该文件的意义就是把内核的一些功能移动到内核外边, 需要的时候插入内核,不需要时卸载。
二、优点
(1)这样可以缩小内核体积; (2)使用方便。
三、.ko文件一般的用处
(1)作为一个功能模块,需要使用时,直接插入运行就行。如在imx6上连接模拟摄像头,先运行模拟摄像头对应的驱动模块 camera.ko文件,然后对应的工程执行文件运行就行。
四、开发环境搭建
[root@ht5 src]# cd /usr/src/kernels/
[root@ht5 kernels]# ls //这个下面没有安装时,什么也没有
[root@ht5 kernels]#
//默认会安装到/usr/src/kernels下
[root@ht5 src]#rpm -qa kernel-headers [root@ht5 src]# yum install gcc //安装gcc编译环境也很重要 [root@ht5 src]#yum install -y kernel-devel //这个很关键,很多资料的阐述的方法不准确
[root@ht5 src]# ls /usr/src/kernels/ //安装之后查看下这个目录
3.10.0-1160.59.1.el7.x86_64
[root@ht5 src]# ls /usr/src/kernels/3.10.0-1160.59.1.el7.x86_64/
arch/ crypto/ fs/ ipc/ lib/ mm/ samples/ sound/ usr/
block/ drivers/ include/ Kconfig Makefile Module.symvers scripts/ System.map virt/
.config firmware/ init/ kernel/ Makefile.qlock net/ security/ tools/ vmlinux.id
//确认是否有init.h内核头文件
[root@ht5 linux]# ls /usr/src/kernels/3.10.0-1160.59.1.el7.x86_64/include/linux/ | grep init.h
init.h
[root@ht5 src]# uname -r //注意本机和安装的内核开发环境的版本不是一致的
3.10.0-1160.42.2.el7.x86_64
五、创建驱动文件mydriver.c
//引入相关内核头文件
#include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("GPL"); //这里必须要声明,内核许可证信息
MODULE_AUTHOR("jinzs");
MODULE_DESCRIPTION("mydriver");
MODULE_VERSION("1.0");
//初始化函数
static int mydriver_init(void) { printk(KERN_ALERT "it is mydriver\n"); return 0; }
//清理函数,在卸载时调用,回收资源销毁执行环境 static void mydriver_exit(void) { printk(KERN_ALERT "out\n"); } //登记初始化函数及清理函数 module_init(mydriver_init); module_exit(mydriver_exit);
############################################################################
内核代码中会有大量的驱动模块
例如: E:\linux内核\linux-2.6.0\linux-2.6.0\drivers\i2c\i2c-dev.c
MODULE_AUTHOR(“Frodo Looijaard <frodol@dds.nl> and “”Simon G. Vogl <simon@tk.uni-linz.ac.at>”);
MODULE_DESCRIPTION(“I2C /dev entries driver”);
MODULE_LICENSE(“GPL”);
module_init(i2c_dev_init);
module_exit(i2c_dev_exit);
//看完本文基本就知道,它的加载机制和实现机制了
六、编译驱动文件mydriver.c,利用Makefile文件
obj-m := mydriver.o //obj-m后是tab键缩进 KERNEL := /usr/src/kernels/3.10.0-1160.59.1.el7.x86_64/ PWD :=$(shell pwd) //PWD后是tab键缩进 modules: $(MAKE) -C $(KERNEL) M=$(PWD) modules clean: rm -f *.o *.ko
# Makefile语法要注意,不能使用空格键来控制文本行缩进,必须使用Tab键,否则会出现Makefile:5: *** missing separator
# /usr/src/kernels/3.10.0-1160.59.1.el7.x86_64/这里3.10.0....写死了, 可以这样 /usr/src/kernels/$(uname -r)/
# 但是由于安装没有对应的内核的devel所以写死了.
编译
[root@ht5 src]# make
make -C /usr/src/kernels/3.10.0-1160.59.1.el7.x86_64/ M=/usr/local/src modules
make[1]: Entering directory `/usr/src/kernels/3.10.0-1160.59.1.el7.x86_64′
CC [M] /usr/local/src/mydriver.o
Building modules, stage 2.
MODPOST 1 modules
CC /usr/local/src/mydriver.mod.o
LD [M] /usr/local/src/mydriver.ko
make[1]: Leaving directory `/usr/src/kernels/3.10.0-1160.59.1.el7.x86_64′
[root@ht5 src]# ll total 101360 -rw-r--r-- 1 root root 297 Mar 28 20:49 mydriver.c -rw-r--r-- 1 root root 101472 Mar 28 20:59 mydriver.ko -rw-r--r-- 1 root root 907 Mar 28 20:59 mydriver.mod.c -rw-r--r-- 1 root root 58864 Mar 28 20:59 mydriver.mod.o -rw-r--r-- 1 root root 45728 Mar 28 20:59 mydriver.o -rw-r--r-- 1 root root 17 Mar 28 20:37 mydriver.s-rw-r--r-- 1 root root 170 Mar 28 21:00 Makefile -rw-r--r-- 1 root root 31 Mar 28 21:00 modules.order -rw-r--r-- 1 root root 0 Mar 28 20:59 Module.symvers
七、加载.ko 文件
1、加载驱动模块mydriver.ko
1)方法一
一旦生成mydriver.ko驱动模块文件,进入所在的目录,然后直接
[root@ht5 src]#insmod mydriver.ko
2)方法二
将mydriver.ko文件拷贝到可加载驱动所在目录下 /lib/modules/3.10.0-693.el7.x86_64/
注意本机:
[root@ht5 src]# uname -r
3.10.0-1160.42.2.el7.x86_64
[root@ht5 src]# depmod
//depmod 会在/lib/modules/3.10.0-693.el7.x86_64/目录下生成modules.dep和modules.dep.bb文件
[root@ht5 src]# modprobe -r mydriver //注意这里无需输入.ko后缀
注:两种方法的区别
modprobe和insmod类似,都是用来动态加载驱动模块的,区别在于modprobe可以解决load module时的依赖关系,
它是通过/lib/modules/#uname -r/modules.dep(.bb)文件来查找依赖关系的;而insmod不能解决依赖问题。也就是说,如果你确定你要加载的驱动模块不依赖其他驱动模块的话,
既可以insmod也可以modprobe,当然insmod可以在任何目录下执行,更方便一些。而如果你要加载的驱动模块还依赖其他ko驱动模块的话,就只能将模块拷贝到上述的特定目录,
depmod后再modprobe。
2、查看已加载的驱动模块列表和模块信息
[root@ht5 src]# lsmod | grep mydriver mydriver 12496 0
[root@ht5 src]# modinfo mydriver.ko
filename: /usr/local/src/mydriver.ko
version: 1.0
description: mydriver
author: jinzs
license: GPL
retpoline: Y
rhelversion: 7.9
srcversion: FCA9B81CB0D8E3B092F2759
depends:
vermagic: 3.10.0-1160.59.1.el7.x86_64 SMP mod_unload modversions
loading out-of-tree module taints kernel问题
[root@ht5 src]# dmesg | grep mydriver [3334186.411879] mydriver: loading out-of-tree module taints kernel. [3334186.411922] mydriver: module verification failed: signature and/or required key missing - tainting kernel
确认是否签名是否被加载
[root@ht5 src]# modinfo -F signer mydriver.ko //执行后无提示
[root@ht5 src]# cd /lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/
[root@ht5 drivers]# ls
acpi bcma char dma gpu i2c iommu media misc ntb platform ptp staging uio vhost xen
ata block cpufreq edac hid idle isdn memstick mmc parport power rtc target usb video
auxdisplay bluetooth crypto firewire hv infiniband leds message mtd pci powercap scsi thermal uwb virtio
base cdrom dca firmware hwmon input md mfd net pcmcia pps ssb tty vfio watchdog
[root@ht5 drivers]# cd net/
[root@ht5 net]# ls
bonding ethernet ieee802154 macvlan.ko mdio.ko netconsole.ko ntb_netdev.ko ppp team usb virtio_net.ko vxlan.ko wireless
dummy.ko hyperv ifb.ko macvtap.ko mii.ko nlmon.ko phy slip tun.ko veth.ko vmxnet3 wan xen-netfront.ko
[root@ht5 net]# modinfo -F signer ifb.ko
CentOS Linux kernel signing key
[root@ht5 net]# modinfo -F signer tun.ko
CentOS Linux kernel signing key
[root@ht5 net]# modinfo tun | grep ‘^sig’
signer: CentOS Linux kernel signing key
sig_key: 28:FD:E6:60:84:9F:DF:48:DE:A9:1B:48:B8:0B:17:B5:6C:E1:51:98
sig_hashalgo: sha256
[root@ht5 net]# hexdump -C tun.ko | tail
0000bea0 5a da 53 36 67 22 a1 fd 16 ab d1 7c c6 84 e4 8b |Z.S6g”…..|….|
0000beb0 45 03 6a 10 dc b3 37 6b 52 18 ea 7b 27 06 0b b2 |E.j…7kR..{‘…|
0000bec0 59 a6 86 53 4e 20 72 b2 b0 95 aa 3f 2d e4 28 fc |Y..SN r….?-.(.|
0000bed0 92 18 a3 cf c2 58 40 75 7d 76 f9 65 d1 8c ac dd |…..X@u}v.e….|
0000bee0 ec a1 83 0c 8f 62 ef 4f 30 4d 3d ef db 3b 4a 5e |…..b.O0M=..;J^|
0000bef0 08 9f 18 b9 82 77 3f dc 4c 92 aa 59 c6 01 04 01 |…..w?.L..Y….|
0000bf00 1f 14 00 00 00 00 00 01 82 7e 4d 6f 64 75 6c 65 |………~Module|
0000bf10 20 73 69 67 6e 61 74 75 72 65 20 61 70 70 65 6e | signature appen|
0000bf20 64 65 64 7e 0a |ded~.|
0000bf25
使用insmod命令加载编写的驱动模块,在用demesg出现信息:loading out-of-tree module taints kernel。
模块还是能够被加载。并且卸载后再次加载时,该提示信息没有再次出现。关于taint资料很多,查查就知道了
部分内核被污染的原因:
加载非GPL兼容的内核模块
驱动程序的使用,它们是内核源代码的一部分,但尚未经过全面测试
使用内核源代码未包含的树外模块
强制加载不是为当前内核版本构建的模块
某些严重错误,例如machine check exceptions(MCE)和kernel oopses
参考
https://unix.stackexchange.com/questions/118116/what-is-a-tainted-linux-kernel
https://wiki.gentoo.org/wiki/Signed_kernel_module_support#Manually_signing_modules
3、卸载驱动模块
[root@ht5 src]# rmmod mydriver
//注:"module_name"是lsmod显示的模块名称,而不是对应的ko文件名
本例子中命令行下执行命令:rmmod mydriver.ko即可。
查看cat /var/log/messages.
可以看到下面这样的信息:“Aug 6 13:40:36 localhost kernel: Goodbye, cruel world”,说明模块卸载成功。
4. 查看模块信息
[root@ht5 src]# nm mydriver.ko 0000000000000020 T cleanup_module U __fentry__ 0000000000000020 t mydriver_exit 0000000000000000 t mydriver_init 0000000000000000 T init_module 000000000000004b r __module_depends U printk 0000000000000000 D __this_module 0000000000000000 r __UNIQUE_ID_license8 000000000000000c r __UNIQUE_ID_retpoline11 0000000000000018 r __UNIQUE_ID_rhelversion10 0000000000000028 r __UNIQUE_ID_srcversion9 0000000000000054 r __UNIQUE_ID_vermagic8 0000000000000000 r ____versions
八 查看内核内置模块(它不以文件形式存在,不在驱动列表下)
[root@ht5 src]# cat /lib/modules/$(uname -r)/modules.builtin kernel/arch/x86/crypto/aes-x86_64.ko kernel/arch/x86/crypto/sha1-ssse3.ko kernel/arch/x86/crypto/sha256-ssse3.ko kernel/arch/x86/events/intel/intel-rapl-perf.ko kernel/arch/x86/events/intel/intel-uncore.ko kernel/arch/x86/kernel/msr.ko kernel/arch/x86/kernel/cpuid.ko kernel/mm/zpool.ko kernel/mm/zbud.ko kernel/mm/zsmalloc.ko kernel/fs/binfmt_script.ko kernel/fs/autofs4/autofs4.ko kernel/fs/configfs/configfs.ko kernel/fs/efivarfs/efivarfs.ko kernel/fs/exportfs/exportfs.ko kernel/fs/nls/nls_base.ko kernel/fs/nls/nls_cp437.ko kernel/fs/nls/nls_ascii.ko kernel/fs/quota/quota_v2.ko kernel/fs/quota/quota_tree.ko kernel/security/keys/trusted.ko kernel/security/keys/encrypted-keys/encrypted-keys.ko kernel/crypto/crypto.ko kernel/crypto/crypto_wq.ko kernel/crypto/crypto_algapi.ko kernel/crypto/aead.ko kernel/crypto/crypto_blkcipher.ko kernel/crypto/chainiv.ko kernel/crypto/eseqiv.ko kernel/crypto/seqiv.ko kernel/crypto/crypto_hash.ko kernel/crypto/pcompress.ko kernel/crypto/akcipher.ko kernel/crypto/kpp.ko kernel/crypto/acompress.ko kernel/crypto/scompress.ko kernel/crypto/cryptomgr.ko kernel/crypto/hmac.ko kernel/crypto/md5.ko kernel/crypto/sha1_generic.ko kernel/crypto/sha256_generic.ko kernel/crypto/ecb.ko kernel/crypto/cbc.ko kernel/crypto/ctr.ko kernel/crypto/aes_generic.ko kernel/crypto/crc32c.ko kernel/crypto/lzo.ko kernel/crypto/rng.ko kernel/crypto/af_alg.ko kernel/crypto/algif_hash.ko kernel/crypto/algif_skcipher.ko kernel/crypto/asymmetric_keys/asymmetric_keys.ko kernel/crypto/asymmetric_keys/public_key.ko kernel/crypto/asymmetric_keys/rsa.ko kernel/crypto/asymmetric_keys/x509_key_parser.ko kernel/crypto/asymmetric_keys/pkcs7_message.ko kernel/block/deadline-iosched.ko kernel/block/cfq-iosched.ko kernel/block/mq-deadline.ko kernel/block/kyber-iosched.ko kernel/drivers/acpi/ac.ko kernel/drivers/acpi/button.ko kernel/drivers/acpi/fan.ko kernel/drivers/acpi/processor.ko kernel/drivers/acpi/thermal.ko kernel/drivers/acpi/battery.ko kernel/drivers/acpi/hed.ko kernel/drivers/base/firmware_class.ko kernel/drivers/char/raw.ko kernel/drivers/char/nvram.ko kernel/drivers/char/crash.ko kernel/drivers/char/agp/agpgart.ko kernel/drivers/char/agp/amd64-agp.ko kernel/drivers/char/agp/intel-agp.ko kernel/drivers/char/agp/intel-gtt.ko kernel/drivers/char/agp/sis-agp.ko kernel/drivers/char/agp/via-agp.ko kernel/drivers/char/hw_random/rng-core.ko kernel/drivers/char/tpm/tpm.ko kernel/drivers/char/tpm/tpm_tis_core.ko kernel/drivers/char/tpm/tpm_tis.ko kernel/drivers/connector/cn.ko kernel/drivers/cpufreq/cpufreq_performance.ko kernel/drivers/cpufreq/cpufreq_powersave.ko kernel/drivers/cpufreq/cpufreq_userspace.ko kernel/drivers/cpufreq/cpufreq_ondemand.ko kernel/drivers/cpufreq/cpufreq_conservative.ko kernel/drivers/dax/dax.ko kernel/drivers/edac/edac_core.ko kernel/drivers/firmware/dmi-sysfs.ko kernel/drivers/firmware/qemu_fw_cfg.ko kernel/drivers/firmware/efi/efivars.ko kernel/drivers/firmware/efi/efi-pstore.ko kernel/drivers/hid/hid.ko kernel/drivers/hid/hid-generic.ko kernel/drivers/hid/hid-a4tech.ko kernel/drivers/hid/hid-apple.ko kernel/drivers/hid/hid-belkin.ko kernel/drivers/hid/hid-cherry.ko kernel/drivers/hid/hid-chicony.ko kernel/drivers/hid/hid-cypress.ko kernel/drivers/hid/hid-ezkey.ko kernel/drivers/hid/hid-kensington.ko kernel/drivers/hid/hid-logitech.ko kernel/drivers/hid/hid-magicmouse.ko kernel/drivers/hid/hid-microsoft.ko kernel/drivers/hid/hid-monterey.ko kernel/drivers/hid/hid-ntrig.ko kernel/drivers/hid/hid-plantronics.ko kernel/drivers/hid/intel-ish-hid/intel-ishtp.ko kernel/drivers/hid/intel-ish-hid/intel-ish-ipc.ko kernel/drivers/hid/intel-ish-hid/intel-ishtp-hid.ko kernel/drivers/hid/usbhid/usbhid.ko kernel/drivers/hwmon/hwmon.ko kernel/drivers/i2c/i2c-core.ko kernel/drivers/iio/industrialio.ko kernel/drivers/iio/buffer/industrialio-buffer-cb.ko kernel/drivers/iio/buffer/kfifo_buf.ko kernel/drivers/input/input-core.ko kernel/drivers/input/ff-memless.ko kernel/drivers/input/input-leds.ko kernel/drivers/input/mousedev.ko kernel/drivers/input/evdev.ko kernel/drivers/input/keyboard/atkbd.ko kernel/drivers/input/mouse/psmouse.ko kernel/drivers/input/serio/serio.ko kernel/drivers/input/serio/i8042.ko kernel/drivers/input/serio/serport.ko kernel/drivers/input/serio/libps2.ko kernel/drivers/iommu/iova.ko kernel/drivers/leds/led-class.ko kernel/drivers/macintosh/mac_hid.ko kernel/drivers/md/md-mod.ko kernel/drivers/mfd/mfd-core.ko kernel/drivers/mfd/intel-lpss.ko kernel/drivers/mfd/intel-lpss-pci.ko kernel/drivers/mfd/intel-lpss-acpi.ko kernel/drivers/net/phy/libphy.ko kernel/drivers/net/phy/realtek.ko kernel/drivers/net/phy/fixed_phy.ko kernel/drivers/nvmem/nvmem_core.ko kernel/drivers/pci/pci-stub.ko kernel/drivers/pcmcia/pcmcia_core.ko kernel/drivers/pcmcia/pcmcia_rsrc.ko kernel/drivers/platform/x86/pvpanic.ko kernel/drivers/rtc/rtc-cmos.ko kernel/drivers/scsi/scsi_mod.ko kernel/drivers/scsi/device_handler/scsi_dh.ko kernel/drivers/scsi/device_handler/scsi_dh_rdac.ko kernel/drivers/scsi/device_handler/scsi_dh_hp_sw.ko kernel/drivers/scsi/device_handler/scsi_dh_emc.ko kernel/drivers/scsi/device_handler/scsi_dh_alua.ko kernel/drivers/thermal/thermal_sys.ko kernel/drivers/thunderbolt/thunderbolt.ko kernel/drivers/tty/serial/serial_core.ko kernel/drivers/tty/serial/kgdboc.ko kernel/drivers/tty/serial/8250/8250.ko kernel/drivers/tty/serial/8250/8250_pci.ko kernel/drivers/tty/serial/8250/8250_dw.ko kernel/drivers/usb/common/usb-common.ko kernel/drivers/usb/core/usbcore.ko kernel/drivers/usb/host/ehci-hcd.ko kernel/drivers/usb/host/ehci-pci.ko kernel/drivers/usb/host/ohci-hcd.ko kernel/drivers/usb/host/ohci-pci.ko kernel/drivers/usb/host/uhci-hcd.ko kernel/drivers/usb/host/xhci-hcd.ko kernel/drivers/usb/host/xhci-pci.ko kernel/drivers/usb/mon/usbmon.ko kernel/drivers/usb/serial/usbserial.ko kernel/drivers/usb/typec/typec.ko kernel/drivers/usb/typec/altmodes/typec_displayport.ko kernel/drivers/usb/typec/ucsi/typec_ucsi.ko kernel/drivers/usb/typec/ucsi/ucsi_acpi.ko kernel/drivers/video/fb.ko kernel/drivers/video/cfbfillrect.ko kernel/drivers/video/cfbcopyarea.ko kernel/drivers/video/cfbimgblt.ko kernel/drivers/video/backlight/backlight.ko kernel/drivers/video/console/fbcon.ko kernel/drivers/video/console/bitblit.ko kernel/drivers/video/console/font.ko kernel/drivers/video/console/softcursor.ko kernel/drivers/video/console/tileblit.ko kernel/drivers/video/console/fbcon_rotate.ko kernel/drivers/video/console/fbcon_cw.ko kernel/drivers/video/console/fbcon_ud.ko kernel/drivers/video/console/fbcon_ccw.ko kernel/drivers/xen/xenbus/xenbus_probe_frontend.ko kernel/arch/x86/pci/vmd.ko kernel/arch/x86/video/fbdev.ko kernel/net/core/drop_monitor.ko kernel/net/core/netprio_cgroup.ko kernel/net/ipv4/inet_lro.ko kernel/net/ipv4/tcp_cubic.ko kernel/net/ipv6/ipv6.ko kernel/net/ipv6/inet6_hashtables.ko kernel/net/mpls/mpls_gso.ko kernel/net/netfilter/x_tables.ko kernel/net/netfilter/xt_tcpudp.ko kernel/net/packet/af_packet.ko kernel/net/sched/cls_cgroup.ko kernel/net/unix/unix.ko kernel/net/xfrm/xfrm_algo.ko kernel/net/xfrm/xfrm_user.ko kernel/lib/test-kstrtox.ko kernel/lib/bitrev.ko kernel/lib/crc16.ko kernel/lib/crc32.ko kernel/lib/digsig.ko kernel/lib/asn1_decoder.ko kernel/lib/oid_registry.ko kernel/lib/ucs2_string.ko kernel/lib/lzo/lzo_compress.ko kernel/lib/lzo/lzo_decompress.ko kernel/lib/mpi/mpi.ko kernel/lib/xz/xz_dec.ko kernel/lib/zlib_deflate/zlib_deflate.ko kernel/lib/zlib_inflate/zlib_inflate.ko
可加载驱动所在目录
在 /sys/module目录下,你可以找到内核模块(包含内置和可加载的)命名的子目录
进入每个模块目录,这里有个“parameters”目录,列出了这个模块所有的参数。
[root@ht5 src]# cd /sys/module [root@ht5 module]# ls 8250 cryptd hid ipt_REJECT nf_conntrack ppdev suspend vmw_vsock_vmci_transport ablk_helper debug_core hid_apple ip_tunnel nf_conntrack_ipv4 printk syscopyarea vmxnet3 acpi dm_log hid_magicmouse ipv6 nf_conntrack_ipv6 processor sysfillrect vsock acpiphp dm_mirror hid_ntrig ip_vs nf_conntrack_netlink psmouse sysimgblt vt aesni_intel dm_mod i2c_piix4 joydev nf_defrag_ipv4 pstore sysrq watchdog ata_generic dm_region_hash i8042 kdb_main nf_defrag_ipv6 rcupdate tcp_cubic workqueue ata_piix drm intel_idle kernel nf_nat rcutree thermal xfs battery drm_kms_helper intel_ishtp keyboard nf_nat_ipv4 rng_core tpm xhci_hcd block drm_panel_orientation_quirks iosf_mbi kgdboc nf_nat_ipv6 sb_edac tpm_tis xt_addrtype bridge dynamic_debug ip6table_nat kgdbts nf_nat_masquerade_ipv4 scsi_dh_alua tpm_tis_core xt_comment br_netfilter edac_core ip6_tables libata nf_reject_ipv4 scsi_dh_rdac ttm xt_conntrack cdrom efi_pstore ipip libcrc32c overlay scsi_mod tunnel4 xt_mark configfs efivars ip_set llc parport scsi_transport_sas uhci_hcd xt_multiport coretemp ehci_hcd ip_set_hash_ip lrw parport_pc sd_mod usbcore xt_nat cpuidle fb_sys_fops ip_set_hash_net md_mod pata_acpi serio_raw usbhid xt_recent crc32c_intel firmware_class iptable_filter module pcie_aspm sg uv_nmi xt_set crc32_pclmul gf128mul iptable_mangle mousedev pciehp shpchp veth xt_statistic crc_t10dif ghash_clmulni_intel iptable_nat mptbase pci_hotplug spurious vmd xz_dec crct10dif_common glue_helper iptable_raw mptsas pci_slot sr_mod vmw_balloon zswap crct10dif_generic haltpoll ip_tables mptscsih pcmcia_core stp vmwgfx crct10dif_pclmul mydriver ipt_MASQUERADE netpoll pcspkr sunrpc vmw_vmci
小结这里有几个目录
/usr/src/kernels/3.10.0-1160.59.1.el7.x86_64/ 开发的内核头文件所在目录 /lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/ 动态加载驱动所在目录 /sys/module 动态和内置驱动所在目录
顺便可以看看深入网卡这篇 https://www.cnblogs.com/aozhejin/p/16057226.html
参考
http://kojipkgs.fedoraproject.org/packages/kernel/2.6.26.6/49.fc8/src/kernel-2.6.26.6-49.fc8.src.rpm
http://ftp.osuosl.org/pub/elrepo/kernel/el7/x86_64/RPMS/