the code is as follows:
-sharpinclude <linux/init.h>
-sharpinclude <linux/module.h>
-sharpinclude <asm/pgalloc.h>
-sharpinclude <asm/pgtable.h>
-sharpinclude <linux/thread_info.h>
-sharpinclude <linux/slab.h>
-sharpinclude <linux/sched.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Sun");
static int __init myModule_init(void)
{
struct pt_regs *regs;
long id=do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, NULL, NULL);
printk(KERN_ALERT"myModule init----fork_id:%d.\r\n",id);
return 0;
}
static void __exit myModule_exit(void)
{
printk(KERN_ALERT"myModule exit.\r\n");
}
module_init(myModule_init);
module_exit(myModule_exit);
then after compiling successfully, insmod page.ko, has the following error:
insmod: ERROR: could not insert module page.ko: Unknown symbol in module
View dmesg | tail:
[108843.437019] page: Unknown symbol do_fork (err 0)
View dependencies:
modinfo page.ko
filename: /home/sun/kernel_code/page.ko
author: colorfulshark@hotmail.com
license: GPL
rhelversion: 7.4
srcversion: 3913DBD14892947BDDCE568
depends:
vermagic: 3.10.0-693.el7.x86_64 SMP mod_unload modversions
after reading the relevant information, do you want to modify it in kernelfork.c? add:
EXPORT_SYMOBL(do_fork)
then recompile the linux kernel, but mine is an x86 platform, and the virtual machine recompiles slowly. I don"t know how the linux kernel code calls the do_fork function?
-sharpinclude < linux/sched.h > already contains the do_fork function, why can"t it be called?