@@ -185,58 +185,6 @@ static struct f2fs_dir_entry *find_in_block(struct inode *dir,
185185 return f2fs_find_target_dentry (& d , fname , max_slots );
186186}
187187
188- #if IS_ENABLED (CONFIG_UNICODE )
189- /*
190- * Test whether a case-insensitive directory entry matches the filename
191- * being searched for.
192- *
193- * Returns 1 for a match, 0 for no match, and -errno on an error.
194- */
195- static int f2fs_match_ci_name (const struct inode * dir , const struct qstr * name ,
196- const u8 * de_name , u32 de_name_len )
197- {
198- const struct super_block * sb = dir -> i_sb ;
199- const struct unicode_map * um = sb -> s_encoding ;
200- struct fscrypt_str decrypted_name = FSTR_INIT (NULL , de_name_len );
201- struct qstr entry = QSTR_INIT (de_name , de_name_len );
202- int res ;
203-
204- if (IS_ENCRYPTED (dir )) {
205- const struct fscrypt_str encrypted_name =
206- FSTR_INIT ((u8 * )de_name , de_name_len );
207-
208- if (WARN_ON_ONCE (!fscrypt_has_encryption_key (dir )))
209- return - EINVAL ;
210-
211- decrypted_name .name = kmalloc (de_name_len , GFP_KERNEL );
212- if (!decrypted_name .name )
213- return - ENOMEM ;
214- res = fscrypt_fname_disk_to_usr (dir , 0 , 0 , & encrypted_name ,
215- & decrypted_name );
216- if (res < 0 )
217- goto out ;
218- entry .name = decrypted_name .name ;
219- entry .len = decrypted_name .len ;
220- }
221-
222- res = utf8_strncasecmp_folded (um , name , & entry );
223- /*
224- * In strict mode, ignore invalid names. In non-strict mode,
225- * fall back to treating them as opaque byte sequences.
226- */
227- if (res < 0 && !sb_has_strict_encoding (sb )) {
228- res = name -> len == entry .len &&
229- memcmp (name -> name , entry .name , name -> len ) == 0 ;
230- } else {
231- /* utf8_strncasecmp_folded returns 0 on match */
232- res = (res == 0 );
233- }
234- out :
235- kfree (decrypted_name .name );
236- return res ;
237- }
238- #endif /* CONFIG_UNICODE */
239-
240188static inline int f2fs_match_name (const struct inode * dir ,
241189 const struct f2fs_filename * fname ,
242190 const u8 * de_name , u32 de_name_len )
@@ -245,8 +193,10 @@ static inline int f2fs_match_name(const struct inode *dir,
245193
246194#if IS_ENABLED (CONFIG_UNICODE )
247195 if (fname -> cf_name .name )
248- return f2fs_match_ci_name (dir , & fname -> cf_name ,
249- de_name , de_name_len );
196+ return generic_ci_match (dir , fname -> usr_fname ,
197+ & fname -> cf_name ,
198+ de_name , de_name_len );
199+
250200#endif
251201 f .usr_fname = fname -> usr_fname ;
252202 f .disk_name = fname -> disk_name ;
0 commit comments