我有字符设备/dev/nvram,我想通过程序检查它。 一个人要求检查 struct stat 结构 aganist S_ISCHR 宏的 st_mode 字段。但我不明白这些信息。有人可以帮助一些示例程序吗?
最佳答案
这个怎么样:
#include <stdio.h>
#include <sys/stat.h>
int main()
{
struct stat st;
if (stat("/dev/nvram", &st) != -1)
{
if (S_ISCHR(st.st_mode))
{
printf("is char device\n");
}
}
return 0;
}
关于c++ - 检查字符设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9680837/