Can't access the superblock list.

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

 



Hello Friends,
                    I am developing a stackable file system raif. I want to access the the superblock list 's_list'. The code is as follows:
 
 

static struct super_block * raif_get_sb(struct file_system_type *fs_type,
  int flags, const char *dev_name,void *data)
{
 struct super_block *sb=NULL,*temp_sb=NULL,*raif_sb=NULL;
 struct list_head *ptr=NULL;
/*
 spin_lock(&sb_lock);
 printk("<0>raif_get_sb: Get spin lock\n");
        list_for_each_entry(temp_sb,&super_blocks,s_list){
                spin_unlock(&sb_lock);
                printk("<0>raif_get_sb: list_for_each\n");
                //temp_sb=list_entry(ptr, struct super_block ,s_list);
                if(temp_sb)
                        if(!strcmp(temp_sb->s_type->name,"vfat")){
                                printk("<0>GOT IT !!\n");
                                break;
                }
                spin_lock(&sb_lock);
        }
        spin_unlock(&sb_lock);
*/
 raif_sb= get_sb_nodev(fs_type,flags,data,raif_fill_super);
 
 //code for getting vfat superblock//
 printk("<0>raif_get_sb: get lock\n");
 spin_lock(&sb_lock);
 
 list_for_each(ptr,&raif_sb->s_list){
  printk("<0>raif_get_sb: unlock\n");
  spin_unlock(&sb_lock);
  printk("<0>raif_get_sb: list_for_each\n");
  temp_sb=list_entry(ptr, struct super_block ,s_list); 
  if(temp_sb!=NULL){
   printk("raif_get-sb: fsname= %s",temp_sb->s_type->name);
   if(!strcmp(temp_sb->s_type->name,"vfat")){          //get vfat superblock
    printk("<0>GOT IT !!\n");
    break;
   }
  }
  spin_lock(&sb_lock);
 }
 spin_unlock(&sb_lock);
 raif_sb->s_fs_info= temp_sb;               //store it
 return raif_sb;
}
 
 
 
 
 
/////////////////
I tried it using the two list functions list_for_each, & list_for_each_entry. When i mounted my fs it showed following error:
 
