【发布时间】:2012-03-13 08:52:57
【问题描述】:
我有字符设备 /dev/nvram,我想通过程序检查它。 一个人要求检查 struct stat 结构 aganist S_ISCHR 宏的 st_mode 字段。但我不明白这个信息。有人可以帮助一些示例程序。
【问题讨论】:
-
阅读
stat()或stat64()系统调用的手册页。
标签: c++ linux linux-kernel linux-device-driver
我有字符设备 /dev/nvram,我想通过程序检查它。 一个人要求检查 struct stat 结构 aganist S_ISCHR 宏的 st_mode 字段。但我不明白这个信息。有人可以帮助一些示例程序。
【问题讨论】:
stat() 或 stat64() 系统调用的手册页。
标签: c++ linux linux-kernel linux-device-driver
这个怎么样:
#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;
}
【讨论】: