Linux系统调用设备的ioctl函数
来源:才华咖 本文已影响2.76W人
来源:才华咖 本文已影响2.76W人
在命令行调用设备的ioctl函数。在Linux系统中,似乎对设备的直接操作只有ioctl函数了。他接受的参数不是太多,而且都是一一对应的。
blockdev - 从命令行调用区块设备控制程序
blockdev [options] commands devices
blockdev 工具允许从命令行调用区块设备控制程序。
–setro 设置设备为只读
–getro 读取设备是否为只读(成功为1,0则为可读写)
–setrw 设置设别为可读写
–getss 打印设备的扇区大小,通常是512
–getsize 打印设别的'容量,按照一个扇区512个字节计算
–setra N 设置预读扇区(512字节)为N个 readahead to N 512-byte sectors.
–getra 打印readahead(预读扇区)
–flushbufs 刷新缓冲
–rereadpt 重读分区表。
觉得–setro,setrw比较有用,这个mount -o ro(rw)是有区别的,mount是在文件系统这个级别上对某个分区挂载为只读或可读写。而blockdev则是在设别这个级别上设置为只读和可读写。
看下面的命令输出结果就一目了然了。
代码如下:
[root@lancy ~]# blockdev –setro /dev/hda4
[root@lancy ~]# blockdev –getro /dev/hda4
1
[root@lancy ~]# mount /dev/hda4 /misc -o rw
mount: block device /dev/hda4 is write-protected, mounting read-only
[root@lancy ~]# umount /dev/hda4
[root@lancy ~]# blockdev –setrw /dev/hda4
[root@lancy ~]# blockdev –getro /dev/hda4
[root@lancy ~]# mount /dev/hda4 /misc -o rw
[root@lancy ~]# touch /misc/one
[root@lancy ~]# umount /dev/hda4
[root@lancy ~]# mount /dev/hda4 /misc -o ro
[root@lancy ~]# rm -f /misc/one
rm: 无法删除‘/misc/one’: 只读文件系统
entOS 6.7 Linux系统的IP配置方法
在linux系统中安装virtualbox增强功能(增强包)的详细步骤是什么
英语《Module 6 Unit 1 You can play football well》的教案设计
托福英语写作范文:Examinations exert a pernicious influence on educat
Linux系统基础知识:IO调度
PetaLinux操作系统在MicroBlaze系统中的移植解析
Linux认证系统管理:linux下搭建ftp
linux系统设置tomcat自启动
Linux cpuinfo系统详解
Linux系统xlsatom命令如何使用
Zend studio for eclipse中使php可以调用mysql相关函数的设置方
Liu Xiang in a TV Commercial Film英语美文
Linux认证系统管理:linuxmail命令发送邮件失败
红旗Linux系统配置LILO文件的方法
深入介绍Linux操作系统定时调度系统Cron
用待定系数法求二次函数的解析式
PHP执行Linux系统命令函数的方法
关于Linux系统命令中exit与exit的区别
如何解决ghost安装系统本地硬盘显示invalid switch fmount问题
如何在Linux CentOS上编译并安装Clang
linux系统下如何使用assert函数
英语作文 Complaint about the Noise Pollution
在Linux系统中使用lsof命令的教程
Linux应用Window系统的常见问题
如何在Linux系统上安装Eclipse
Unit 5 It must belong to Caral section A英语评课稿
低碳生活英语写作范文:An activity about low carbon living
Linux系统top命令的使用方法介绍
矿井监控系统设备设施管理制度
高二英语Unit 3TheMillionPoundBankNote教案
实用的Linux/Unix系统磁带管理命令
Linux系统中使用数据备份同步工具Rsync的实例讲解
关于SEFC Book I Unit 7 Cultural Relics的教学方案
Unit 1 London is the capital of England说课稿
Linux系统管理:linux修改键盘按键
Win10系统ntoskrnl.exe进程占用大量CPU和内存怎么办
Module 3 Unit 2 I love my pocket calculator说课稿
空调系统优化设计的论文
Linux Mint Cinnamon下使用vino-server配置桌面共享的方法
九年级《unit 6 I like music that I can dance to. Period2》评课稿