博客
关于我
Linux /dev目录设备文件
阅读量:799 次
发布时间:2023-01-31

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

在Linux系统中,硬件设备通常以文件形式存在,这种文件被称为设备文件。设备文件在操作系统与外部设备之间建立了桥梁,使得用户能够像操作普通文件一样操作外部设备。

设备文件的接口

设备文件的操作与普通文件类似,可以通过文件描述符进行操作。常用的接口包括:

  • int open(const char *path, int oflag, ...)
  • int close(int fd)
  • ssize_t write(int fd, const void *buf, size_t nbyte)
  • ssize_t read(int fd, void *buf, size_t nbyte)
  • int ioctl(int d, int request, ...)

这些接口提供了基本的设备操作功能。设备驱动可以动态加载和删除,具体操作可通过以下命令进行管理:

  • lsmod:查看已加载的模块
  • insmod <module_file>:加载指定模块
  • modprobe <module>:加载指定模块及依赖
  • rmmod <module>:卸载指定模块

常见设备文件命名规律

设备文件的命名方式各有特点:

  • 软驱(/dev/fd):fd0代表第一软盘,fd1代表第二软盘。
  • IDE 磁盘(/dev/hd):用于IDE接口的磁盘设备。
  • SCSI 磁盘(/dev/sd):SCSI接口的磁盘设备,例如sda代表第一块SCSI磁盘,sdc5代表第三块SCSI设备的第五个逻辑分区。
  • 终端(/dev/tty):用于虚拟终端或物理终端设备。
  • 虚拟磁盘(/dev/vd):用于virtio-block类型的设备,命名规则较为特殊,例如vda、vdX等。

设备文件的命名并非固定,随着设备加载或系统重启,设备文件的命名可能会发生变化。

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

你可能感兴趣的文章
Nmap渗透测试指南之指纹识别与探测、伺机而动
查看>>
Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
查看>>
NMAP网络扫描工具的安装与使用
查看>>
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>