~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to fs/squashfs/decompressor.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Squashfs - a compressed read only filesystem for Linux
3
3
 *
4
4
 * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
5
 
 * Phillip Lougher <phillip@lougher.demon.co.uk>
 
5
 * Phillip Lougher <phillip@squashfs.org.uk>
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or
8
8
 * modify it under the terms of the GNU General Public License
23
23
 
24
24
#include <linux/types.h>
25
25
#include <linux/mutex.h>
 
26
#include <linux/slab.h>
26
27
#include <linux/buffer_head.h>
27
28
 
28
29
#include "squashfs_fs.h"
74
75
 
75
76
        return decompressor[i];
76
77
}
 
78
 
 
79
 
 
80
void *squashfs_decompressor_init(struct super_block *sb, unsigned short flags)
 
81
{
 
82
        struct squashfs_sb_info *msblk = sb->s_fs_info;
 
83
        void *strm, *buffer = NULL;
 
84
        int length = 0;
 
85
 
 
86
        /*
 
87
         * Read decompressor specific options from file system if present
 
88
         */
 
89
        if (SQUASHFS_COMP_OPTS(flags)) {
 
90
                buffer = kmalloc(PAGE_CACHE_SIZE, GFP_KERNEL);
 
91
                if (buffer == NULL)
 
92
                        return ERR_PTR(-ENOMEM);
 
93
 
 
94
                length = squashfs_read_data(sb, &buffer,
 
95
                        sizeof(struct squashfs_super_block), 0, NULL,
 
96
                        PAGE_CACHE_SIZE, 1);
 
97
 
 
98
                if (length < 0) {
 
99
                        strm = ERR_PTR(length);
 
100
                        goto finished;
 
101
                }
 
102
        }
 
103
 
 
104
        strm = msblk->decompressor->init(msblk, buffer, length);
 
105
 
 
106
finished:
 
107
        kfree(buffer);
 
108
 
 
109
        return strm;
 
110
}