首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

14.块设备驱动

1、字符设备驱动:   当我们的应用层读写(read()/write())字符设备驱动时,是按字节/字符来读写数据的,期间没有任何缓存区,因为数据量小,不能随机读取数据,例如:按键、LED、鼠标、键盘等 2、块设备:   块设备是i/o设备中的一类, 当我们的应用层对该设备读写时,是按扇区大小来读写数据的,若读写的数据小于扇区的大小,就会需要缓存区, 可以随机读写设备的任意位置处的数据,例如 普通文件(.txt,.c等),硬盘,U盘,SD卡。 3、块设备结构: 段(Segments):由若干个块组成。是Linux内存管理机制中一个内存页或者内存页的一部分。 块 (Blocks): 由Linux制定对内核或文件系统等数据处理的基本单位。通常由1个或多个扇区组成。(对Linux操作系统而言) 扇区(Sectors):块设备的基本单位。通常在512字节到32768字节之间,默认512字节 应用程序进行文件的读写,通过文件系统将文件的读写转换为块设备驱动操作硬件。

03
您找到你想要的搜索结果了吗?
是的
没有找到

Day2 Linux登录和操作(个人理解简易版)

``` R pwd #显示当前路径 bio02@ecm-cefa:~$ pwd /home/bio02 mkdir #创建目录 bio02@ecm-cefa:~$ mkdir hello ls #显示列表 bio02@ecm-cefa:~$ ls biosoft hello project src tmp #除了四个已有目录,新增一个hello目录 rm #删文件 rmdir #删空目录 rm -r #删非空目录(删除统一展示了,如下,因为不会随意切换目录,导致删除要挨个进入目录删) bio02@ecm-cefa:~$ rm -r tmp bio02@ecm-cefa:~$ mkdir tmp bio02@ecm-cefa:~$ cd tmp bio02@ecm-cefa:~/tmp$ mkdir rm_test bio02@ecm-cefa:~/tmp$ cd rm_test bio02@ecm-cefa:~/tmp/rm_test$ mkdir huahua bio02@ecm-cefa:~/tmp/rm_test$ cd huahua bio02@ecm-cefa:~/tmp/rm_test/huahua$ touch doodle.txt bio02@ecm-cefa:~/tmp/rm_test/huahua$ rm doodle.txt bio02@ecm-cefa:~/tmp/rm_test/huahua$ cd bio02@ecm-cefa:~$ cd tmp bio02@ecm-cefa:~/tmp$ cd rm_test bio02@ecm-cefa:~/tmp/rm_test$ rmdir huahua bio02@ecm-cefa:~/tmp/rm_test$ cd bio02@ecm-cefa:~$ cd tmp bio02@ecm-cefa:~/tmp$ rmdir rm_test bio02@ecm-cefa:~/tmp$ cd #进入目录 bio02@ecm-cefa:~$ cd tmp vi #建脚本或文档 bio02@ecm-cefa:~/tmp/new$ vi hello_world.txt cat #查看文档并展示到屏幕 bio02@ecm-cefa:~/tmp/new$ cat hello_world.txt i today is a good day,i meet my boyfriend,he is older than me,he finished his work then meet me.we have a good time. head #输出前十行(然而我只发挥了一行) bio02@ecm-cefa:~/tmp/new$ head hello_world.txt i today is a good day,i meet my boyfriend,he is older than me,he finished his work then meet me.we have a good time. tail #输出后十行(如上括号所言) bio02@ecm-cefa:~/tmp/new$ tail hello_world.txt i today is a good day,i meet my boyfriend,he is older than me,he finished his work then meet me.we have a good time. head -n #数字 自定义输出几行 bio02@ecm-cefa:~/tmp/new$ head -n 2 hello_world.txt i today is a good day,i meet my boyfriend,he is older than me,he finished his work then meet me.we have a good time. cp #复制 bio02@ecm-cefa:~/tmp/new$ cp hello_world.txt hello_boy mv #移动 bio02@ecm-cefa:~/tmp/new$ mv hello_world.txt tmp bio02@ecm-cefa:~/tmp/new$ ```

02

Linux内核(5.10)-IO全路径-文件系统到磁盘-或远端iscsi/nvmeof协议盘

DAX: 磁盘(disk)的访问模式有三种 BUFFERED、DIRECT、DAX。前面提到的由于page cache存在可以避免耗时的磁盘通信就是BUFFERED访问模式的集中体现;但是如果我要求用户的write请求要实时存储到磁盘里,不能只在内存中更新,那么此时我便需要DIRECT模式;大家可能听说过flash分为两种nand flash和nor flash,nor flash可以像ram一样直接通过地址线和数据线访问,不需要整块整块的刷,对于这种场景我们采用DAX模式。所以file_operations的read_iter和write_iter回调函数首先就需要根据不同的标志判断采用哪种访问模式, kernel在2020年12月的patch中提出了folio的概念,我们可以把folio简单理解为一段连续内存,一个或多个page的集合

01
领券