- #include <linux/module.h>
- #include <linux/init.h>
- #include <linux/kernel.h>
- #include <linux/types.h>
- #include <linux/list.h>
- #include <linux/spinlock.h>
- #include <linux/kdev_t.h>
- #include <linux/fs.h>
- #define SUPER_BLOCKS 0xffffffff81c41c10
- #define SB_LOCK 0xffffffff81f03c20
- static int __init my_init(void)
- {
- struct super_block *sb;
- struct list_head *pos;
- struct list_head *lnode;
-
- printk("super_blocks:\n");
- spin_lock((spinlock_t *)SB_LOCK); //加锁
-
- list_for_each(pos,(struct list_head *)SUPER_BLOCKS) {
- sb = list_entry(pos,struct super_block,s_list);
- printk("name---->%s\t\t",sb->s_type->name);
- printk("dev_t %d:%d\n",MAJOR(sb->s_dev),MINOR(sb->s_dev));
- }
- spin_unlock((spinlock_t *)SB_LOCK); //解锁
- return 0;
- }
- lwp@lwp-linux:~$ sudo cat /proc/kallsyms |grep super_blocks
- [sudo] password for lwp:
- c182928c D super_blocks
- lwp@lwp-linux:~$ sudo cat /proc/kallsyms |grep sb_block
- c11be410 t get_sb_block
- c11dc750 t get_sb_block
我们也可以打印索引结点号,代码如下:
- list_for_each(linode,&sb->s_inodes){
- pinode=list_entry(linode,struct inode,i_sb_list);
- count++;
- printk("%lu\t",pinode->i_ino);
- }