日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

/dev、/sys/dev 和/sys/devices 和udev的关系

發布時間:2025/4/16 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 /dev、/sys/dev 和/sys/devices 和udev的关系 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

/dev,設備文件存儲目錄,應用程序通過對這些文件的讀寫和控制,可以訪問實際的設備;


/sys/devices目錄,按照設備掛接的總線類型,組織成層次結構,保存了系統所有的設備;是文件系統管理設備的最重要的目錄結構;

這是內核設備按總線類型分層放置的目錄結構, devices 中的所有設備都是連接于某種總線之下,在這里的每一種具體總線之下可以

找到每一個具體設備的符號鏈接,它也是構成 Linux 統一設備模型的一部分;


/sys/dev下有兩個子目錄,block和char,存放的是塊設備和字符設備的主次號碼,形式為(major:minor),它指向/sys/devices目錄下的

設備。


一直沒有認真看過sysfs的文檔,所以一直就迷迷糊糊的不知道/sys/dev和/sys/devices到底啥關系,另外對于udev也是一知半解。懶啊...

?

終于遇到了問題,不得不看看文檔,總結了下:

?

sysfsintroduction:

----------------------------

sysfs is amechanism for representing kernel objects, their attributes, and theirrelationships

with each other.

?

It provides twocomponents: a kernel programming interface for exporting these items via sysfs,and a user interface to view and manipulate these items that maps back to thekernel objects which they represent.

?

The table belowshows the mapping between internel (kernel) constructs and their external

(userspace) sysfsmappings.

---------------------------------------

|Internal???????????? | External????? |

---------------------------------------

|KernelObjects?????? | Directories?? |

---------------------------------------

|ObjectAttributes??? | Regular Files |

---------------------------------------

|ObjectRelationships | Symbolic Links|

---------------------------------------

(Reference:http://www.kernel.org/pub/linux/kernel/people/mochel/doc/papers/ols-2005/mochel.pdf)

?

/sys/dev:

------------------

Contains twodirectories char/ and block/. Inside these two directories there are symlinksnamed <major>:<minor>. These symlinks point to the sysfs directoryfor the given device. /sys/dev provides a quick way to lookup the sysfsinterface for a device from the result of a stat(2) operation.

?

Example:

root@AuxLinux:/sys#ls -l dev/block/8:1

lrwxrwxrwx 1 rootroot 0 2011-08-26 10:13 dev/block/8:1 ->../../devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0/block/sda/sda1

root@AuxLinux:/sys#stat /dev/sda1

? File: `/dev/sda1'

? Size: 0?????????????? Blocks: 0????????? IO Block: 4096?? block special file

Device: 5h/5d?? Inode: 5484??????? Links: 1???? Device type: 8,1

Access:(0660/brw-rw----)? Uid: (??? 0/???root)?? Gid: (??? 6/???disk)

Access: 2011-08-2418:25:02.902025252 +0800

Modify: 2011-08-1815:14:17.281472005 +0800

Change: 2011-08-1815:14:17.281472005 +0800

?

/sys/devices:

----------------------------

Contains afilesystem representation of the device tree. It maps directly to the internalkernel device tree, which is a hierarchy of struct device.

?

udev:

-----------------------------

udev is a devicemanagement 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 informsthe udevd daemon when certain events happen. The udevd daemon is configured torespond to some events with actions. Always, it means adding/removing devicefile under /dev dynamically.



總結

以上是生活随笔為你收集整理的/dev、/sys/dev 和/sys/devices 和udev的关系的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。