Feb 22 12:37:32 linux kernel: init_raif:- Enter
Feb 22 12:37:39 linux kernel: ramfs_fill_supe: Enterr
Feb 22 12:37:39 linux kernel: root->d_name.name:- /
Feb 22 12:37:39 linux kernel: ramfs_fill_super: call path lookup, /mnt/h
Feb 22 12:37:39 linux kernel: raif_fill_super: Leave
Feb 22 12:37:39 linux kernel: raif_get_sb: get lock
Feb 22 12:37:39 linux kernel: raif_get_sb: unlock
Feb 22 12:37:39 linux kernel: raif_get_sb: list_for_each
Feb 22 12:37:39 linux kernel: Unable to handle kernel NULL pointer dereference at virtual address 00000000
Feb 22 12:37:39 linux kernel:  printing eip:
Feb 22 12:37:39 linux kernel: d088f18a
Feb 22 12:37:39 linux kernel: *pde = 00000000
Feb 22 12:37:39 linux kernel: Oops: 0000 [#1]
Feb 22 12:37:39 linux kernel: Modules linked in: main thinkpad i915 usbserial parport_pc lp parport nvram ipt_TOS ip6t_LOG ip6t_limit ipt_LOG ipt_limit ipt_pkttype speedstep_lib freq_table thermal processor fan button battery ac snd_pcm_oss snd_mixer_oss snd_intel8x0 snd_ac97_codec snd_pcm snd_timer snd soundcore snd_page_alloc ip6t_state ip6_conntrack ipt_state ip6t_REJECT ipt_REJECT iptable_mangle iptable_filter ip6table_mangle ip_nat_ftp iptable_nat ip_conntrack_ftp ip_conntrack ip_tables ip6table_filter ip6_tables ipv6 edd ds yenta_socket pcmcia_core usbhid ehci_hcd evdev joydev sg st sd_mod sr_mod scsi_mod ide_cd cdrom intel_agp agpgart hw_random binfmt_misc uhci_hcd subfs nls_utf8 nls_cp437 vfat fat via_rhine mii dm_mod usbcore ext3 jbd
Feb 22 12:37:39 linux kernel: CPU:    0
Feb 22 12:37:39 linux kernel: EIP:    0060:[<d088f18a>]    Tainted:  G  U VLI
Feb 22 12:37:39 linux kernel: EFLAGS: 00210286   (2.6.8-24-default 20041006091623)
Feb 22 12:37:39 linux kernel: EIP is at raif_get_sb+0x5a/0xd0 [main]
Feb 22 12:37:39 linux kernel: eax: 00000000   ebx: c036b774   ecx: c189ded8   edx: d088f324
Feb 22 12:37:39 linux kernel: esi: d088f324   edi: d088f299   ebp: c036b774   esp: c189ded8
Feb 22 12:37:39 linux kernel: ds: 007b   es: 007b   ss: 0068
Feb 22 12:37:39 linux kernel: Process mount (pid: 5960, threadinfo=c189c000 task=cd16a000)
Feb 22 12:37:39 linux kernel: Stack: c12ef800 00000000 cf264800 d088fac0 c18dc000 c0156f47 c18dc000 c1912000
Feb 22 12:37:39 linux kernel:        c52fc000 00000000 c1535000 c18dc000 c1535004 c52fc000 c01698fa c18dc000
Feb 22 12:37:39 linux kernel:        00000000 00000000 c189df50 c52fc000 c18dc000 c189df50 00000000 c0169ef2
Feb 22 12:37:39 linux kernel: Call Trace:
Feb 22 12:37:39 linux kernel:  [<c0156f47>] do_kern_mount+0x87/0x180
Feb 22 12:37:39 linux kernel:  [<c01698fa>] do_new_mount+0x5a/0x90
Feb 22 12:37:39 linux kernel:  [<c0169ef2>] do_mount+0x172/0x1c0
Feb 22 12:37:39 linux kernel:  [<c013a3b4>] __alloc_pages+0x134/0x3b0
Feb 22 12:37:39 linux kernel:  [<c0169ca6>] exact_copy_from_user+0x26/0x60
Feb 22 12:37:39 linux kernel:  [<c016a26c>] sys_mount+0x6c/0xc0
Feb 22 12:37:39 linux kernel:  [<c0105c69>] sysenter_past_esp+0x52/0x79
Feb 22 12:37:39 linux kernel: Code: 90 3b 1c 24 74 77 68 81 f2 88 d0 89 dd e8 af d8 88 ef c7 04 24 24 f3 88 d0 e8 a3 d8 88 ef 5e 85 db 74 30 8b 43 20 bf 99 f2 88 d0 <8b> 08 51 68 9e f2 88 d0 e8 89 d8 88 ef 58 8b 43 20 5a 8b 30 ac
 
 
/////////////
I want to access the super block list & want vfst super_block.
The same code is working on the other pc having kernel 2.6.8-24-smp(SUSE 10.0).
 
My configuration:
Pentium 2.66
Krypton i845 motherboard
Kernel -2.6.8-24
SUSE 10.0
 
 
I am attaching the code file & make file.
 
 
 
2) Based on this vfat super block i want to access the content of vfat file system(vfat partition on my disk). That means 'ls' on my filesystem mountpoint should be get redirected to vfat & vfat content should be shown. I want to know that which functions(inode operations & file operations) are involved in 'ls'. Are they 'lookup' ,'open', 'readdir'? so that i can modify them.
How should i redirect the 'ls' to point to content of vfat. 

// RAIF source code

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/pagemap.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/string.h>
#include <linux/namei.h>

#define RAIF_MAGIC 0x888888a8;

//extern struct list_head super_blocks;
//extern spinlock_t sb_lock;

/*
struct dentry *lookup(struct inode *dir,struct *dentry,struct nameidata mode){
		
		struct inode *inode;
		struct dentry *lower_dentry;
		
		
}
*/
/*

int raif_open(){
}

*/

struct address_space_operations raif_aops={
	
};

struct super_operations raif_super_ops={
	
};
/*
struct file_operation raif_file_ops={
	//.open		= raif_open,
	//.readdir	= raif_readdir,	
};
*/
struct inode_operations raif_inode_ops={
	//.lookup		= raif_lookup,	
	
};

