/dev、/sys/devices 和 /sys/dev 之间区别

/dev,设备文件存储目录,应用程序通过对这些文件的读写和控制,可以访问实际的设备;


/sys/devices 目录,按照设备挂接的总线类型,组织成层次结构,保存了系统所有的设备;是文件系统管理设备的最重要的目录结构;这是内核设备按总线类型分层放置的目录结构, devices 中的所有设备都是连接于某种总线之下,在这里的每一种具体总线之下可以找到每一个具体设备的符号链接,它也是构成 Linux 统一设备模型的一部分;


/sys/dev 下有两个子目录,block和char,存放的是块设备和字符设备的主次号码,形式为(major:minor),它指向 /sys/devices 目录下的设备。


1. sysfs的挂载点是/sys目录, sysfs是一个虚拟的文件系统(还有其它的虚拟文件系统,例如usbfs和procfs),sysfs导出了内核的数据结构。
2. /sys/dev/ 和/sys/devices是sysfs按面向对象管理的思想来组织,sysfs最主要是用来描绘Linux kernel 2.6中的设备驱动模型,用户态的后台程序会动态地周期性的扫描/sys目录中的属性项来自动管理设备文件(也称为设备节点),从而在/dev目录会建立或者删除对应的设备文件。


Documentation\filesystems


  1. Top Level Directory Layout  
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~  
  3.   
  4. The sysfs directory arrangement exposes the relationship of kernel  
  5. data structures.   
  6.   
  7. The top level sysfs directory looks like:  
  8.   
  9. block/  
  10. bus/  
  11. class/  
  12. dev/  
  13. devices/  
  14. firmware/  
  15. net/  
  16. fs/  
  17.   
  18. devices/ contains a filesystem representation of the device tree. It maps  
  19. directly to the internal kernel device tree, which is a hierarchy of  
  20. struct device.  
  21.   
  22. bus/ contains flat directory layout of the various bus types in the  
  23. kernel. Each bus's directory contains two subdirectories:  
  24.   
  25.     devices/  
  26.     drivers/  
  27.   
  28. devices/ contains symlinks for each device discovered in the system  
  29. that point to the device's directory under root/.  
  30.   
  31. drivers/ contains a directory for each device driver that is loaded  
  32. for devices on that particular bus (this assumes that drivers do not  
  33. span multiple bus types).  
  34.   
  35. fs/ contains a directory for some filesystems.  Currently each  
  36. filesystem wanting to export attributes must create its own hierarchy  
  37. below fs/ (see ./fuse.txt for an example).  
  38.   
  39. dev/ contains two directories char/ and block/. Inside these two  
  40. directories there are symlinks named <major>:<minor>.  These symlinks  
  41. point to the sysfs directory for the given device.  /sys/dev provides a  
  42. quick way to lookup the sysfs interface for a device from the result of  
  43. a stat(2) operation.  
  44.   
  45. More information can driver-model specific features can be found in  
  46. Documentation/driver-model/.   



  1. udev:  
  2. -----------------------------  
  3. udev is a device management framework that replaced the devfs facility in the Linux 2.6 kernel. It is composed of some kernel services and the udevd daemon. The kernel informs the udevd daemon when certain events happen. The udevd daemon is configured to respond to some events with actions. Always, it means adding/removing device file under /dev dynamically.  
  4.   
  5. * When the kernel detects that a device has been added or removed, a uevent is sent to  
  6. the udevd daemon through a netlink socket  
  7. * When udevd receives the uevent, it matches its configured rules against the available  
  8. device attributes provided in sysfs  
  9. * If a match is found, one or more actions (e.g., create device node, remove device node,  
  10. install firmware, etc.) are taken  



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值