《精编》Linux设备驱动程式学习资料

上传人:tang****xu2 文档编号:133273014 上传时间:2020-05-25 格式:DOC 页数:8 大小:45.50KB
返回 下载 相关 举报
《精编》Linux设备驱动程式学习资料_第1页
第1页 / 共8页
《精编》Linux设备驱动程式学习资料_第2页
第2页 / 共8页
《精编》Linux设备驱动程式学习资料_第3页
第3页 / 共8页
《精编》Linux设备驱动程式学习资料_第4页
第4页 / 共8页
《精编》Linux设备驱动程式学习资料_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《《精编》Linux设备驱动程式学习资料》由会员分享,可在线阅读,更多相关《《精编》Linux设备驱动程式学习资料(8页珍藏版)》请在金锄头文库上搜索。

1、nLinux设备驱动程式学习(6)-高级字符驱动程式操作(3)设备文件的访问控制Linux设备驱动程式学习(6)-高级字符驱动程式操作(3)设备文件的访问控制提供访问控制对于一个设备节点来的可靠性来说有时是至关重要的。这部分的内容只是在open和release方法上做些修改,增加一些检查机制既可。 独享设备最生硬的访问控制方式是只允许一个设备一次被一个进程打开(独享),这是个设备驱动最简单的访问控制。实现十分简单,具体的代码看实验源码吧!模块程式链接:scullsingle.tar.gz模块测试程式链接:scullsingle-test.tar.gzARM9实验板的实验现象是:Tekkaman

2、2440SBC2440V4#cd /lib/modules/Tekkaman2440SBC2440V4#insmod scullsingle.koTekkaman2440SBC2440V4#cat /proc/devicesCharacter devices:1 mem2 pty3 ttyp4 /dev/vc/04 tty4 ttyS5 /dev/tty5 /dev/console5 /dev/ptmx7 vcs10 misc13 input14 sound81 video4linux89 i2c90 mtd116 alsa128 ptm136 pts180 usb189 usb_device

3、204 s3c2410_serial252 scullsingle253 usb_endpoint254 rtcBlock devices:1 ramdisk256 rfd7 loop31 mtdblock93 nftl96 inftl179 mmcTekkaman2440SBC2440V4#mknod -m 666 scullsingle c 252 0Tekkaman2440SBC2440V4#cd /tmp/Tekkaman2440SBC2440V4#./scullsingle-test &Tekkaman2440SBC2440V4#open scullsingle is file=3T

4、ekkaman2440SBC2440V4#echo 12345 /dev/scullsingle-sh: cannot create /dev/scullsingle: Device or resource busyTekkaman2440SBC2440V4#cat /dev/scullsinglecat: cant open /dev/scullsingle单用户访问 open 调用在第一次打开记住了设备拥有者,此用户可多次打开设备,并协调多个进程对设备并发操作。同时,没有其他用户可打开他,避免了外部干扰。这个模块我是利用completion模块改的,这要既能实现功能,也方便测试。模块程式链

5、接:completion-singleUID.tar.gz模块测试程式链接:completion-singleUID-test.tar.gzARM9实验板的实验现象是:Tekkaman2440SBC2440V4#insmod /lib/modules/singleUID.koTekkaman2440SBC2440V4#cat /proc/devicesCharacter devices:1 mem2 pty3 ttyp4 /dev/vc/04 tty4 ttyS5 /dev/tty5 /dev/console5 /dev/ptmx7 vcs10 misc13 input14 sound81 v

6、ideo4linux89 i2c90 mtd116 alsa128 ptm136 pts180 usb189 usb_device204 s3c2410_serial252 singleUID253 usb_endpoint254 rtcBlock devices:1 ramdisk256 rfd7 loop31 mtdblock93 nftl96 inftl179 mmcTekkaman2440SBC2440V4#mknod -m 666 /dev/singleUID c 252 0Tekkaman2440SBC2440V4#/tmp/singleUID_testr&Tekkaman2440

7、SBC2440V4#login tekkamanPassword:Set search library path int /etc/profileSet user path in /etc/profileruning /etc/profile okTekkaman2440SBC2440V4#/tmp/singleUID_testwopen singleUID code=-1Tekkaman2440SBC2440V4#/tmp/singleUID_testropen singleUID code=-1Tekkaman2440SBC2440V4#exitTekkaman2440SBC2440V4#

8、/tmp/singleUID_testwwrite code=0Tekkaman2440SBC2440V4#read code=01 + Done /tmp/singleUID_testr阻塞型单用户访问模块程式链接:completion-singleUIDnb.tar.gz模块测试程式链接:completion-singleUIDnb-test.tar.gzARM9实验板的实验现象是:Tekkaman2440SBC2440V4#insmod /lib/modules/singleUIDnb.koTekkaman2440SBC2440V4#cat /proc/devicesCharacter

9、devices:1 mem2 pty3 ttyp4 /dev/vc/04 tty4 ttyS5 /dev/tty5 /dev/console5 /dev/ptmx7 vcs10 misc13 input14 sound81 video4linux89 i2c90 mtd116 alsa128 ptm136 pts180 usb189 usb_device204 s3c2410_serial252 singleUIDnb253 usb_endpoint254 rtcBlock devices:1 ramdisk256 rfd7 loop31 mtdblock93 nftl96 inftl179

10、mmcTekkaman2440SBC2440V4#mknod -m 666 /dev/singleUIDnb c 252 0Tekkaman2440SBC2440V4#/tmp/singleUID_testrnb&Tekkaman2440SBC2440V4#login tekkamanPassword:Set search library path int /etc/profileSet user path in /etc/profileruning /etc/profile okTekkaman2440SBC2440V4#/tmp/singleUID_testrnb &Tekkaman244

11、0SBC2440V4#/tmp/singleUID_testwnb &Tekkaman2440SBC2440V4#exitTekkaman2440SBC2440V4#psPID Uid VSZ Stat Command 1 root 1744 S init 2 root SW kthreadd 3 root SWN ksoftirqd/0 4 root SW watchdog/0 5 root SW events/0 6 root SW khelper 59 root SW kblockd/0 60 root SW ksuspend_usbd 63 root SW khubd 65 root

12、SW kseriod 77 root SW pdflush 78 root SW pdflush 79 root SW kswapd0 80 root SW aio/0707 root SW mtdblockd708 root SW nftld709 root SW inftld710 root SW rfdd742 root SW kpsmoused751 root SW kmmcd769 root SW rpciod/0778 root 1752 S -sh779 root 1744 S init781 root 1744 S init782 root 1744 S init783 roo

13、t 1744 S init814 root 1336 D /tmp/singleUID_testrnb816 tekkaman 1336 S /tmp/singleUID_testrnb817 tekkaman 1336 S /tmp/singleUID_testwnb818 root 1744 R psTekkaman2440SBC2440V4#/tmp/singleUID_testwnb&Tekkaman2440SBC2440V4#read code=0write code=0write code=0read code=02 + Done /tmp/singleUID_testwnb1 +

14、 Done /tmp/singleUID_testrnbTekkaman2440SBC2440V4#psPID Uid VSZ Stat Command 1 root 1744 S init 2 root SW kthreadd 3 root SWN ksoftirqd/0 4 root SW watchdog/0 5 root SW events/0 6 root SW khelper 59 root SW kblockd/0 60 root SW ksuspend_usbd 63 root SW khubd 65 root SW kseriod 77 root SW pdflush 78 ro

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号