static int raif_fill_super(struct super_block *sb,void *data,int silent){

	struct inode *inode;
	struct dentry *root;
	struct nameidata nd;
	int err=-1;
	printk("<0>ramfs_fill_supe: Enterr\n");	
	sb->s_maxbytes = MAX_LFS_FILESIZE;
        sb->s_blocksize = PAGE_CACHE_SIZE;
        sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
        sb->s_magic = RAIF_MAGIC;
        sb->s_op = &raif_super_ops;
	//sb->s_type= &raif_fs_type;
	
	
	inode= new_inode(sb);
	if (!inode)
                return -ENOMEM;

		// Set inode attributes
		inode->i_mode = S_IFDIR | 0755 ;
        	inode->i_uid = current->fsuid;
        	inode->i_gid = current->fsgid;
        	inode->i_blksize = PAGE_CACHE_SIZE;
        	inode->i_blocks = 0;
		inode->i_op= &raif_inode_ops;
        	inode->i_mapping->a_ops = &raif_aops;
        	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;

	
        //printk("<0>d_alloc_root: Allocate root dentry\n");
        root = d_alloc_root(inode);
        printk("<0>root->d_name.name:- %s\n",root->d_name.name);
	if (!root) {
                //printk("<0>iput: Put an inode");
                iput(inode);
                return -ENOMEM;
        }
        sb->s_root = root;
        printk("<0>ramfs_fill_super: call path lookup, %s\n",(char * )data);
	
	err=path_lookup((char *)data,LOOKUP_FOLLOW, &nd);
        sb->s_root->d_fsdata=nd.dentry;
	printk("<0>raif_fill_super: Leave\n");	
	return 0;
	
}



static struct super_block * raif_get_sb(struct file_system_type *fs_type,
		int flags, const char *dev_name,void *data)
{
	struct super_block *sb=NULL,*temp_sb=NULL,*raif_sb=NULL;
	struct list_head *ptr=NULL;
/*
	spin_lock(&sb_lock);
	printk("<0>raif_get_sb: Get spin lock\n");
        list_for_each_entry(temp_sb,&super_blocks,s_list){
                spin_unlock(&sb_lock);
                printk("<0>raif_get_sb: list_for_each\n");
                //temp_sb=list_entry(ptr, struct super_block ,s_list);
                if(temp_sb)
                        if(!strcmp(temp_sb->s_type->name,"vfat")){
                                printk("<0>GOT IT !!\n");
                                break;
                }
                spin_lock(&sb_lock);
        }
        spin_unlock(&sb_lock);
*/
	raif_sb= get_sb_nodev(fs_type,flags,data,raif_fill_super);
	
	//code for getting vfat superblock//
	printk("<0>raif_get_sb: get lock\n");
	spin_lock(&sb_lock);
	
	list_for_each(ptr,&raif_sb->s_list){
		printk("<0>raif_get_sb: unlock\n");
		spin_unlock(&sb_lock);
		printk("<0>raif_get_sb: list_for_each\n");
		temp_sb=list_entry(ptr, struct super_block ,s_list);	
		if(sb)
			if(!strcmp(temp_sb->s_type->name,"vfat")){          //get vfat superblock
				printk("<0>GOT IT !!\n");
				break;
		}
		spin_lock(&sb_lock);
	}
	spin_unlock(&sb_lock);
	raif_sb->s_fs_info= temp_sb;               //store it
	return raif_sb;
}

static struct file_system_type raif_fs_type={
        .owner          = THIS_MODULE,
        .name           = "raif",
        .get_sb         = &raif_get_sb,
        .kill_sb        = &kill_litter_super,
};


static int __init init_raif(void){
	printk("<0>init_raif:- Enter \n");
	return register_filesystem(&raif_fs_type);
} 

void __exit exit_raif(void){
	printk("<0>exit_raif: Enter\n");
	unregister_filesystem(&raif_fs_type);
}

module_init(init_raif)
module_exit(exit_raif)

MODULE_LICENSE("GPL");




obj-m := main.o

default: 
	make -C /lib/modules/2.6.8-24-default/build SUBDIRS=$(PWD) modules

clean:
	rm *.o *.ko .* *.mod *.mod.*


