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.
12 #include <linux/stat.h>
13 #include <linux/time.h>
14 #include <linux/ctype.h>
15 #include <asm/byteorder.h>
16 #include "zfs_common.h"
20 #include <zfs/dnode.h>
21 #include <zfs/uberblock_impl.h>
22 #include <zfs/vdev_impl.h>
23 #include <zfs/zio_checksum.h>
24 #include <zfs/zap_impl.h>
25 #include <zfs/zap_leaf.h>
26 #include <zfs/zfs_znode.h>
28 #include <zfs/dmu_objset.h>
29 #include <zfs/dsl_dir.h>
30 #include <zfs/dsl_dataset.h>
34 #define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1)
37 * Decompression Entry - lzjb
44 lzjb_decompress(void *s_start, void *d_start, uint32_t s_len,
47 uint8_t *src = s_start;
48 uint8_t *dst = d_start;
49 uint8_t *d_end = (uint8_t *) d_start + d_len;
50 uint8_t *s_end = (uint8_t *) s_start + s_len;
51 uint8_t *cpy, copymap = 0;
52 int copymask = 1 << (NBBY - 1);
54 while (dst < d_end && src < s_end) {
55 if ((copymask <<= 1) == (1 << NBBY)) {
60 printf("lzjb decompression failed\n");
61 return ZFS_ERR_BAD_FS;
63 if (copymap & copymask) {
64 int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN;
65 int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK;
68 if (src > s_end || cpy < (uint8_t *) d_start) {
69 printf("lzjb decompression failed\n");
70 return ZFS_ERR_BAD_FS;
72 while (--mlen >= 0 && dst < d_end)
79 printf("lzjb decompression failed\n");
80 return ZFS_ERR_BAD_FS;