PDA

View Full Version : What's wrong with my Kernel Mod!?!?!?!



workisnotfun
09-26-2013, 09:03 PM
Inserting it gives the correct output in /var/log/messages/ but when I try to remove it, it KILLS it and makes it unremovable!!! This screws up a whole lot of other things like my start up sometimes as well.


#include <linux/module.h> /* Needed by all modules */#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h>


static int hello2_data __initdata = 2;


static int __init hello_2_init(void)
{
printk("My Name: Loading Hello%d module - Hello World %d\n",hello2_data,hello2_data);
return 0;


}


static void __exit hello_2_exit(void)
{
printk("My Name: Exiting Hello%d module - Goodbye World %d\n",hello2_data,hello2_data);
}


module_init(hello_2_init);
module_exit(hello_2_exit);




I want it to print the exitting statement when I rmmod hello_2 but that command just KILLS it and I have to restart to remove it and the exitting message doesnt get put into the /var/log/message/

workisnotfun
09-26-2013, 09:34 PM
i get some weird output when I do cat /var/log/messages | grep hello


Sep 26 21:36:50 localhost kernel: [16462.322273] Modules linked in: hello_2(POF-) binfmt_misc fuse ebtable_nat bnep bluetooth nf_conntrack_netbios_ns nf_conntrack_broadcast ipt_MASQUERADE ip6table_nat nf_nat_ipv6 ip6table_mangle ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 iptable_nat nf_nat_ipv4 nf_nat iptable_mangle nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ebtable_filter ebtables ip6table_filter ip6_tables bbswitch(OF) arc4 nouveau snd_hda_codec_hdmi snd_hda_codec_realtek ttm snd_hda_intel snd_hda_codec ath9k ath9k_common ath9k_hw ath mac80211 snd_hwdep snd_seq snd_seq_device snd_pcm snd_page_alloc snd_timer snd mperf coretemp kvm_intel kvm cfg80211 soundcore acer_wmi sparse_keymap rfkill tg3 sdhci_pci sdhci mmc_core ptp pps_core shpchp crc32_pclmul crc32c_intel joydev ghash_clmulni_intel serio_raw uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_core videodev iTCO_wdt iTCO_vendor_support i2c_i801 mei_me mei lpc_ich media mfd_core microcode uinput i915 i2c_algo_bit drm_kms_helper drm i2c_core hid_logitech_dj mxm_wmi video wmi [last unloaded: hello_1]Sep 26 22:37:27 localhost kernel: [ 234.769461] hello_2: version magic '3.10.11-200.fc19.x86_64 SMP mod_unload ' should be '3.11.1-200.fc19.x86_64 SMP mod_unload '
Sep 26 22:37:34 localhost kernel: [ 241.864405] hello_2: module license 'unspecified' taints kernel.
Sep 26 22:37:51 localhost kernel: [ 259.118175] Modules linked in: hello_2(POF-) fuse ebtable_nat bnep bluetooth nf_conntrack_netbios_ns nf_conntrack_broadcast ipt_MASQUERADE ip6table_nat nf_nat_ipv6 ip6table_mangle ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 iptable_nat nf_nat_ipv4 nf_nat iptable_mangle nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ebtable_filter ebtables ip6table_filter ip6_tables bbswitch(OF) uvcvideo videobuf2_vmalloc videobuf2_memops arc4 videobuf2_core videodev media x86_pkg_temp_thermal coretemp kvm_intel kvm crc32_pclmul crc32c_intel ghash_clmulni_intel ttm iTCO_wdt acer_wmi iTCO_vendor_support sparse_keymap snd_hda_codec_hdmi snd_hda_codec_realtek ath9k ath9k_common ath9k_hw ath snd_hda_intel mac80211 snd_hda_codec joydev snd_hwdep microcode serio_raw snd_seq snd_seq_device i2c_i801 lpc_ich snd_pcm mfd_core cfg80211 snd_page_alloc tg3 sdhci_pci sdhci snd_timer mmc_core rfkill mei_me ptp snd pps_core mei soundcore shpchp mperf uinput i915 i2c_algo_bit drm_kms_helper drm i2c_core hid_logitech_dj mxm_wmi wmi video [last unloaded: nvidia]
Sep 26 22:55:22 localhost kernel: [ 288.268876] hello_2: module license 'unspecified' taints kernel.
Sep 26 23:20:11 localhost kernel: [ 1421.086943] hello_2: module license 'unspecified' taints kernel.
Sep 26 23:20:35 localhost kernel: [ 1445.384568] Modules linked in: hello_2(POF-) fuse ebtable_nat nf_conntrack_netbios_ns nf_conntrack_broadcast ipt_MASQUERADE ip6table_nat nf_nat_ipv6 ip6table_mangle ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 iptable_nat nf_nat_ipv4 nf_nat iptable_mangle nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack bnep bluetooth ebtable_filter ebtables ip6table_filter ip6_tables bbswitch(OF) arc4 x86_pkg_temp_thermal coretemp kvm_intel kvm crc32_pclmul ath9k ath9k_common ath9k_hw ath snd_hda_codec_hdmi mac80211 crc32c_intel ghash_clmulni_intel microcode snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_hwdep snd_seq uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_core videodev media cfg80211 acer_wmi sparse_keymap rfkill snd_seq_device iTCO_wdt snd_pcm nouveau ttm snd_page_alloc snd_timer snd soundcore iTCO_vendor_support sdhci_pci tg3 sdhci mmc_core ptp pps_core shpchp joydev serio_raw i2c_i801 lpc_ich mei_me mfd_core mei mperf uinput i915 hid_logitech_dj i2c_algo_bit drm_kms_helper drm i2c_core mxm_wmi video wmi


Any ideas?

nonpuz
09-26-2013, 10:35 PM
It's complaining that you haven't specified a license via the MODULE_LICENSE() macro. As far the message I believe you need to supply some sort of level, such as KERN_INFO which may be why it's not printing out (at least where you'd expect).

See this example:
Hello World Kernel Module | Kernel Module Hello World (http://learninglinuxkernel.in/linux-kernel-module-programming/hello-world-kernel-module)

Also, this is the wrong forum, there is a linux specific forum.