1 // SPDX-License-Identifier: GPL-2.0+
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
7 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
8 * Use is subject to license terms.
13 #include <linux/stat.h>
14 #include <linux/time.h>
15 #include <linux/ctype.h>
16 #include <asm/byteorder.h>
17 #include "zfs_common.h"
21 #include <zfs/dnode.h>
22 #include <zfs/uberblock_impl.h>
23 #include <zfs/vdev_impl.h>
24 #include <zfs/zio_checksum.h>
25 #include <zfs/zap_impl.h>
26 #include <zfs/zap_leaf.h>
27 #include <zfs/zfs_znode.h>
29 #include <zfs/dmu_objset.h>
30 #include <zfs/dsl_dir.h>
31 #include <zfs/dsl_dataset.h>
35 #define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1)
38 * Decompression Entry - lzjb
45 lzjb_decompress(void *s_start, void *d_start, uint32_t s_len,
48 uint8_t *src = s_start;
49 uint8_t *dst = d_start;
50 uint8_t *d_end = (uint8_t *) d_start + d_len;
51 uint8_t *s_end = (uint8_t *) s_start + s_len;
52 uint8_t *cpy, copymap = 0;
53 int copymask = 1 << (NBBY - 1);
55 while (dst < d_end && src < s_end) {
56 if ((copymask <<= 1) == (1 << NBBY)) {
61 printf("lzjb decompression failed\n");
62 return ZFS_ERR_BAD_FS;
64 if (copymap & copymask) {
65 int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN;
66 int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK;
69 if (src > s_end || cpy < (uint8_t *) d_start) {
70 printf("lzjb decompression failed\n");
71 return ZFS_ERR_BAD_FS;
73 while (--mlen >= 0 && dst < d_end)
80 printf("lzjb decompression failed\n");
81 return ZFS_ERR_BAD_FS;