Dear All,
I have one simple problem in exporting the function. Everything is fine, but its not working as per the expectation. Actually I have to export some function from fs/dropcache.c, but it is not working as per the expectataion, [ I am able to export any function from other files like fs/buffer.c and block/genhd.c but dropcache.c creates a problem] .I am attaching the file. Just once check & please tell if something is missing, what I have done is as follows:
I have exported three functions from fs/dropcaches.c by making their function declaration in linux/mm.h, compiled the corresponding 2.6.26 kernel & got their entries in System.map file as follows:
c0174d98 T drop_slab
c0174db2 T drop_pagecache
c0174ea7 T drop_caches_sysctl_handler
These entries are quite different from the actual exported functions from other files, it has only T option. Can antbody elaborate what is the meaning of these options like T, t, r , u and so on?
I have booted with same 2.6.26 kernel. I included linux/mm.h and all the above three function in my module done make & found following warnings in compilation & following error message in insmod due to some linking error:
[root@CENTOS2 kernel]# make
make -C /lib/modules/2.6.26/build M=/root/kernel modules
make[1]: Entering directory `/root/Desktop/linux-2.6.26'
Building modules, stage 2.
MODPOST 2 modules
WARNING: "drop_slab" [/root/kernel/dropcache.ko] undefined!
WARNING: "drop_pagecache" [/root/kernel/dropcache.ko] undefined!
WARNING: "drop_caches_sysctl_handler" [/root/kernel/dropcache.ko] undefined!
make[1]: Leaving directory `/root/Desktop/linux-2.6.26'
[root@CENTOS2 kernel]#
[root@CENTOS2 kernel]#
[root@CENTOS2 kernel]# insmod dropcache.ko
insmod: error inserting 'dropcache.ko': -1 Unknown symbol in module
[root@CENTOS2 kernel]#
[root@CENTOS2 kernel]#
Any idea how to trace it & what is missing, as I got all the exported entries in System.map file & I have included the function declaration file linux/mm.h on the same compiled kernel, it should do the things in right manner.
Please suggest, If I am missing something or you want any more information. I am attaching my kernel module and these are some more snippet :
[root@CENTOS2 kernel]# uname -a
Linux CENTOS2 2.6.26 #1 SMP Sun Jul 19 10:54:05 IST 2009 i686 i686 i386 GNU/Linux
[root@CENTOS2 kernel]#
[root@CENTOS2 kernel]# tail -1 /root/Desktop/linux-2.6.26/fs/drop_caches.c
EXPORT_SYMBOL(drop_caches_sysctl_handler);
[root@CENTOS2 kernel]#
[root@CENTOS2 kernel]#
Thanks and Best Regards,
------------------------
Krishna Kumar
#include <linux/module.h> #include <linux/kernel.h> #include<linux/kmod.h> #include<linux/mm.h> #include<linux/fs.h> #include<linux/writeback.h> #include<linux/sysctl.h> #include<linux/gfp.h> int init_module(void) { printk(KERN_INFO " trying to check the exported function calling : drop_caches_sysctl_handler,drop_pagecache and drop_slab\n"); //drop_caches_sysctl_handler(ctl_table *table, int write, struct file *, v oid __user *buffer, size_t *length, loff_t *ppos); drop_caches_sysctl_handler(NULL, 0, NULL, NULL, NULL, NULL); drop_pagecache(); drop_slab(); return 0; } void cleanup_module(void) { printk(KERN_INFO "outside drop_cache_sysctl_handler"); }