首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

初学者请问,应用程序怎么判断驱动程序已经挂载成功

2012-04-08 
菜鸟请教,应用程序如何判断驱动程序已经挂载成功已经写好驱动hello.ko, init, exit, open函数也已经写好如

菜鸟请教,应用程序如何判断驱动程序已经挂载成功
已经写好驱动hello.ko, init, exit, open函数也已经写好

如果先在控制台"insmod hello.ko"(驱动程序会输出提示信息"install hello.ko")
然后在应用程序里面,

static int fd;
fd = open("/dev/hello",0);(驱动程序提示信息"open hello")
if(fd<0)
{
  exit(1); 
}
是正常打开的


如果在程序里面使用system()函数挂载驱动,就出错了
system("insmod /lib/hello.ko");(驱动程序会输出提示信息"install hello.ko")
fd = open("/dev/hello",0);(这里就没有提示信息了)
if(fd<0)
{
  exit(1); (退出了)
}

应该是system函数还没有完成挂载驱动,open就不能成功

请教高手应该怎么处理呢?
谢谢啊

[解决办法]
fd = open("/dev/hello",0);(这里就没有提示信息了)
if(fd<0)
{
perror("open /dev/hello:");
exit(1); 
}


用perror打出错误原因

热点排行