my bad. insmod works fine and i could see "fortune" proc entry in /proc/net directory.
system hangs when i do the command - cat fortune On Wed, Aug 17, 2011 at 10:50 PM, ratheesh kannoth <[email protected]> wrote: > I try to get register values of a NIC , using below module. But wen i > try to insmod the module, system hangs. I dont have any clue > what is happening, Could you please help me a little. > > > #include <linux/module.h> > #include <linux/kernel.h> > #include <linux/proc_fs.h> > #include <linux/string.h> > #include <linux/vmalloc.h> > #include <asm/uaccess.h> > #include <net/net_namespace.h> > #include <linux/if_ether.h> > #include <linux/netfilter/xt_time.h> > #include <linux/string.h> > > #include <linux/init.h> > #include <linux/netfilter.h> > #include <linux/netdevice.h> > #include <linux/etherdevice.h> > #include <linux/ethtool.h> > > > > MODULE_LICENSE("GPL"); > > MODULE_DESCRIPTION("Fortune Cookie Kernel Module"); > > MODULE_AUTHOR("M. Tim Jones"); > > > static struct proc_dir_entry *proc_entry; > static struct proc_dir_entry *proc_dir_entry; > > > > int fortune_read(char *buffer, char **start, off_t off, > int count, int *eof, void *data) > { > struct net_device *dev ; > struct ethtool_regs reg; > > if (off > 0) { > printk(KERN_INFO "we have finished to read "); > return 0; > } > > > dev=(struct net_device *)dev_get_by_name(&init_net, "eth0"); > > #if 1 > if(dev->ethtool_ops->get_regs) { > dev->ethtool_ops->get_regs(dev, ®, (void *)buffer); > } > #endif > > return count; > } > > > int fortune_write(struct file *file, const char __user *buffer, > unsigned long count, void *data) > { > return count; > } > > > > > int init_fortune_module( void ) > > { > > > struct file *filp = filp_open("/proc/net", O_RDONLY, 0); > > proc_dir_entry = PDE(filp->f_dentry->d_inode); > proc_entry = create_proc_entry( "fortune", 0644, proc_dir_entry ); > > if (proc_entry == NULL) { > printk(KERN_INFO "fortune: Couldn't create proc entry\n"); > > } else { > > proc_entry->read_proc = fortune_read; > > proc_entry->write_proc = fortune_write; > > printk(KERN_INFO "fortune: Module loaded.\n"); > > } > > > return 0; > > } > > void cleanup_fortune_module( void ) > { > > > remove_proc_entry("fortune", proc_dir_entry); > printk(KERN_INFO "fortune: Module unloaded.\n"); > > } > > > module_init( init_fortune_module ); > module_exit( cleanup_fortune_module ); > -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
