It should be related with bytes order in the structure of "ext2_dirent_entry" and "ext2_dirent_entry_2" on the PPC64 machine.
struct ext4_dir_entry {
__le32 inode;
__le16 rec_len;
__le16 name_len;
char name[EXT4_NAME_LEN];
};
/*
* The new version of the directory entry. Since EXT4 structures are
* stored in intel byte order, and the name_len field could never be
* bigger than 255 chars, it's safe to reclaim the extra byte for the
* file_type field.
*/
struct ext4_dir_entry_2 {
__le32 inode;
__le16 rec_len;
__u8 name_len;
__u8 file_type;
char name[EXT4_NAME_LEN];
};
In fact, the ext4_dir_entry_2::name_len and ext4_dir_entry_2::file_type should be exchanged on PPC64 as following:
struct ext2_dir_entry_2 {
__le32 inode;
__le16 rec_len;
#ifndef WORDS_BIGENDIAN
__u8 name_len;
__u8 file_type;
#else
__u8 file_type;
__u8 name_len;
#endif
char name[EXT2_NAME_LEN];
};
Then we can access the ext2_dir_entry::name_len via ext2_dir_entry_2::name_len.
In fact, because the CPU bytes-order for PPC64 and the on-disk bytes-order are different, any value (not only ext2_dir_dirent, but also others, such as inode, super_block, and so on) which is larger than 1-byte and loaded from disk (write or disk) should be converted via lexx_to_cpu (or cpu_to_lexx). Unfortunately, we missed to do that at a lot of points in current implantation.
On the other hand, in current implementation, we assume the ext2_dir_entry_2::name_len is lower than ext2_dir_entry_2::file_type, so there are some logic like the following:
int filetype = dirent->name_len >> 8;
...
dirent->name_len = ((dirent->name_len & 0xFF) | (dirdata | should_be) << 8);
...
To make the e2fsck workable on PPC64 correctly, all related codes should be well checked and re-considere. In theory, it is not complex, but it involves a lot of trivial things and I am not sure whether there will be other data structures to be handled. We must check carefully one by one. So it is not a simple work.
This is fixed in the latest e2fsprogs release.