读取超级块的代码,编译错误,不知道为何?

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
momar
帖子: 24
注册时间: 2009-02-27 16:53

读取超级块的代码,编译错误,不知道为何?

#1

帖子 momar » 2011-02-28 12:59

各位高手再帮忙看下~~谢谢 :em01

错误提示:

代码: 全选

In file included from superb.c:1:
/usr/include/linux/ext2_fs.h: In function ‘ext2_mask_flags’:
/usr/include/linux/ext2_fs.h:182: error: ‘FS_DIRSYNC_FL’ undeclared (first use in this function)
/usr/include/linux/ext2_fs.h:182: error: (Each undeclared identifier is reported only once
/usr/include/linux/ext2_fs.h:182: error: for each function it appears in.)
/usr/include/linux/ext2_fs.h:182: error: ‘FS_TOPDIR_FL’ undeclared (first use in this function)
/usr/include/linux/ext2_fs.h:184: error: ‘FS_NODUMP_FL’ undeclared (first use in this function)
/usr/include/linux/ext2_fs.h:184: error: ‘FS_NOATIME_FL’ undeclared (first use in this function)
代码如下:
1 #include<linux/ext2_fs.h>
2 #include<linux/fs.h>
3 #include<sys/types.h>
4 #include<sys/stat.h>
5 #include<stdio.h>
6 #include<unistd.h>
7 #include<fcntl.h>
8 #include<stdlib.h>
9 #include<string.h>
10
11 #define boot_block_size 1024
12
13 int main()
14 {
15 char *buff = (char *)malloc(sizeof(struct ext2_super_block));
16
17 int fd = open("/mnt/tmp_mnt",O_RDONLY);
18
19 lseek(fd,boot_block_size,SEEK_CUR);
20
21 read(fd,buff,sizeof(struct ext2_super_block));
22
23 write(1,(void *)buff,sizeof(struct ext2_super_block));
24
25 close(fd);
26
27 return 0;
28
29 }
momar
帖子: 24
注册时间: 2009-02-27 16:53

Re: 读取超级块的代码,编译错误,不知道为何?

#2

帖子 momar » 2011-02-28 14:43

各位大侠帮忙解释下阿~~
momar
帖子: 24
注册时间: 2009-02-27 16:53

Re: 读取超级块的代码,编译错误,不知道为何?

#3

帖子 momar » 2011-02-28 21:29

1 #include<linux/ext2_fs.h>
2 #include<linux/fs.h>
两个头文件的包含顺序错了。。。。

问题已解决
头像
lotutu
帖子: 730
注册时间: 2010-12-23 16:29
来自: 北京

Re: 读取超级块的代码,编译错误,不知道为何?

#4

帖子 lotutu » 2011-03-01 12:43

原来还有顺序要求,学习了
回复