|

楼主 |
发表于 2004-4-6 21:49:51
|
显示全部楼层
还有个奇怪的现象,在系统引导时unload kernel, 加载上旧的内核,启动,到了界面,就不能听歌了,是/dev/sond/* 失败,原来一切正常的,两个声音模块是。
snd_ich.ko AND snd_pcm.ko
kldstat能知道一个模块的状态,#kldstat MODULE_NAME是知道该模块的状态
其实我这贴的目的是想知道一个模块名,然后在程序中使用用modstat,OR kldstat()。
找到了一个modfind()的使用的例子,modfind()的作用是返回一个模块的modid.
这程序来自:
/usr/share/examples/kld/syscall/test/call.c
- #include <stdio.h>
- #include <sys/syscall.h>
- #include <sys/types.h>
- #include <sys/module.h>
- static void usage (void);
- static void
- usage (void)
- {
- fprintf (stderr, "call syscall-number\n");
- exit (1);
- }
- int
- main(int argc, char **argv)
- {
- char *endptr;
- int syscall_num;
- struct module_stat stat;
- stat.version = sizeof(stat);
- modstat(modfind("syscall"), &stat);/*modfind()里的参数是一个模块的名字*/
- syscall_num = stat.data.intval;
- return syscall (syscall_num);
- }
复制代码
编译通过,但不知道怎么运行,还请指教。
自己写了个
- #include <sys/param.h>
- #include <sys/module.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- int
- main(void)
- {
- struct module_stat stat ;
- if(modstat(modfind("syscall"),&stat)<0) {
- printf("modstat error\n");
- return(1);
- }
- printf("version is %d,name is %s,refs is %d ,modspecific_t is %s \n",
- stat->version,stat->refs,stat->data);
- return(0);
- }
复制代码
根据最上面的程序,知道了modfind()里的参数可以是syscall,
但我设置为syscall,snd_ich.ko snd_pcm.ko kernel都输出:modstat error , why ?
如果不能在BSD版解决,请版主把整个主题复制到程序设计版,谢谢!! |
|