]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - fs/ubifs/ubifs.c
Merge branch 'master' of git://git.denx.de/u-boot-blackfin
[karo-tx-uboot.git] / fs / ubifs / ubifs.c
index d16d2b06a7e8b21060a6686d8d3469a5d0a88eed..273c0a96383538ccb35421a2694d3f0e272612df 100644 (file)
@@ -37,8 +37,8 @@ DECLARE_GLOBAL_DATA_PTR;
 static int gzip_decompress(const unsigned char *in, size_t in_len,
                           unsigned char *out, size_t *out_len)
 {
-       unsigned long len = in_len;
-       return zunzip(out, *out_len, (unsigned char *)in, &len, 0, 0);
+       return zunzip(out, *out_len, (unsigned char *)in,
+                     (unsigned long *)out_len, 0, 0);
 }
 
 /* Fake description object for the "none" compressor */
@@ -295,6 +295,7 @@ static int ubifs_finddir(struct super_block *sb, char *dirname,
        struct file *file;
        struct dentry *dentry;
        struct inode *dir;
+       int ret = 0;
 
        file = kzalloc(sizeof(struct file), 0);
        dentry = kzalloc(sizeof(struct dentry), 0);
@@ -336,7 +337,8 @@ static int ubifs_finddir(struct super_block *sb, char *dirname,
                if ((strncmp(dirname, (char *)dent->name, nm.len) == 0) &&
                    (strlen(dirname) == nm.len)) {
                        *inum = le64_to_cpu(dent->inum);
-                       return 1;
+                       ret = 1;
+                       goto out_free;
                }
 
                /* Switch to the next entry */
@@ -355,11 +357,12 @@ static int ubifs_finddir(struct super_block *sb, char *dirname,
        }
 
 out:
-       if (err != -ENOENT) {
+       if (err != -ENOENT)
                ubifs_err("cannot find next direntry, error %d", err);
-               return err;
-       }
 
+out_free:
+       if (file->private_data)
+               kfree(file->private_data);
        if (file)
                free(file);
        if (dentry)
@@ -367,11 +370,7 @@ out:
        if (dir)
                free(dir);
 
-       if (file->private_data)
-               kfree(file->private_data);
-       file->private_data = NULL;
-       file->f_pos = 2;
-       return 0;
+       return ret;
 }
 
 static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
@@ -384,6 +383,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
        unsigned long root_inum = 1;
        unsigned long inum;
        int symlink_count = 0; /* Don't allow symlink recursion */
+       char link_name[64];
 
        strcpy(fpath, filename);
 
@@ -420,7 +420,6 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
                ui = ubifs_inode(inode);
 
                if ((inode->i_mode & S_IFMT) == S_IFLNK) {
-                       char link_name[64];
                        char buf[128];
 
                        /* We have some sort of symlink recursion, bail out */
@@ -739,8 +738,10 @@ int ubifs_load(char *filename, u32 addr, u32 size)
 
        if (err)
                printf("Error reading file '%s'\n", filename);
-       else
+       else {
+               setenv_hex("filesize", size);
                printf("Done\n");
+       }
 
        ubifs_iput(inode);