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

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

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/squashfs/lzo_wrapper.c (Version linux-6.12-rc7) and /fs/squashfs/lzo_wrapper.c (Version linux-5.4.285)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*                                                  2 /*
  3  * Squashfs - a compressed read only filesyste      3  * Squashfs - a compressed read only filesystem for Linux
  4  *                                                  4  *
  5  * Copyright (c) 2010 LG Electronics                5  * Copyright (c) 2010 LG Electronics
  6  * Chan Jeong <chan.jeong@lge.com>                  6  * Chan Jeong <chan.jeong@lge.com>
  7  *                                                  7  *
  8  * lzo_wrapper.c                                    8  * lzo_wrapper.c
  9  */                                                 9  */
 10                                                    10 
 11 #include <linux/mutex.h>                           11 #include <linux/mutex.h>
 12 #include <linux/bio.h>                         !!  12 #include <linux/buffer_head.h>
 13 #include <linux/slab.h>                            13 #include <linux/slab.h>
 14 #include <linux/vmalloc.h>                         14 #include <linux/vmalloc.h>
 15 #include <linux/lzo.h>                             15 #include <linux/lzo.h>
 16                                                    16 
 17 #include "squashfs_fs.h"                           17 #include "squashfs_fs.h"
 18 #include "squashfs_fs_sb.h"                        18 #include "squashfs_fs_sb.h"
 19 #include "squashfs.h"                              19 #include "squashfs.h"
 20 #include "decompressor.h"                          20 #include "decompressor.h"
 21 #include "page_actor.h"                            21 #include "page_actor.h"
 22                                                    22 
 23 struct squashfs_lzo {                              23 struct squashfs_lzo {
 24         void    *input;                            24         void    *input;
 25         void    *output;                           25         void    *output;
 26 };                                                 26 };
 27                                                    27 
 28 static void *lzo_init(struct squashfs_sb_info      28 static void *lzo_init(struct squashfs_sb_info *msblk, void *buff)
 29 {                                                  29 {
 30         int block_size = max_t(int, msblk->blo     30         int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
 31                                                    31 
 32         struct squashfs_lzo *stream = kzalloc(     32         struct squashfs_lzo *stream = kzalloc(sizeof(*stream), GFP_KERNEL);
 33         if (stream == NULL)                        33         if (stream == NULL)
 34                 goto failed;                       34                 goto failed;
 35         stream->input = vmalloc(block_size);       35         stream->input = vmalloc(block_size);
 36         if (stream->input == NULL)                 36         if (stream->input == NULL)
 37                 goto failed;                       37                 goto failed;
 38         stream->output = vmalloc(block_size);      38         stream->output = vmalloc(block_size);
 39         if (stream->output == NULL)                39         if (stream->output == NULL)
 40                 goto failed2;                      40                 goto failed2;
 41                                                    41 
 42         return stream;                             42         return stream;
 43                                                    43 
 44 failed2:                                           44 failed2:
 45         vfree(stream->input);                      45         vfree(stream->input);
 46 failed:                                            46 failed:
 47         ERROR("Failed to allocate lzo workspac     47         ERROR("Failed to allocate lzo workspace\n");
 48         kfree(stream);                             48         kfree(stream);
 49         return ERR_PTR(-ENOMEM);                   49         return ERR_PTR(-ENOMEM);
 50 }                                                  50 }
 51                                                    51 
 52                                                    52 
 53 static void lzo_free(void *strm)                   53 static void lzo_free(void *strm)
 54 {                                                  54 {
 55         struct squashfs_lzo *stream = strm;        55         struct squashfs_lzo *stream = strm;
 56                                                    56 
 57         if (stream) {                              57         if (stream) {
 58                 vfree(stream->input);              58                 vfree(stream->input);
 59                 vfree(stream->output);             59                 vfree(stream->output);
 60         }                                          60         }
 61         kfree(stream);                             61         kfree(stream);
 62 }                                                  62 }
 63                                                    63 
 64                                                    64 
 65 static int lzo_uncompress(struct squashfs_sb_i     65 static int lzo_uncompress(struct squashfs_sb_info *msblk, void *strm,
 66         struct bio *bio, int offset, int lengt !!  66         struct buffer_head **bh, int b, int offset, int length,
 67         struct squashfs_page_actor *output)        67         struct squashfs_page_actor *output)
 68 {                                                  68 {
 69         struct bvec_iter_all iter_all = {};    << 
 70         struct bio_vec *bvec = bvec_init_iter_ << 
 71         struct squashfs_lzo *stream = strm;        69         struct squashfs_lzo *stream = strm;
 72         void *buff = stream->input, *data;         70         void *buff = stream->input, *data;
 73         int bytes = length, res;               !!  71         int avail, i, bytes = length, res;
 74         size_t out_len = output->length;           72         size_t out_len = output->length;
 75                                                    73 
 76         while (bio_next_segment(bio, &iter_all !!  74         for (i = 0; i < b; i++) {
 77                 int avail = min(bytes, ((int)b !!  75                 avail = min(bytes, msblk->devblksize - offset);
 78                                                !!  76                 memcpy(buff, bh[i]->b_data + offset, avail);
 79                 data = bvec_virt(bvec);        << 
 80                 memcpy(buff, data + offset, av << 
 81                 buff += avail;                     77                 buff += avail;
 82                 bytes -= avail;                    78                 bytes -= avail;
 83                 offset = 0;                        79                 offset = 0;
                                                   >>  80                 put_bh(bh[i]);
 84         }                                          81         }
 85                                                    82 
 86         res = lzo1x_decompress_safe(stream->in     83         res = lzo1x_decompress_safe(stream->input, (size_t)length,
 87                                         stream     84                                         stream->output, &out_len);
 88         if (res != LZO_E_OK)                       85         if (res != LZO_E_OK)
 89                 goto failed;                       86                 goto failed;
 90                                                    87 
 91         res = bytes = (int)out_len;                88         res = bytes = (int)out_len;
 92         data = squashfs_first_page(output);        89         data = squashfs_first_page(output);
 93         buff = stream->output;                     90         buff = stream->output;
 94         while (data) {                             91         while (data) {
 95                 if (bytes <= PAGE_SIZE) {          92                 if (bytes <= PAGE_SIZE) {
 96                         if (!IS_ERR(data))     !!  93                         memcpy(data, buff, bytes);
 97                                 memcpy(data, b << 
 98                         break;                     94                         break;
 99                 } else {                           95                 } else {
100                         if (!IS_ERR(data))     !!  96                         memcpy(data, buff, PAGE_SIZE);
101                                 memcpy(data, b << 
102                         buff += PAGE_SIZE;         97                         buff += PAGE_SIZE;
103                         bytes -= PAGE_SIZE;        98                         bytes -= PAGE_SIZE;
104                         data = squashfs_next_p     99                         data = squashfs_next_page(output);
105                 }                                 100                 }
106         }                                         101         }
107         squashfs_finish_page(output);             102         squashfs_finish_page(output);
108                                                   103 
109         return res;                               104         return res;
110                                                   105 
111 failed:                                           106 failed:
112         return -EIO;                              107         return -EIO;
113 }                                                 108 }
114                                                   109 
115 const struct squashfs_decompressor squashfs_lz    110 const struct squashfs_decompressor squashfs_lzo_comp_ops = {
116         .init = lzo_init,                         111         .init = lzo_init,
117         .free = lzo_free,                         112         .free = lzo_free,
118         .decompress = lzo_uncompress,             113         .decompress = lzo_uncompress,
119         .id = LZO_COMPRESSION,                    114         .id = LZO_COMPRESSION,
120         .name = "lzo",                            115         .name = "lzo",
121         .alloc_buffer = 0,                     << 
122         .supported = 1                            116         .supported = 1
123 };                                                117 };
124                                                   118 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php