- 论坛徽章:
- 9
|
回复 1# motorn
你要的东西就在genhd.c这个文件里。- /*
- * aggregate disk stat collector. Uses the same stats that the sysfs
- * entries do, above, but makes them available through one seq_file.
- * Watching a few disks may be efficient through sysfs, but watching
- * all of them will be more efficient through this interface.
- *
- * The output looks suspiciously like /proc/partitions with a bunch of
- * extra fields.
- */
- /* iterator */
- static void *diskstats_start(struct seq_file *part, loff_t *pos)
- {
- loff_t k = *pos;
- struct list_head *p;
- mutex_lock(&block_subsys_lock);
- list_for_each(p, &block_subsys.list)
- if (!k--)
- return list_entry(p, struct gendisk, kobj.entry);
- return NULL;
- }
- static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
- {
- struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
- ++*pos;
- return p==&block_subsys.list ? NULL :
- list_entry(p, struct gendisk, kobj.entry);
- }
- static void diskstats_stop(struct seq_file *part, void *v)
- {
- mutex_unlock(&block_subsys_lock);
- }
复制代码 你太不认真的。你怎么只看diskstats_show,不看和他一套的函数呢。
如果对seq_operations不熟,自己去baidu.com!! |
|