A question about fs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Everyone:
      The first time to study fs ,and write a simple module to traverse the double list with super_block.
and the output of module is different with the result from the command cat /proc/filesystems.
 the output fs of module is 23,and the output fs of cat /proc/filesystems is 26. why?
 
 My Environments:
# uname -r
2.6.39.1
# lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 11.04
Release:    11.04
Codename:    natty
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)

my code is as followed:

#include<linux/module.h>
#include<linux/init.h>
#include<linux/sched.h>
#include <linux/fs.h>
#include <linux/list.h>
#include <linux/spinlock.h>

#define addr_super_blocks 0xc173d0a0
#define addr_sb_lock      0xc18f3ba0

#ifndef offsetof
#define offsetof(type, field)   ((long) &((type *)0)->field)
#endif   /* offsetof */
 
#ifndef container_of
#define container_of(ptr, type, member) ({                      \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
#endif


static __init int sbinfo_init(void)
{
    struct list_head *p;
    int count = 0;
    struct super_block *sb;

    spin_lock((spinlock_t *)addr_sb_lock);
    p = (struct list_head *)addr_super_blocks;
    p = p->next;
    for (;p != (struct list_head *)addr_super_blocks;p = p->next) {
           sb = container_of(p,struct super_block,s_list);
       printk("<0>filesystem name:%s\n",sb->s_type->name);
           count++;
    }    
    spin_unlock((spinlock_t *)addr_sb_lock);
    printk("<0>----------------->%d\n",count);
    return 0;
}


static __exit void sbinfo_exit(void)
{
    printk("<0> bye! \n");
}

module_init(sbinfo_init);
module_exit(sbinfo_exit);
MODULE_LICENSE("GPL");

and output:
[ 4196.218726] filesystem name:sysfs
[ 4196.218732] filesystem name:rootfs
[ 4196.218735] filesystem name:bdev
[ 4196.218737] filesystem name:proc
[ 4196.218740] filesystem name:tmpfs
[ 4196.218742] filesystem name:devtmpfs
[ 4196.218745] filesystem name:debugfs
[ 4196.218747] filesystem name:sockfs
[ 4196.218750] filesystem name:pipefs
[ 4196.218752] filesystem name:anon_inodefs
[ 4196.218755] filesystem name:securityfs
[ 4196.218757] filesystem name:devpts
[ 4196.218760] filesystem name:hugetlbfs
[ 4196.218762] filesystem name:mqueue
[ 4196.218765] filesystem name:sysfs
[ 4196.218767] filesystem name:fusectl
[ 4196.218769] filesystem name:ext4
[ 4196.218771] filesystem name:tmpfs
[ 4196.218774] filesystem name:tmpfs
[ 4196.218776] filesystem name:tmpfs
[ 4196.218778] filesystem name:ext4
[ 4196.218780] filesystem name:fuse
[ 4196.218783] filesystem name:binfmt_misc
[ 4196.218786] ----------------->23

and cat /proc/filesystems output:
nodev    sysfs
nodev    rootfs
nodev    bdev
nodev    proc
nodev    cgroup
nodev    cpuset
nodev    tmpfs
nodev    devtmpfs
nodev    debugfs
nodev    securityfs
nodev    sockfs
nodev    pipefs
nodev    anon_inodefs
nodev    devpts
             ext3
             ext2
             ext4
nodev    ramfs
nodev    hugetlbfs
nodev    ecryptfs
nodev    fuse
             fuseblk
nodev    fusectl
nodev    pstore
nodev    mqueue
nodev    binfmt_misc

if anyone knows please help .Thanks
--
----------------------------------------------------------------------------------------------
WangZhe  Xi'an Shanxi CHINA
qq                             785924174
blog                           blog.163.com/zhe_wang_2009
----------------------------------------------------------------------------------------------
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux