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