sdcardfs: Check for other cases on path lookup
authorDaniel Rosenberg <drosen@google.com>
Wed, 27 Apr 2016 22:31:29 +0000 (15:31 -0700)
committerStricted <info@stricted.net>
Thu, 11 Oct 2018 16:03:16 +0000 (18:03 +0200)
This fixes a bug where the first lookup of a
file or folder created under a different view
would not be case insensitive. It will now
search through for a case insensitive match
if the initial lookup fails.

Bug:28024488
Change-Id: I4ff9ce297b9f2f9864b47540e740fd491c545229
Signed-off-by: Daniel Rosenberg <drosen@google.com>
fs/sdcardfs/lookup.c

index a01b06a514fd9b7ab032fbfebf846b659e1048fe..a8d6792b7656970aa6e6d3991061af15bb6f8478 100644 (file)
@@ -240,6 +240,28 @@ static struct dentry *__sdcardfs_lookup(struct dentry *dentry,
        /* Use vfs_path_lookup to check if the dentry exists or not */
        err = vfs_path_lookup(lower_dir_dentry, lower_dir_mnt, name, 0,
                                &lower_path);
+       /* check for other cases */
+       if (err == -ENOENT) {
+               struct dentry *child;
+               struct dentry *match = NULL;
+               spin_lock(&lower_dir_dentry->d_lock);
+               list_for_each_entry(child, &lower_dir_dentry->d_subdirs, d_u.d_child) {
+                       if (child && child->d_inode) {
+                               if (strcasecmp(child->d_name.name, name)==0) {
+                                       match = dget(child);
+                                       break;
+                               }
+                       }
+               }
+               spin_unlock(&lower_dir_dentry->d_lock);
+               if (match) {
+                       err = vfs_path_lookup(lower_dir_dentry,
+                                               lower_dir_mnt,
+                                               match->d_name.name, 0,
+                                               &lower_path);
+                       dput(match);
+               }
+       }
 
        /* no error: handle positive dentries */
        if (!err) {