如何判断在/dev目录下指定的某个设备是否存在呢?比如判断/dev/ttyS0是否存在可用如下代码:
access(dev_fn,O_RDWR);
if (errno == ENOENT)
{ /* judge file exist or not */
system("mknod /dev/audio_alg c 240 0");
}
if ((dev_fd = open(dev_fn,O_RDWR)) <= 0)
{
perror("/dev/audio_alg");
return -1;
}
No comments:
Post a Comment