博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
word_count_init_success,ret=0
阅读量:2299 次
发布时间:2019-05-09

本文共 1751 字,大约阅读时间需要 5 分钟。

#include 
#include
#include
#include
#include
#include
// 定义设备文件名#define DEVICE_NAME "wordcount"// 描述与设备文件触发的事件对应的回调函数指针static struct file_operations dev_fops ={ .owner = THIS_MODULE };// 描述设备文件的信息 static struct miscdevice misc ={ .minor = MISC_DYNAMIC_MINOR, .name = DEVICE_NAME, .fops = &dev_fops };// 初始化Linux驱动static int __init word_count_init(void){ int ret; // 建立设备文件 ret = misc_register(&misc); // 输出日志信息 printk("word_count_init_success,ret=%d\n",ret); return ret;}// 卸载Linux驱动static void __exit word_count_exit(void){ // 删除设备文件 misc_deregister(&misc); // 输出日志信息 printk("word_count_init_exit_success\n");} // 注册初始化Linux驱动的函数module_init( word_count_init);// 注册卸载Linux驱动的函数module_exit( word_count_exit);MODULE_AUTHOR("lining");MODULE_DESCRIPTION("statistics of word count.");MODULE_ALIAS("word count module.");MODULE_LICENSE("GPL");

[root@localhost word_count]# rmmod word_count

ERROR: Module word_count does not exist in /proc/modules
[root@localhost word_count]# insmod word_count.ko
[root@localhost word_count]# dmesg | grep word_count 
word_count: no version for "struct_module" found: kernel tainted.
word_count_init_success
word_count_init_exit_success
word_count_init_success
word_count_init_exit_success
word_count_init_success
word_count_init_exit_success
word_count_init_success
word_count_init_exit_success
word_count_init_success,ret=0
[root@localhost word_count]# modinfo word_count.ko
filename:       word_count.ko
license:        GPL
alias:          word count module.
description:    statistics of word count.
author:         lining
srcversion:     B604BC7626027EB7564FDA5
depends:        
vermagic:       2.6.18-53.el5xen SMP mod_unload 686 REGPARM 4KSTACKS gcc-4.1
[root@localhost word_count]# 

转载地址:http://ynkib.baihongyu.com/

你可能感兴趣的文章
C++ STL 排序源码详解(一)
查看>>
C++ STL 排序源码详解(二)
查看>>
各种排序算法的时间复杂度
查看>>
ROC曲线与AUC值
查看>>
Ali开源软件Sentinel的思考 Issue #59:关于线程限流问题的讨论
查看>>
spring boot + spring cache 实现两级缓存(redis + ehcache)
查看>>
GBDT
查看>>
仿射集合与子空间的关系
查看>>
概率波和杨氏双缝干涉
查看>>
笔记2013.09.17
查看>>
笔记2013.09.18
查看>>
Android Studio入门之常见问题
查看>>
Android札记
查看>>
BerkeleyDB--备份机制
查看>>
使用core文件调试程序
查看>>
makefile学习笔记
查看>>
Android 九年,我们需要学什么?
查看>>
iOS 九年,技术迭代迅捷下如何保持核心竞争力?
查看>>
探索跨平台应用开发的最佳实践
查看>>
温故而知新 - AngularJS 1.x
查看>>