============高手快来,救小的一下下!!==============================
Aegis 2002-11-27 10:14:16 小的在写一个内核模块,其中因为有多进程,所以引入了信号量。程序在编译时没有任何问题,但在insmod时提示unresolved symbol sys_semctl。
下面是我测试时抠出来的一段代码(以便排除问题出在其他部分的可能性):
/* gcc -c -Wall test.c*/
#define __KERNEL__
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/ipc.h>
#include <linux/sem.h>
#include <linux/slab.h> /*kmalloc(), kfree()*/
#include <linux/stat.h>
#include <asm/types.h>
#include <asm/ipc.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
key_t ftok(path, id)
const char *path;
char id;
{
struct stat st;
/* if (stat(path, &st) < 0)
return (key_t)-1;*/
return (key_t) (id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xfff
));
}
init_module()
{
int i;
int AgentLock;
union semun options;
key_t MyKey = ftok( ".", "xyz" );
AgentLock = sys_semget( MyKey, 5, IPC_CREAT | IPC_EXCL );
options.val = 1;
for( i = 0; i < 5; i++ )
sys_semctl( AgentLock, i, SETVAL, options );
}
哪位高人帮我看看?小的实在不知道该咋办了!!