~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/squashfs/decompressor_single.c

Version: ~ [ linux-5.9 ] ~ [ linux-5.8.14 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.70 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.150 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.200 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.238 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.238 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (c) 2013
  3  * Phillip Lougher <phillip@squashfs.org.uk>
  4  *
  5  * This work is licensed under the terms of the GNU GPL, version 2. See
  6  * the COPYING file in the top-level directory.
  7  */
  8 
  9 #include <linux/types.h>
 10 #include <linux/mutex.h>
 11 #include <linux/slab.h>
 12 #include <linux/buffer_head.h>
 13 
 14 #include "squashfs_fs.h"
 15 #include "squashfs_fs_sb.h"
 16 #include "decompressor.h"
 17 #include "squashfs.h"
 18 
 19 /*
 20  * This file implements single-threaded decompression in the
 21  * decompressor framework
 22  */
 23 
 24 struct squashfs_stream {
 25         void            *stream;
 26         struct mutex    mutex;
 27 };
 28 
 29 void *squashfs_decompressor_create(struct squashfs_sb_info *msblk,
 30                                                 void *comp_opts)
 31 {
 32         struct squashfs_stream *stream;
 33         int err = -ENOMEM;
 34 
 35         stream = kmalloc(sizeof(*stream), GFP_KERNEL);
 36         if (stream == NULL)
 37                 goto out;
 38 
 39         stream->stream = msblk->decompressor->init(msblk, comp_opts);
 40         if (IS_ERR(stream->stream)) {
 41                 err = PTR_ERR(stream->stream);
 42                 goto out;
 43         }
 44 
 45         kfree(comp_opts);
 46         mutex_init(&stream->mutex);
 47         return stream;
 48 
 49 out:
 50         kfree(stream);
 51         return ERR_PTR(err);
 52 }
 53 
 54 void squashfs_decompressor_destroy(struct squashfs_sb_info *msblk)
 55 {
 56         struct squashfs_stream *stream = msblk->stream;
 57 
 58         if (stream) {
 59                 msblk->decompressor->free(stream->stream);
 60                 kfree(stream);
 61         }
 62 }
 63 
 64 int squashfs_decompress(struct squashfs_sb_info *msblk, struct buffer_head **bh,
 65         int b, int offset, int length, struct squashfs_page_actor *output)
 66 {
 67         int res;
 68         struct squashfs_stream *stream = msblk->stream;
 69 
 70         mutex_lock(&stream->mutex);
 71         res = msblk->decompressor->decompress(msblk, stream->stream, bh, b,
 72                 offset, length, output);
 73         mutex_unlock(&stream->mutex);
 74 
 75         if (res < 0)
 76                 ERROR("%s decompression failed, data probably corrupt\n",
 77                         msblk->decompressor->name);
 78 
 79         return res;
 80 }
 81 
 82 int squashfs_max_decompressors(void)
 83 {
 84         return 1;
 85 }
 86 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp