]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - fs/jffs2/jffs2_1pass.c
JFFS2: Return early when file read not necessary
[karo-tx-uboot.git] / fs / jffs2 / jffs2_1pass.c
index c856983ef444bfb3292a5aa2efafdd18b489e3e5..2e569ff59bb30a1d2b0594ba09a5e9d09c1979e4 100644 (file)
 #include <common.h>
 #include <config.h>
 #include <malloc.h>
+#include <div64.h>
 #include <linux/stat.h>
 #include <linux/time.h>
 #include <watchdog.h>
@@ -718,12 +719,18 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest)
                }
                put_fl_mem(jNode, pL->readbuf);
        }
+       /*
+        * If no destination is provided, we are done.
+        * Just return the total size.
+        */
+       if (!dest)
+               return totalSize;
 #endif
 
        for (b = pL->frag.listHead; b != NULL; b = b->next) {
                jNode = (struct jffs2_raw_inode *) get_node_mem(b->offset,
                                                                pL->readbuf);
-               if ((inode == jNode->ino)) {
+               if (inode == jNode->ino) {
 #if 0
                        putLabeledWord("\r\n\r\nread_inode: totlen = ", jNode->totlen);
                        putLabeledWord("read_inode: inode = ", jNode->ino);
@@ -1438,7 +1445,7 @@ jffs2_1pass_build_lists(struct part_info * part)
 {
        struct b_lists *pL;
        struct jffs2_unknown_node *node;
-       u32 nr_sectors = part->size/part->sector_size;
+       u32 nr_sectors;
        u32 i;
        u32 counter4 = 0;
        u32 counterF = 0;
@@ -1447,6 +1454,7 @@ jffs2_1pass_build_lists(struct part_info * part)
        u32 buf_size = DEFAULT_EMPTY_SCAN_SIZE;
        char *buf;
 
+       nr_sectors = lldiv(part->size, part->sector_size);
        /* turn off the lcd.  Refreshing the lcd adds 50% overhead to the */
        /* jffs2 list building enterprise nope.  in newer versions the overhead is */
        /* only about 5 %.  not enough to inconvenience people for. */