How to fix ext4magic compile error: error: ‘struct ext2_inode’ has no member named ‘i_dir_acl’?

Problem

When trying to compile ext4magic on modern Linux version, you’ll see an error like this:

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

Solution

Many people have encountered this problem, and on SourceForge, someone has posted this patch.

The gist is simple: Replace inode->i_dir_acl by inode->i_size_high and you’re done.

Luckily, this can easily be performed without transferring patch files, using sed:

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

After that, retry compiling using make and the error should be gone.