]> www.infradead.org Git - mtd-utils.git/commitdiff
mkfs.jffs2: Remove Incorrect Find Optimization
authorGrant Erickson <gerickson@nuovations.com>
Fri, 13 Jun 2008 15:46:29 +0000 (01:46 +1000)
committerJosh Boyer <jwboyer@vader.jdub.homelinux.org>
Wed, 18 Jun 2008 13:07:20 +0000 (09:07 -0400)
Remove performance optimization in find_filesystem_entry that prevented
the successful simultaneous use of --root and --devtable where the
latter is only used to fix-up permissions and ownership and to create
device nodes.

As it stood, the performance optimization prevented a successful find
where directory recursion was required or where the file being searched
for had any mode permission bits set.

See http://lists.infradead.org/pipermail/linux-mtd/2008-June/021997.html
for additional information.

Signed-off-by: Grant Erickson <gerickson@nuovations.com>
Signed-off-by: Josh Boyer <jwboyer@vader.jdub.homelinux.org>
mkfs.jffs2.c

index cdf2a5a834f5523e3122b3c784fa7696cd92ae6c..f042ae7fc2e4f05d37ddd8faa6321e839b462302 100644 (file)
@@ -276,30 +276,27 @@ static struct filesystem_entry *find_filesystem_entry(
                e = dir->files;
        }
        while (e) {
-               /* Only bother to do the expensive strcmp on matching file types */
-               if (type == (e->sb.st_mode & S_IFMT)) {
-                       if (S_ISDIR(e->sb.st_mode)) {
-                               int len = strlen(e->fullname);
-
-                               /* Check if we are a parent of the correct path */
-                               if (strncmp(e->fullname, fullname, len) == 0) {
-                                       /* Is this an _exact_ match? */
-                                       if (strcmp(fullname, e->fullname) == 0) {
-                                               return (e);
-                                       }
-                                       /* Looks like we found a parent of the correct path */
-                                       if (fullname[len] == '/') {
-                                               if (e->files) {
-                                                       return (find_filesystem_entry (e, fullname, type));
-                                               } else {
-                                                       return NULL;
-                                               }
-                                       }
-                               }
-                       } else {
+               if (S_ISDIR(e->sb.st_mode)) {
+                       int len = strlen(e->fullname);
+
+                       /* Check if we are a parent of the correct path */
+                       if (strncmp(e->fullname, fullname, len) == 0) {
+                               /* Is this an _exact_ match? */
                                if (strcmp(fullname, e->fullname) == 0) {
                                        return (e);
                                }
+                               /* Looks like we found a parent of the correct path */
+                               if (fullname[len] == '/') {
+                                       if (e->files) {
+                                               return (find_filesystem_entry (e, fullname, type));
+                                       } else {
+                                               return NULL;
+                                       }
+                               }
+                       }
+               } else {
+                       if (strcmp(fullname, e->fullname) == 0) {
+                               return (e);
                        }
                }
                e = e->next;