一步一步粗谈linux文件系统(七)----sysfs概述

Sysfs 是 Linux 2.6所提供的一种虚拟文件系统。这个文件系统不仅可以把设备(devices)和驱动程序(drivers) 的信息从内核输出到用户空间,也可以用来对设备和驱动程序做设置。

 

procfs太过于混乱,不利于查看设备驱动信息。sysfs 的目的是把一些原本在 procfs中的,关于设备的部份,独立出来,以‘设备层次结构架构’(device tree)的形式呈现

 


The sysfs directoryarrangement exposes the relationship of kernel

data structures.

The top level sysfsdirectory looks like:

block/

bus/

class/

devices/

firmware/

net/

fs/

 

devices/ contains afilesystem representation of the device tree. It maps

directly to theinternal kernel device tree, which is a hierarchy of

struct device.

 

bus/ contains flatdirectory layout of the various bus types in the

kernel. Each bus'sdirectory contains two subdirectories:

 

devices/

drivers/

 

devices/ containssymlinks for each device discovered in the system

that point to thedevice's directory under root/.

 

drivers/ contains adirectory for each device driver that is loaded

for devices on thatparticular bus (this assumes that drivers do not

span multiple bustypes).

 

fs/ contains adirectory for some filesystems. Currently each

filesystem wantingto export attributes must create its own hierarchy

below fs/ (see./fuse.txt for an example).

 

 

More information candriver-model specific features can be found in

Documentation/driver-model/.

 

 

TODO: Finish thissection.

 

摘自Doc/filesystem/sysfs.txt

 

关于sysfs,首先要搞清楚,ksetkobject

 

-kobjects        a simple object.

-kset                aset of objects of a certain type.

-ktype                aset of helpers for objects of a common type.

-subsystem        a controlling objectfor a number of ksets.

 

struct kobject {

char                        name[KOBJ_NAME_LEN]; //名字

atomic_t                refcount; //引用数

structlist_head        entry; //kobject之间的双向链表,用于跟所属kset形成环形链表

structkobject                *parent; //它的父kobject

structkset                *kset; //所属的kset

structkobj_type        * ktype; //负责对该kobject类型进行跟踪的struct

structdentry                *dentry;//目录

};

 

struct kset {

structsubsystem        * subsys;

structkobj_type        * ktype; //指向该kset对象类型的指针

structlist_head        list; //与它所含的kobject形成环形链表

spinlock_t                list_lock;

structkobject                kobj; //它自己也是个object

structkset_uevent_ops        * uevent_ops; //ops

};



上面两张图,谷歌而得的,很赞

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值