"sysfs is a ram-based filesystem initially based on ramfs. It provides a means
to export kernel data structures, their attributes, and the linkages between them to
userspace.” --- documentation/filesystems/sysfs.txt
可以先把documentation/filesystems/sysfs.txt讀一遍。文檔這種東西,真正讀起來就嫌少了。Sysfs文件系統是一個類似于proc文件系統的特殊文件系統,用于將系統中的設備組織成層次結構,并向用戶模式程序提供詳細的內核數據結構信息。
去/sys看一看,
localhost:/sys#ls /sys/
block/ bus/ class/ devices/ firmware/ kernel/ module/ power/
Block目錄:包含所有的塊設備
Devices目錄:包含系統所有的設備,并根據設備掛接的總線類型組織成層次結構
Bus目錄:包含系統中所有的總線類型
Drivers目錄:包括內核中所有已注冊的設備驅動程序
Class目錄:系統中的設備類型(如網卡設備,聲卡設備等)?
sys下面的目錄和文件反映了整臺機器的系統狀況。比如bus,
localhost:/sys/bus#ls
i2c/ ide/ pci/ pci express/ platform/ pnp/ scsi/ serio/ usb/
里面就包含了系統用到的一系列總線,比如pci, ide, scsi, usb等等。比如你可以在usb文件夾中發現你使用的U盤,USB鼠標的信息。
我們要討論一個文件系統,首先要知道這個文件系統的信息來源在哪里。所謂信息來源是指文件組織存放的地點。比如,我們掛載一個分區,
mount -t vfat /dev/hda2 /mnt/C
我們就知道掛載在/mnt/C下的是一個vfat類型的文件系統,它的信息來源是在第一塊硬盤的第2個分區。
但是,你可能根本沒有去關心過sysfs的掛載過程,她是這樣被掛載的。
mount -t sysfs sysfs /sys
ms看不出她的信息來源在哪。sysfs是一個特殊文件系統,并沒有一個實際存放文件的介質。斷電后就玩完了。簡而言之,sysfs的信息來源是kobject層次結構,讀一個sysfs文件,就是動態的從kobject結構提取信息,生成文件。
所以,首先,我要先講一講sysfs文件系統的信息來源 -- kobject層次結構。kobject層次結構就是linux的設備模型。
?牛人博客:http://blog.csdn.net/fudan_abc/article/details/1768277
?
SysFs
V4L2 specifications allow switching output and standard using IOCTLs. FBDev specifications allow
switching of resolutions at the output, but not the output itself. In the past, proprietary IOCTLs were added
in FBDev to allow output switching. Instead of abusing the FBDev interface with proprietary IOCTLs, it was
decided to remove this functionality from V4L2 and FBDev and implement the same functionality as a
SysFs driver attribute. This can be extended to support simple functions like enable/disable display,
control brightness, hue, etc. The LSP 2.00 DaVinci Video Sysfs User's Guide (SPRUG95)explains the
procedure to change the output and standard to work with the current display device.
?