【发布时间】:2014-06-01 11:54:03
【问题描述】:
我有一些问题。
我尝试读取一些 VFS 属性,例如 struct super_block 中的 s_magic 值。 但我看不懂 s_magic。
这是我的代码。
#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<linux/fs.h>
int main()
{
int fd;
char boot[1024];
struct super_block sb;
fd = open("/dev/fd", O_RDONLY);
read(fd, boot, 1024);
read(fd, &sb, sizeof(struct super_block);
printf("%x\n", sb.s_magic);
close(fd);
return 0;
}
所以,此代码因某些错误而无法工作。 在此错误中,“sb”的存储大小未知,并且“sizeof”对不完整类型“struct super_block”的应用无效
谢谢。
【问题讨论】:
标签: linux linux-kernel vfs