Chinaunix

标题: 请教大家有什么地方可以看到内核代码里面每个变量的作用说明吗?先谢谢大家了。 [打印本页]

作者: wali66    时间: 2016-10-05 19:27
标题: 请教大家有什么地方可以看到内核代码里面每个变量的作用说明吗?先谢谢大家了。
比如 kernfs_node这个结构体中有些成员没有注释。我想知道各个成员的用途或者目的。比如void* priv
98  * kernfs_node - the building block of kernfs hierarchy.  Each and every
99  * kernfs node is represented by single kernfs_node.  Most fields are
100  * private to kernfs and shouldn't be accessed directly by kernfs users.
101  *
102  * As long as s_count reference is held, the kernfs_node itself is
103  * accessible.  Dereferencing elem or any other outer entity requires
104  * active reference.
105  */
106 struct kernfs_node {
107         atomic_t                count;
108         atomic_t                active;
109 #ifdef CONFIG_DEBUG_LOCK_ALLOC
110         struct lockdep_map      dep_map;
111 #endif
112         /*
113          * Use kernfs_get_parent() and kernfs_name/path() instead of
114          * accessing the following two fields directly.  If the node is
115          * never moved to a different parent, it is safe to access the
116          * parent directly.
117          */
118         struct kernfs_node      *parent;
119         const char              *name;
120
121         struct rb_node          rb;
122
123         const void              *ns;    /* namespace tag */
124         unsigned int            hash;   /* ns + name hash */
125         union {
126                 struct kernfs_elem_dir          dir;
127                 struct kernfs_elem_symlink      symlink;
128                 struct kernfs_elem_attr         attr;
129         };
130
131         void                    *priv;
132
133         unsigned short          flags;
134         umode_t                 mode;
135         unsigned int            ino;
136         struct kernfs_iattrs    *iattr;
137 };

作者: wlforyou1    时间: 2016-10-06 08:57
需要到网上查资料。
作者: wali66    时间: 2016-10-16 22:07
wlforyou1 发表于 2016-10-06 08:57
需要到网上查资料。

我只看到部分的说明,一个结构体中有部分变量是没有说明的。比如struct sysfs_buffer {
  55        size_t                  count;
  56        loff_t                  pos;
  57        char                    * page;
  58        struct sysfs_ops        * ops;
  59        struct semaphore        sem;
  60        int                     needs_read_fill;
  61        int                     event;
  62};

这里面的event

作者: MMMIX    时间: 2016-10-16 23:02
回复 1# wali66

这你只能看用到它们的代码了。

作者: wali66    时间: 2016-10-18 22:04
MMMIX 发表于 2016-10-16 23:02
回复 1# wali66

这你只能看用到它们的代码了。

谢谢~ 还有就是发现一个结构体的定义有些变化比如kset(不同 内核版本)但是不知道为什么有这个变化

作者: MMMIX    时间: 2016-10-19 21:12
回复 5# wali66

还有就是发现一个结构体的定义有些变化比如kset(不同 内核版本)但是不知道为什么有这个变化


看对应的 commit message

作者: wali66    时间: 2016-10-20 21:09
MMMIX 发表于 2016-10-19 21:12
回复 5# wali66

好的,谢谢

作者: shang2010    时间: 2016-10-21 14:42
一般变量名就是注释意思,h头文件基本够了
作者: wali66    时间: 2016-10-22 23:28
回复 8# shang2010

谢谢~




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2