Hello Everyone:<br>      The first time to study fs ,and write a simple module to traverse the double list with super_block.<br>and the output of module is different with the result from the command cat /proc/filesystems.<br>
 the output fs of module is 23,and the output fs of cat /proc/filesystems is 26. why?<br> <br> My Environments:<br>
# uname -r<br>
2.6.39.1<br>
# lsb_release -a<br>
No LSB modules are available.<br>Distributor ID:    Ubuntu<br>Description:    Ubuntu 11.04<br>Release:    11.04<br>Codename:    natty<br>
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)<br clear="all"><br>my code is as followed:<br><br>#include&lt;linux/module.h&gt;<br>#include&lt;linux/init.h&gt;<br>#include&lt;linux/sched.h&gt;<br>#include &lt;linux/fs.h&gt;<br>
#include &lt;linux/list.h&gt;<br>#include &lt;linux/spinlock.h&gt;<br><br>#define addr_super_blocks 0xc173d0a0 <br>#define addr_sb_lock      0xc18f3ba0<br><br>#ifndef offsetof <br>#define offsetof(type, field)   ((long) &amp;((type *)0)-&gt;field) <br>
#endif   /* offsetof */ <br> <br>#ifndef container_of <br>#define container_of(ptr, type, member) ({                      \<br>        const typeof( ((type *)0)-&gt;member ) *__mptr = (ptr);    \<br>        (type *)( (char *)__mptr - offsetof(type,member) );})<br>
#endif <br><br><br>static __init int sbinfo_init(void)<br>{<br>    struct list_head *p;<br>    int count = 0;<br>    struct super_block *sb;<br><br>    spin_lock((spinlock_t *)addr_sb_lock);<br>    p = (struct list_head *)addr_super_blocks;<br>
    p = p-&gt;next;<br>    for (;p != (struct list_head *)addr_super_blocks;p = p-&gt;next) {<br>           sb = container_of(p,struct super_block,s_list);<br>       printk(&quot;&lt;0&gt;filesystem name:%s\n&quot;,sb-&gt;s_type-&gt;name);<br>
           count++;<br>    }     <br>    spin_unlock((spinlock_t *)addr_sb_lock);<br>    printk(&quot;&lt;0&gt;-----------------&gt;%d\n&quot;,count);<br>    return 0;<br>}<br><br><br>static __exit void sbinfo_exit(void)<br>
{<br>    printk(&quot;&lt;0&gt; bye! \n&quot;);<br>}<br><br>module_init(sbinfo_init);<br>module_exit(sbinfo_exit);<br>MODULE_LICENSE(&quot;GPL&quot;);<br><br>and output:<br>[ 4196.218726] filesystem name:sysfs<br>[ 4196.218732] filesystem name:rootfs<br>
[ 4196.218735] filesystem name:bdev<br>[ 4196.218737] filesystem name:proc<br>[ 4196.218740] filesystem name:tmpfs<br>[ 4196.218742] filesystem name:devtmpfs<br>[ 4196.218745] filesystem name:debugfs<br>[ 4196.218747] filesystem name:sockfs<br>
[ 4196.218750] filesystem name:pipefs<br>[ 4196.218752] filesystem name:anon_inodefs<br>[ 4196.218755] filesystem name:securityfs<br>[ 4196.218757] filesystem name:devpts<br>[ 4196.218760] filesystem name:hugetlbfs<br>[ 4196.218762] filesystem name:mqueue<br>
[ 4196.218765] filesystem name:sysfs<br>[ 4196.218767] filesystem name:fusectl<br>[ 4196.218769] filesystem name:ext4<br>[ 4196.218771] filesystem name:tmpfs<br>[ 4196.218774] filesystem name:tmpfs<br>[ 4196.218776] filesystem name:tmpfs<br>
[ 4196.218778] filesystem name:ext4<br>[ 4196.218780] filesystem name:fuse<br>[ 4196.218783] filesystem name:binfmt_misc<br>[ 4196.218786] -----------------&gt;23<br><br>and cat /proc/filesystems output:<br>nodev    sysfs<br>
nodev    rootfs<br>nodev    bdev<br>nodev    proc<br>nodev    cgroup<br>nodev    cpuset<br>nodev    tmpfs<br>nodev    devtmpfs<br>nodev    debugfs<br>nodev    securityfs<br>nodev    sockfs<br>nodev    pipefs<br>nodev    anon_inodefs<br>
nodev    devpts<br>             ext3<br>             ext2<br>             ext4<br>nodev    ramfs<br>nodev    hugetlbfs<br>nodev    ecryptfs<br>nodev    fuse<br>             fuseblk<br>nodev    fusectl<br>nodev    pstore<br>
nodev    mqueue<br>nodev    binfmt_misc<br><br>if anyone knows please help .Thanks<br>-- <br><div>----------------------------------------------------------------------------------------------</div><div>WangZhe  Xi&#39;an Shanxi CHINA</div>
<div>qq                             785924174</div><div>blog                           <a href="http://blog.163.com/zhe_wang_2009" target="_blank">blog.163.com/zhe_wang_2009</a></div><div>----------------------------------------------------------------------------------------------</div>