Feb 22 12:37:32 linux kernel: init_raif:- Enter 
Feb 22 12:37:39 linux kernel: ramfs_fill_supe: Enterr
Feb 22 12:37:39 linux kernel: root->d_name.name:- /
Feb 22 12:37:39 linux kernel: ramfs_fill_super: call path lookup, /mnt/h
Feb 22 12:37:39 linux kernel: raif_fill_super: Leave
Feb 22 12:37:39 linux kernel: raif_get_sb: get lock
Feb 22 12:37:39 linux kernel: raif_get_sb: unlock
Feb 22 12:37:39 linux kernel: raif_get_sb: list_for_each
Feb 22 12:37:39 linux kernel: Unable to handle kernel NULL pointer dereference at virtual address 00000000
Feb 22 12:37:39 linux kernel:  printing eip:
Feb 22 12:37:39 linux kernel: d088f18a
Feb 22 12:37:39 linux kernel: *pde = 00000000
Feb 22 12:37:39 linux kernel: Oops: 0000 [#1]
Feb 22 12:37:39 linux kernel: Modules linked in: main thinkpad i915 usbserial parport_pc lp parport nvram ipt_TOS ip6t_LOG ip6t_limit ipt_LOG ipt_limit ipt_pkttype speedstep_lib freq_table thermal processor fan button battery ac snd_pcm_oss snd_mixer_oss snd_intel8x0 snd_ac97_codec snd_pcm snd_timer snd soundcore snd_page_alloc ip6t_state ip6_conntrack ipt_state ip6t_REJECT ipt_REJECT iptable_mangle iptable_filter ip6table_mangle ip_nat_ftp iptable_nat ip_conntrack_ftp ip_conntrack ip_tables ip6table_filter ip6_tables ipv6 edd ds yenta_socket pcmcia_core usbhid ehci_hcd evdev joydev sg st sd_mod sr_mod scsi_mod ide_cd cdrom intel_agp agpgart hw_random binfmt_misc uhci_hcd subfs nls_utf8 nls_cp437 vfat fat via_rhine mii dm_mod usbcore ext3 jbd
Feb 22 12:37:39 linux kernel: CPU:    0
Feb 22 12:37:39 linux kernel: EIP:    0060:[<d088f18a>]    Tainted:  G  U VLI
Feb 22 12:37:39 linux kernel: EFLAGS: 00210286   (2.6.8-24-default 20041006091623) 
Feb 22 12:37:39 linux kernel: EIP is at raif_get_sb+0x5a/0xd0 [main]
Feb 22 12:37:39 linux kernel: eax: 00000000   ebx: c036b774   ecx: c189ded8   edx: d088f324
Feb 22 12:37:39 linux kernel: esi: d088f324   edi: d088f299   ebp: c036b774   esp: c189ded8
Feb 22 12:37:39 linux kernel: ds: 007b   es: 007b   ss: 0068
Feb 22 12:37:39 linux kernel: Process mount (pid: 5960, threadinfo=c189c000 task=cd16a000)
Feb 22 12:37:39 linux kernel: Stack: c12ef800 00000000 cf264800 d088fac0 c18dc000 c0156f47 c18dc000 c1912000 
Feb 22 12:37:39 linux kernel:        c52fc000 00000000 c1535000 c18dc000 c1535004 c52fc000 c01698fa c18dc000 
Feb 22 12:37:39 linux kernel:        00000000 00000000 c189df50 c52fc000 c18dc000 c189df50 00000000 c0169ef2 
Feb 22 12:37:39 linux kernel: Call Trace:
Feb 22 12:37:39 linux kernel:  [<c0156f47>] do_kern_mount+0x87/0x180
Feb 22 12:37:39 linux kernel:  [<c01698fa>] do_new_mount+0x5a/0x90
Feb 22 12:37:39 linux kernel:  [<c0169ef2>] do_mount+0x172/0x1c0
Feb 22 12:37:39 linux kernel:  [<c013a3b4>] __alloc_pages+0x134/0x3b0
Feb 22 12:37:39 linux kernel:  [<c0169ca6>] exact_copy_from_user+0x26/0x60
Feb 22 12:37:39 linux kernel:  [<c016a26c>] sys_mount+0x6c/0xc0
Feb 22 12:37:39 linux kernel:  [<c0105c69>] sysenter_past_esp+0x52/0x79
Feb 22 12:37:39 linux kernel: Code: 90 3b 1c 24 74 77 68 81 f2 88 d0 89 dd e8 af d8 88 ef c7 04 24 24 f3 88 d0 e8 a3 d8 88 ef 5e 85 db 74 30 8b 43 20 bf 99 f2 88 d0 <8b> 08 51 68 9e f2 88 d0 e8 89 d8 88 ef 58 8b 43 20 5a 8b 30 ac 



[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