如何修复 ext4magic 编译错误:error: 'struct ext2_inode' has no member named 'i_dir_acl'?

问题

尝试在现代 Linux 版本上编译 ext4magic 时,你会看到如下错误:

ext4magic_error.txt
inode.c: In function 'dump_inode':
inode.c:407:82: error: 'struct ext2_inode' has no member named 'i_dir_acl'; did you mean 'i_file_acl'?
  407 |                  inode->i_file_acl, LINUX_S_ISDIR(inode->i_mode) ? inode->i_dir_acl : 0,
      |                                                                           ^~~~~~~~~
      |                                                                           i_file_acl
inode.c:414:63: error: 'struct ext2_inode' has no member named 'i_dir_acl'; did you mean 'i_file_acl'?
  414 |                         LINUX_S_ISDIR(inode->i_mode) ? inode->i_dir_acl : 0);
      |                                                               ^~~~~~~~~
      |                                                               i_file_acl
make[2]: *** [Makefile:491: ext4magic-inode.o] Error 1

解决方案

许多人遇到了此问题,在 SourceForge 上,有人发布了此补丁

要点很简单:将 inode->i_dir_acl 替换为 inode->i_size_high 就完成了。

幸运的是,这可以轻松地使用 sed 执行而无需传输补丁文件:

fix_ext4magic.sh
sed -i 's/inode->i_dir_acl/inode->i_size_high/g' src/*.c

之后,使用 make 重试编译,错误应该消失了。


Check out similar posts by category: Linux