On Wed, May 18, 2022 at 01:23:16PM -0400, Gabriel Krisman Bertazi wrote: > Instead of reimplementing ext4_match_ci, use the new libfs helper. > > Signed-off-by: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxx> > --- [...] > int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, > struct ext4_filename *name) > { > @@ -1432,20 +1380,25 @@ static bool ext4_match(struct inode *parent, > #if IS_ENABLED(CONFIG_UNICODE) > if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) && > (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) { > - if (fname->cf_name.name) { > - if (IS_ENCRYPTED(parent)) { > - if (fname->hinfo.hash != EXT4_DIRENT_HASH(de) || > - fname->hinfo.minor_hash != > - EXT4_DIRENT_MINOR_HASH(de)) { > + int ret; > > - return false; > - } > - } > - return !ext4_ci_compare(parent, &fname->cf_name, > - de->name, de->name_len, true); > + if (IS_ENCRYPTED(parent) && > + (fname->hinfo.hash != EXT4_DIRENT_HASH(de) || > + fname->hinfo.minor_hash != EXT4_DIRENT_MINOR_HASH(de))) > + return false; > + > + ret = generic_ci_match(parent, fname->usr_fname, > + &fname->cf_name, de->name, > + de->name_len); > + if (ret < 0) { > + /* > + * Treat comparison errors as not a match. The > + * only case where it happens is on a disk > + * corruption or ENOMEM. > + */ > + return false; > } > - return !ext4_ci_compare(parent, fname->usr_fname, de->name, > - de->name_len, false); > + return ret; > } This needs an explanation for why it's okay to remove 'fname->cf_name.name != NULL' from the condition for doing the hash comparison for an encrypted+casefolded directory entry. - Eric