]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Add support for EasyOS 4.0
authorlongpanda <admin@ventoy.net>
Sat, 11 Jun 2022 14:47:38 +0000 (22:47 +0800)
committerlongpanda <admin@ventoy.net>
Sat, 11 Jun 2022 14:47:38 +0000 (22:47 +0800)
17 files changed:
GRUB2/MOD_SRC/grub-2.04/grub-core/fs/squash4.c [new file with mode: 0644]
GRUB2/MOD_SRC/grub-2.04/grub-core/fs/zfs/zfs_lz4.c [new file with mode: 0644]
GRUB2/MOD_SRC/grub-2.04/install.sh
INSTALL/grub/arm64-efi/gfxterm_menu.mod [deleted file]
INSTALL/grub/arm64-efi/moddep.lst
INSTALL/grub/arm64-efi/zfs.mod
INSTALL/grub/i386-efi/moddep.lst
INSTALL/grub/i386-efi/smbios.mod [deleted file]
INSTALL/grub/i386-efi/zfs.mod
INSTALL/grub/i386-pc/moddep.lst
INSTALL/grub/i386-pc/zfs.mod
INSTALL/grub/mips64el-efi/gfxterm_menu.mod [deleted file]
INSTALL/grub/mips64el-efi/moddep.lst
INSTALL/grub/mips64el-efi/zfs.mod
INSTALL/grub/x86_64-efi/moddep.lst
INSTALL/grub/x86_64-efi/smbios.mod [deleted file]
INSTALL/grub/x86_64-efi/zfs.mod

diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/fs/squash4.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/fs/squash4.c
new file mode 100644 (file)
index 0000000..afeea66
--- /dev/null
@@ -0,0 +1,1043 @@
+/* squash4.c - SquashFS */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2010  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/deflate.h>
+#include <minilzo.h>
+
+#include "xz.h"
+#include "xz_stream.h"
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/*
+  object         format      Pointed by
+  superblock     RAW         Fixed offset (0)
+  data           RAW ?       Fixed offset (60)
+  inode table    Chunk       superblock
+  dir table      Chunk       superblock
+  fragment table Chunk       unk1
+  unk1           RAW, Chunk  superblock
+  unk2           RAW         superblock
+  UID/GID        Chunk       exttblptr
+  exttblptr      RAW         superblock
+
+  UID/GID table is the array ot uint32_t
+  unk1 contains pointer to fragment table followed by some chunk.
+  unk2 containts one uint64_t
+*/
+
+struct grub_squash_super
+{
+  grub_uint32_t magic;
+#define SQUASH_MAGIC 0x73717368
+  grub_uint32_t dummy1;
+  grub_uint32_t creation_time;
+  grub_uint32_t block_size;
+  grub_uint32_t dummy2;
+  grub_uint16_t compression;
+  grub_uint16_t dummy3;
+  grub_uint64_t dummy4;
+  grub_uint16_t root_ino_offset;
+  grub_uint32_t root_ino_chunk;
+  grub_uint16_t dummy5;
+  grub_uint64_t total_size;
+  grub_uint64_t exttbloffset;
+  grub_uint64_t dummy6;
+  grub_uint64_t inodeoffset;
+  grub_uint64_t diroffset;
+  grub_uint64_t unk1offset;
+  grub_uint64_t unk2offset;
+} GRUB_PACKED;
+
+/* Chunk-based */
+struct grub_squash_inode
+{
+  /* Same values as direlem types. */
+  grub_uint16_t type;
+  grub_uint16_t dummy[3];
+  grub_uint32_t mtime;
+  grub_uint32_t dummy2;
+  union
+  {
+    struct {
+      grub_uint32_t chunk;
+      grub_uint32_t fragment;
+      grub_uint32_t offset;
+      grub_uint32_t size;
+      grub_uint32_t block_size[0];
+    }  GRUB_PACKED file;
+    struct {
+      grub_uint64_t chunk;
+      grub_uint64_t size;
+      grub_uint32_t dummy1[3];
+      grub_uint32_t fragment;
+      grub_uint32_t offset;
+      grub_uint32_t dummy3;
+      grub_uint32_t block_size[0];
+    }  GRUB_PACKED long_file;
+    struct {
+      grub_uint32_t chunk;
+      grub_uint32_t dummy;
+      grub_uint16_t size;
+      grub_uint16_t offset;
+    } GRUB_PACKED dir;
+    struct {
+      grub_uint32_t dummy1;
+      grub_uint32_t size;
+      grub_uint32_t chunk;
+      grub_uint32_t dummy2;
+      grub_uint16_t dummy3;
+      grub_uint16_t offset;
+    } GRUB_PACKED long_dir;
+    struct {
+      grub_uint32_t dummy;
+      grub_uint32_t namelen;
+      char name[0];
+    } GRUB_PACKED symlink;
+  }  GRUB_PACKED;
+} GRUB_PACKED;
+
+struct grub_squash_cache_inode
+{
+  struct grub_squash_inode ino;
+  grub_disk_addr_t ino_chunk;
+  grub_uint16_t        ino_offset;
+  grub_uint32_t *block_sizes;
+  grub_disk_addr_t *cumulated_block_sizes;
+};
+
+/* Chunk-based.  */
+struct grub_squash_dirent_header
+{
+  /* Actually the value is the number of elements - 1.  */
+  grub_uint32_t nelems;
+  grub_uint32_t ino_chunk;
+  grub_uint32_t dummy;
+} GRUB_PACKED;
+
+struct grub_squash_dirent
+{
+  grub_uint16_t ino_offset;
+  grub_uint16_t dummy;
+  grub_uint16_t type;
+  /* Actually the value is the length of name - 1.  */
+  grub_uint16_t namelen;
+  char name[0];
+} GRUB_PACKED;
+
+enum
+  {
+    SQUASH_TYPE_DIR = 1,
+    SQUASH_TYPE_REGULAR = 2,
+    SQUASH_TYPE_SYMLINK = 3,
+    SQUASH_TYPE_LONG_DIR = 8,
+    SQUASH_TYPE_LONG_REGULAR = 9,
+  };
+
+
+struct grub_squash_frag_desc
+{
+  grub_uint64_t offset;
+  grub_uint32_t size;
+  grub_uint32_t dummy;
+} GRUB_PACKED;
+
+enum
+  {
+    SQUASH_CHUNK_FLAGS = 0x8000,
+    SQUASH_CHUNK_UNCOMPRESSED = 0x8000
+  };
+
+enum
+  {
+    SQUASH_BLOCK_FLAGS = 0x1000000,
+    SQUASH_BLOCK_UNCOMPRESSED = 0x1000000
+  };
+
+enum
+  {
+    COMPRESSION_ZLIB = 1,
+    COMPRESSION_LZO = 3,
+    COMPRESSION_XZ = 4,
+    COMPRESSION_LZ4 = 5,
+  };
+
+
+#define SQUASH_CHUNK_SIZE 0x2000
+#define XZBUFSIZ 0x2000
+
+struct grub_squash_data
+{
+  grub_disk_t disk;
+  struct grub_squash_super sb;
+  struct grub_squash_cache_inode ino;
+  grub_uint64_t fragments;
+  int log2_blksz;
+  grub_size_t blksz;
+  grub_ssize_t (*decompress) (char *inbuf, grub_size_t insize, grub_off_t off,
+                             char *outbuf, grub_size_t outsize,
+                             struct grub_squash_data *data);
+  struct xz_dec *xzdec;
+  char *xzbuf;
+};
+
+struct grub_fshelp_node
+{
+  struct grub_squash_data *data;
+  struct grub_squash_inode ino;
+  grub_size_t stsize;
+  struct 
+  {
+    grub_disk_addr_t ino_chunk;
+    grub_uint16_t ino_offset;
+  } stack[1];
+};
+
+static grub_err_t
+read_chunk (struct grub_squash_data *data, void *buf, grub_size_t len,
+           grub_uint64_t chunk_start, grub_off_t offset)
+{
+  while (len > 0)
+    {
+      grub_uint64_t csize;
+      grub_uint16_t d;
+      grub_err_t err;
+      while (1)
+       {
+         err = grub_disk_read (data->disk,
+                               chunk_start >> GRUB_DISK_SECTOR_BITS,
+                               chunk_start & (GRUB_DISK_SECTOR_SIZE - 1),
+                               sizeof (d), &d);
+         if (err)
+           return err;
+         if (offset < SQUASH_CHUNK_SIZE)
+           break;
+         offset -= SQUASH_CHUNK_SIZE;
+         chunk_start += 2 + (grub_le_to_cpu16 (d) & ~SQUASH_CHUNK_FLAGS);
+       }
+
+      csize = SQUASH_CHUNK_SIZE - offset;
+      if (csize > len)
+       csize = len;
+  
+      if (grub_le_to_cpu16 (d) & SQUASH_CHUNK_UNCOMPRESSED)
+       {
+         grub_disk_addr_t a = chunk_start + 2 + offset;
+         err = grub_disk_read (data->disk, (a >> GRUB_DISK_SECTOR_BITS),
+                               a & (GRUB_DISK_SECTOR_SIZE - 1),
+                               csize, buf);
+         if (err)
+           return err;
+       }
+      else
+       {
+         char *tmp;
+         grub_size_t bsize = grub_le_to_cpu16 (d) & ~SQUASH_CHUNK_FLAGS; 
+         grub_disk_addr_t a = chunk_start + 2;
+         tmp = grub_malloc (bsize);
+         if (!tmp)
+           return grub_errno;
+         /* FIXME: buffer uncompressed data.  */
+         err = grub_disk_read (data->disk, (a >> GRUB_DISK_SECTOR_BITS),
+                               a & (GRUB_DISK_SECTOR_SIZE - 1),
+                               bsize, tmp);
+         if (err)
+           {
+             grub_free (tmp);
+             return err;
+           }
+
+         if (data->decompress (tmp, bsize, offset,
+                               buf, csize, data) < 0)
+           {
+             grub_free (tmp);
+             return grub_errno;
+           }
+         grub_free (tmp);
+       }
+      len -= csize;
+      offset += csize;
+      buf = (char *) buf + csize;
+    }
+  return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+zlib_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
+                char *outbuf, grub_size_t outsize,
+                struct grub_squash_data *data __attribute__ ((unused)))
+{
+  return grub_zlib_decompress (inbuf, insize, off, outbuf, outsize);
+}
+
+static grub_ssize_t
+lzo_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
+               char *outbuf, grub_size_t len, struct grub_squash_data *data)
+{
+  lzo_uint usize = data->blksz;
+  grub_uint8_t *udata;
+
+  if (usize < 8192)
+    usize = 8192;
+
+  udata = grub_malloc (usize);
+  if (!udata)
+    return -1;
+
+  if (lzo1x_decompress_safe ((grub_uint8_t *) inbuf,
+                            insize, udata, &usize, NULL) != LZO_E_OK)
+    {
+      grub_error (GRUB_ERR_BAD_FS, "incorrect compressed chunk");
+      grub_free (udata);
+      return -1;
+    }
+  grub_memcpy (outbuf, udata + off, len);
+  grub_free (udata);
+  return len;
+}
+
+static grub_ssize_t
+xz_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
+              char *outbuf, grub_size_t len, struct grub_squash_data *data)
+{
+  grub_size_t ret = 0;
+  grub_off_t pos = 0;
+  struct xz_buf buf;
+
+  xz_dec_reset (data->xzdec);
+  buf.in = (grub_uint8_t *) inbuf;
+  buf.in_pos = 0;
+  buf.in_size = insize;
+  buf.out = (grub_uint8_t *) data->xzbuf;
+  buf.out_pos = 0;
+  buf.out_size = XZBUFSIZ;
+
+  while (len)
+    {
+      enum xz_ret xzret;
+      
+      buf.out_pos = 0;
+
+      xzret = xz_dec_run (data->xzdec, &buf);
+
+      if (xzret != XZ_OK && xzret != XZ_STREAM_END)
+       {
+         grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "invalid xz chunk");
+         return -1;
+       }
+      if (pos + buf.out_pos >= off)
+       {
+         grub_ssize_t outoff = pos - off;
+         grub_size_t l;
+         if (outoff >= 0)
+           {
+             l = buf.out_pos;
+             if (l > len)
+               l = len;
+             grub_memcpy (outbuf + outoff, buf.out, l);
+           }
+         else
+           {
+             outoff = -outoff;
+             l = buf.out_pos - outoff;
+             if (l > len)
+               l = len;
+             grub_memcpy (outbuf, buf.out + outoff, l);
+           }
+         ret += l;
+         len -= l;
+       }
+      pos += buf.out_pos;
+      if (xzret == XZ_STREAM_END)
+       break;
+    }
+  return ret;
+}
+
+int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, int maxOutputSize);
+static grub_ssize_t lz4_decompress_wrap(char *inbuf, grub_size_t insize, grub_off_t off, 
+    char *outbuf, grub_size_t len, struct grub_squash_data *data)
+{
+  char *udata = NULL;
+  int usize = data->blksz;
+
+  if (usize < 8192)
+    usize = 8192;
+
+  udata = grub_malloc (usize);
+  if (!udata)
+    return -1;
+
+  LZ4_uncompress_unknownOutputSize(inbuf, udata, insize, usize);
+  grub_memcpy (outbuf, udata + off, len);
+  grub_free (udata);
+  return len;
+}
+
+static struct grub_squash_data *
+squash_mount (grub_disk_t disk)
+{
+  struct grub_squash_super sb;
+  grub_err_t err;
+  struct grub_squash_data *data;
+  grub_uint64_t frag;
+
+  err = grub_disk_read (disk, 0, 0, sizeof (sb), &sb);
+  if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+    grub_error (GRUB_ERR_BAD_FS, "not a squash4");
+  if (err)
+    return NULL;
+  if (sb.magic != grub_cpu_to_le32_compile_time (SQUASH_MAGIC)
+      || sb.block_size == 0
+      || ((sb.block_size - 1) & sb.block_size))
+    {
+      grub_error (GRUB_ERR_BAD_FS, "not squash4");
+      return NULL;
+    }
+
+  err = grub_disk_read (disk, 
+                       grub_le_to_cpu64 (sb.unk1offset)
+                       >> GRUB_DISK_SECTOR_BITS, 
+                       grub_le_to_cpu64 (sb.unk1offset)
+                       & (GRUB_DISK_SECTOR_SIZE - 1), sizeof (frag), &frag);
+  if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+    grub_error (GRUB_ERR_BAD_FS, "not a squash4");
+  if (err)
+    return NULL;
+
+  data = grub_zalloc (sizeof (*data));
+  if (!data)
+    return NULL;
+  data->sb = sb;
+  data->disk = disk;
+  data->fragments = grub_le_to_cpu64 (frag);
+
+  switch (sb.compression)
+    {
+    case grub_cpu_to_le16_compile_time (COMPRESSION_ZLIB):
+      data->decompress = zlib_decompress;
+      break;
+    case grub_cpu_to_le16_compile_time (COMPRESSION_LZO):
+      data->decompress = lzo_decompress;
+      break;
+    case grub_cpu_to_le16_compile_time (COMPRESSION_LZ4):
+      data->decompress = lz4_decompress_wrap;
+      break;
+    case grub_cpu_to_le16_compile_time (COMPRESSION_XZ):
+      data->decompress = xz_decompress;
+      data->xzbuf = grub_malloc (XZBUFSIZ);
+      if (!data->xzbuf)
+       {
+         grub_free (data);
+         return NULL;
+       }
+      data->xzdec = xz_dec_init (1 << 16);
+      if (!data->xzdec)
+       {
+         grub_free (data->xzbuf);
+         grub_free (data);
+         return NULL;
+       }
+      break;
+    default:
+      grub_free (data);
+      grub_error (GRUB_ERR_BAD_FS, "unsupported compression %d",
+                 grub_le_to_cpu16 (sb.compression));
+      return NULL;
+    }
+
+  data->blksz = grub_le_to_cpu32 (data->sb.block_size);
+  for (data->log2_blksz = 0; 
+       (1U << data->log2_blksz) < data->blksz;
+       data->log2_blksz++);
+
+  return data;
+}
+
+static char *
+grub_squash_read_symlink (grub_fshelp_node_t node)
+{
+  char *ret;
+  grub_err_t err;
+  ret = grub_malloc (grub_le_to_cpu32 (node->ino.symlink.namelen) + 1);
+
+  err = read_chunk (node->data, ret,
+                   grub_le_to_cpu32 (node->ino.symlink.namelen),
+                   grub_le_to_cpu64 (node->data->sb.inodeoffset)
+                   + node->stack[node->stsize - 1].ino_chunk,
+                   node->stack[node->stsize - 1].ino_offset
+                   + (node->ino.symlink.name - (char *) &node->ino));
+  if (err)
+    {
+      grub_free (ret);
+      return NULL;
+    }
+  ret[grub_le_to_cpu32 (node->ino.symlink.namelen)] = 0;
+  return ret;
+}
+
+static int
+grub_squash_iterate_dir (grub_fshelp_node_t dir,
+                        grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+  grub_uint32_t off;
+  grub_uint32_t endoff;
+  grub_uint64_t chunk;
+  unsigned i;
+
+  /* FIXME: why - 3 ? */
+  switch (dir->ino.type)
+    {
+    case grub_cpu_to_le16_compile_time (SQUASH_TYPE_DIR):
+      off = grub_le_to_cpu16 (dir->ino.dir.offset);
+      endoff = grub_le_to_cpu16 (dir->ino.dir.size) + off - 3;
+      chunk = grub_le_to_cpu32 (dir->ino.dir.chunk);
+      break;
+    case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_DIR):
+      off = grub_le_to_cpu16 (dir->ino.long_dir.offset);
+      endoff = grub_le_to_cpu16 (dir->ino.long_dir.size) + off - 3;
+      chunk = grub_le_to_cpu32 (dir->ino.long_dir.chunk);
+      break;
+    default:
+      grub_error (GRUB_ERR_BAD_FS, "unexpected ino type 0x%x",
+                 grub_le_to_cpu16 (dir->ino.type));
+      return 0;
+    }
+
+  {
+    grub_fshelp_node_t node;
+    node = grub_malloc (sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
+    if (!node)
+      return 0;
+    grub_memcpy (node, dir,
+                sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
+    if (hook (".", GRUB_FSHELP_DIR, node, hook_data))
+      return 1;
+
+    if (dir->stsize != 1)
+      {
+       grub_err_t err;
+
+       node = grub_malloc (sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
+       if (!node)
+         return 0;
+
+       grub_memcpy (node, dir,
+                    sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
+
+       node->stsize--;
+       err = read_chunk (dir->data, &node->ino, sizeof (node->ino),
+                         grub_le_to_cpu64 (dir->data->sb.inodeoffset)
+                         + node->stack[node->stsize - 1].ino_chunk,
+                         node->stack[node->stsize - 1].ino_offset);
+       if (err)
+         return 0;
+
+       if (hook ("..", GRUB_FSHELP_DIR, node, hook_data))
+         return 1;
+      }
+  }
+
+  while (off < endoff)
+    {
+      struct grub_squash_dirent_header dh;
+      grub_err_t err;
+
+      err = read_chunk (dir->data, &dh, sizeof (dh),
+                       grub_le_to_cpu64 (dir->data->sb.diroffset)
+                       + chunk, off);
+      if (err)
+       return 0;
+      off += sizeof (dh);
+      for (i = 0; i < (unsigned) grub_le_to_cpu32 (dh.nelems) + 1; i++)
+       {
+         char *buf;
+         int r;
+         struct grub_fshelp_node *node;
+         enum grub_fshelp_filetype filetype = GRUB_FSHELP_REG;
+         struct grub_squash_dirent di;
+         struct grub_squash_inode ino;
+
+         err = read_chunk (dir->data, &di, sizeof (di),
+                           grub_le_to_cpu64 (dir->data->sb.diroffset)
+                           + chunk, off);
+         if (err)
+           return 0;
+         off += sizeof (di);
+
+         err = read_chunk (dir->data, &ino, sizeof (ino),
+                           grub_le_to_cpu64 (dir->data->sb.inodeoffset)
+                           + grub_le_to_cpu32 (dh.ino_chunk),
+                           grub_cpu_to_le16 (di.ino_offset));
+         if (err)
+           return 0;
+
+         buf = grub_malloc (grub_le_to_cpu16 (di.namelen) + 2);
+         if (!buf)
+           return 0;
+         err = read_chunk (dir->data, buf,
+                           grub_le_to_cpu16 (di.namelen) + 1,
+                           grub_le_to_cpu64 (dir->data->sb.diroffset)
+                           + chunk, off);
+         if (err)
+           return 0;
+
+         off += grub_le_to_cpu16 (di.namelen) + 1;
+         buf[grub_le_to_cpu16 (di.namelen) + 1] = 0;
+         if (grub_le_to_cpu16 (di.type) == SQUASH_TYPE_DIR)
+           filetype = GRUB_FSHELP_DIR;
+         if (grub_le_to_cpu16 (di.type) == SQUASH_TYPE_SYMLINK)
+           filetype = GRUB_FSHELP_SYMLINK;
+
+         node = grub_malloc (sizeof (*node)
+                             + (dir->stsize + 1) * sizeof (dir->stack[0]));
+         if (! node)
+           return 0;
+
+         grub_memcpy (node, dir,
+                      sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
+
+         node->ino = ino;
+         node->stack[node->stsize].ino_chunk = grub_le_to_cpu32 (dh.ino_chunk);
+         node->stack[node->stsize].ino_offset = grub_le_to_cpu16 (di.ino_offset);
+         node->stsize++;
+         r = hook (buf, filetype, node, hook_data);
+
+         grub_free (buf);
+         if (r)
+           return r;
+       }
+    }
+  return 0;
+}
+
+static grub_err_t
+make_root_node (struct grub_squash_data *data, struct grub_fshelp_node *root)
+{
+  grub_memset (root, 0, sizeof (*root));
+  root->data = data;
+  root->stsize = 1;
+  root->stack[0].ino_chunk = grub_le_to_cpu32 (data->sb.root_ino_chunk);
+  root->stack[0].ino_offset = grub_cpu_to_le16 (data->sb.root_ino_offset);
+ return read_chunk (data, &root->ino, sizeof (root->ino),
+                   grub_le_to_cpu64 (data->sb.inodeoffset) 
+                   + root->stack[0].ino_chunk,
+                   root->stack[0].ino_offset);
+}
+
+static void
+squash_unmount (struct grub_squash_data *data)
+{
+  if (data->xzdec)
+    xz_dec_end (data->xzdec);
+  grub_free (data->xzbuf);
+  grub_free (data->ino.cumulated_block_sizes);
+  grub_free (data->ino.block_sizes);
+  grub_free (data);
+}
+
+
+/* Context for grub_squash_dir.  */
+struct grub_squash_dir_ctx
+{
+  grub_fs_dir_hook_t hook;
+  void *hook_data;
+};
+
+/* Helper for grub_squash_dir.  */
+static int
+grub_squash_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+                     grub_fshelp_node_t node, void *data)
+{
+  struct grub_squash_dir_ctx *ctx = data;
+  struct grub_dirhook_info info;
+
+  grub_memset (&info, 0, sizeof (info));
+  info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+  info.mtimeset = 1;
+  info.mtime = grub_le_to_cpu32 (node->ino.mtime);
+  grub_free (node);
+  return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_squash_dir (grub_device_t device, const char *path,
+                grub_fs_dir_hook_t hook, void *hook_data)
+{
+  struct grub_squash_dir_ctx ctx = { hook, hook_data };
+  struct grub_squash_data *data = 0;
+  struct grub_fshelp_node *fdiro = 0;
+  struct grub_fshelp_node root;
+  grub_err_t err;
+
+  data = squash_mount (device->disk);
+  if (! data)
+    return grub_errno;
+
+  err = make_root_node (data, &root);
+  if (err)
+    return err;
+
+  grub_fshelp_find_file (path, &root, &fdiro, grub_squash_iterate_dir,
+                        grub_squash_read_symlink, GRUB_FSHELP_DIR);
+  if (!grub_errno)
+    grub_squash_iterate_dir (fdiro, grub_squash_dir_iter, &ctx);
+
+  squash_unmount (data);
+
+  return grub_errno;
+}
+
+static grub_err_t
+grub_squash_open (struct grub_file *file, const char *name)
+{
+  struct grub_squash_data *data = 0;
+  struct grub_fshelp_node *fdiro = 0;
+  struct grub_fshelp_node root;
+  grub_err_t err;
+
+  data = squash_mount (file->device->disk);
+  if (! data)
+    return grub_errno;
+
+  err = make_root_node (data, &root);
+  if (err)
+    return err;
+
+  grub_fshelp_find_file (name, &root, &fdiro, grub_squash_iterate_dir,
+                        grub_squash_read_symlink, GRUB_FSHELP_REG);
+  if (grub_errno)
+    {
+      squash_unmount (data);
+      return grub_errno;
+    }
+
+  file->data = data;
+  data->ino.ino = fdiro->ino;
+  data->ino.block_sizes = NULL;
+  data->ino.cumulated_block_sizes = NULL;
+  data->ino.ino_chunk = fdiro->stack[fdiro->stsize - 1].ino_chunk;
+  data->ino.ino_offset = fdiro->stack[fdiro->stsize - 1].ino_offset;
+
+  switch (fdiro->ino.type)
+    {
+    case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR):
+      file->size = grub_le_to_cpu64 (fdiro->ino.long_file.size);
+      break;
+    case grub_cpu_to_le16_compile_time (SQUASH_TYPE_REGULAR):
+      file->size = grub_le_to_cpu32 (fdiro->ino.file.size);
+      break;
+    default:
+      {
+       grub_uint16_t type = grub_le_to_cpu16 (fdiro->ino.type);
+       grub_free (fdiro);
+       squash_unmount (data);
+       return grub_error (GRUB_ERR_BAD_FS, "unexpected ino type 0x%x", type);
+      }
+    }
+
+  grub_free (fdiro);
+
+  return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+direct_read (struct grub_squash_data *data, 
+            struct grub_squash_cache_inode *ino,
+            grub_off_t off, char *buf, grub_size_t len)
+{
+  grub_err_t err;
+  grub_off_t cumulated_uncompressed_size = 0;
+  grub_uint64_t a = 0;
+  grub_size_t i;
+  grub_size_t origlen = len;
+
+  switch (ino->ino.type)
+    {
+    case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR):
+      a = grub_le_to_cpu64 (ino->ino.long_file.chunk);
+      break;
+    case grub_cpu_to_le16_compile_time (SQUASH_TYPE_REGULAR):
+      a = grub_le_to_cpu32 (ino->ino.file.chunk);
+      break;
+    }
+
+  if (!ino->block_sizes)
+    {
+      grub_off_t total_size = 0;
+      grub_size_t total_blocks;
+      grub_size_t block_offset = 0;
+      switch (ino->ino.type)
+       {
+       case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR):
+         total_size = grub_le_to_cpu64 (ino->ino.long_file.size);
+         block_offset = ((char *) &ino->ino.long_file.block_size
+                         - (char *) &ino->ino);
+         break;
+       case grub_cpu_to_le16_compile_time (SQUASH_TYPE_REGULAR):
+         total_size = grub_le_to_cpu32 (ino->ino.file.size);
+         block_offset = ((char *) &ino->ino.file.block_size
+                         - (char *) &ino->ino);
+         break;
+       }
+      total_blocks = ((total_size + data->blksz - 1) >> data->log2_blksz);
+      ino->block_sizes = grub_malloc (total_blocks
+                                     * sizeof (ino->block_sizes[0]));
+      ino->cumulated_block_sizes = grub_malloc (total_blocks
+                                               * sizeof (ino->cumulated_block_sizes[0]));
+      if (!ino->block_sizes || !ino->cumulated_block_sizes)
+       {
+         grub_free (ino->block_sizes);
+         grub_free (ino->cumulated_block_sizes);
+         ino->block_sizes = 0;
+         ino->cumulated_block_sizes = 0;
+         return -1;
+       }
+      err = read_chunk (data, ino->block_sizes,
+                       total_blocks * sizeof (ino->block_sizes[0]),
+                       grub_le_to_cpu64 (data->sb.inodeoffset)
+                       + ino->ino_chunk,
+                       ino->ino_offset + block_offset);
+      if (err)
+       {
+         grub_free (ino->block_sizes);
+         grub_free (ino->cumulated_block_sizes);
+         ino->block_sizes = 0;
+         ino->cumulated_block_sizes = 0;
+         return -1;
+       }
+      ino->cumulated_block_sizes[0] = 0;
+      for (i = 1; i < total_blocks; i++)
+       ino->cumulated_block_sizes[i] = ino->cumulated_block_sizes[i - 1]
+         + (grub_le_to_cpu32 (ino->block_sizes[i - 1]) & ~SQUASH_BLOCK_FLAGS);
+    }
+
+  if (a == 0)
+    a = sizeof (struct grub_squash_super);
+  i = off >> data->log2_blksz;
+  cumulated_uncompressed_size = data->blksz * (grub_disk_addr_t) i;
+  while (cumulated_uncompressed_size < off + len)
+    {
+      grub_size_t boff, curread;
+      boff = off - cumulated_uncompressed_size;
+      curread = data->blksz - boff;
+      if (curread > len)
+       curread = len;
+      if (!ino->block_sizes[i])
+       {
+         /* Sparse block */
+         grub_memset (buf, '\0', curread);
+       }
+      else if (!(ino->block_sizes[i]
+           & grub_cpu_to_le32_compile_time (SQUASH_BLOCK_UNCOMPRESSED)))
+       {
+         char *block;
+         grub_size_t csize;
+         csize = grub_le_to_cpu32 (ino->block_sizes[i]) & ~SQUASH_BLOCK_FLAGS;
+         block = grub_malloc (csize);
+         if (!block)
+           return -1;
+         err = grub_disk_read (data->disk,
+                               (ino->cumulated_block_sizes[i] + a)
+                               >> GRUB_DISK_SECTOR_BITS,
+                               (ino->cumulated_block_sizes[i] + a)
+                               & (GRUB_DISK_SECTOR_SIZE - 1),
+                               csize, block);
+         if (err)
+           {
+             grub_free (block);
+             return -1;
+           }
+         if (data->decompress (block, csize, boff, buf, curread, data)
+             != (grub_ssize_t) curread)
+           {
+             grub_free (block);
+             if (!grub_errno)
+               grub_error (GRUB_ERR_BAD_FS, "incorrect compressed chunk");
+             return -1;
+           }
+         grub_free (block);
+       }
+      else
+       err = grub_disk_read (data->disk, 
+                             (ino->cumulated_block_sizes[i] + a + boff)
+                             >> GRUB_DISK_SECTOR_BITS,
+                             (ino->cumulated_block_sizes[i] + a + boff)
+                             & (GRUB_DISK_SECTOR_SIZE - 1),
+                             curread, buf);
+      if (err)
+       return -1;
+      off += curread;
+      len -= curread;
+      buf += curread;
+      cumulated_uncompressed_size += grub_le_to_cpu32 (data->sb.block_size);
+      i++;
+    }
+  return origlen;
+}
+
+
+static grub_ssize_t
+grub_squash_read (grub_file_t file, char *buf, grub_size_t len)
+{
+  struct grub_squash_data *data = file->data;
+  struct grub_squash_cache_inode *ino = &data->ino;
+  grub_off_t off = file->offset;
+  grub_err_t err;
+  grub_uint64_t a, b;
+  grub_uint32_t fragment = 0;
+  int compressed = 0;
+  struct grub_squash_frag_desc frag;
+  grub_off_t direct_len;
+  grub_uint64_t mask = grub_le_to_cpu32 (data->sb.block_size) - 1;
+  grub_size_t orig_len = len;
+
+  switch (ino->ino.type)
+    {
+    case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR):
+      fragment = grub_le_to_cpu32 (ino->ino.long_file.fragment);
+      break;
+    case grub_cpu_to_le16_compile_time (SQUASH_TYPE_REGULAR):
+      fragment = grub_le_to_cpu32 (ino->ino.file.fragment);
+      break;
+    }
+
+  /* Squash may pack file tail as fragment. So read initial part directly and
+     get tail from fragments */
+  direct_len = fragment == 0xffffffff ? file->size : file->size & ~mask;
+  if (off < direct_len)
+    {
+      grub_size_t read_len = direct_len - off;
+      grub_ssize_t res;
+
+      if (read_len > len)
+       read_len = len;
+      res = direct_read (data, ino, off, buf, read_len);
+      if ((grub_size_t) res != read_len)
+       return -1; /* FIXME: is short read possible here? */
+      len -= read_len;
+      if (!len)
+       return read_len;
+      buf += read_len;
+      off = 0;
+    }
+  else
+    off -= direct_len;
+  err = read_chunk (data, &frag, sizeof (frag),
+                   data->fragments, sizeof (frag) * fragment);
+  if (err)
+    return -1;
+  a = grub_le_to_cpu64 (frag.offset);
+  compressed = !(frag.size & grub_cpu_to_le32_compile_time (SQUASH_BLOCK_UNCOMPRESSED));
+  if (ino->ino.type == grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR))
+    b = grub_le_to_cpu32 (ino->ino.long_file.offset) + off;
+  else
+    b = grub_le_to_cpu32 (ino->ino.file.offset) + off;
+  
+  /* FIXME: cache uncompressed chunks.  */
+  if (compressed)
+    {
+      char *block;
+      block = grub_malloc (grub_le_to_cpu32 (frag.size));
+      if (!block)
+       return -1;
+      err = grub_disk_read (data->disk,
+                           a >> GRUB_DISK_SECTOR_BITS,
+                           a & (GRUB_DISK_SECTOR_SIZE - 1),
+                           grub_le_to_cpu32 (frag.size), block);
+      if (err)
+       {
+         grub_free (block);
+         return -1;
+       }
+      if (data->decompress (block, grub_le_to_cpu32 (frag.size),
+                           b, buf, len, data)
+         != (grub_ssize_t) len)
+       {
+         grub_free (block);
+         if (!grub_errno)
+           grub_error (GRUB_ERR_BAD_FS, "incorrect compressed chunk");
+         return -1;
+       }
+      grub_free (block);
+    }
+  else
+    {
+      err = grub_disk_read (data->disk, (a + b) >> GRUB_DISK_SECTOR_BITS,
+                         (a + b) & (GRUB_DISK_SECTOR_SIZE - 1), len, buf);
+      if (err)
+       return -1;
+    }
+  return orig_len;
+}
+
+static grub_err_t
+grub_squash_close (grub_file_t file)
+{
+  squash_unmount (file->data);
+  return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_squash_mtime (grub_device_t dev, grub_int32_t *tm)
+{
+  struct grub_squash_data *data = 0;
+
+  data = squash_mount (dev->disk);
+  if (! data)
+    return grub_errno;
+  *tm = grub_le_to_cpu32 (data->sb.creation_time);
+  squash_unmount (data);
+  return GRUB_ERR_NONE;
+} 
+
+static struct grub_fs grub_squash_fs =
+  {
+    .name = "squash4",
+    .fs_dir = grub_squash_dir,
+    .fs_open = grub_squash_open,
+    .fs_read = grub_squash_read,
+    .fs_close = grub_squash_close,
+    .fs_mtime = grub_squash_mtime,
+#ifdef GRUB_UTIL
+    .reserved_first_sector = 0,
+    .blocklist_install = 0,
+#endif
+    .next = 0
+  };
+
+GRUB_MOD_INIT(squash4)
+{
+  grub_fs_register (&grub_squash_fs);
+}
+
+GRUB_MOD_FINI(squash4)
+{
+  grub_fs_unregister (&grub_squash_fs);
+}
+
diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/fs/zfs/zfs_lz4.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/fs/zfs/zfs_lz4.c
new file mode 100644 (file)
index 0000000..0309905
--- /dev/null
@@ -0,0 +1,285 @@
+/*
+ * LZ4 - Fast LZ compression algorithm
+ * Header File
+ * Copyright (C) 2011-2013, Yann Collet.
+ * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You can contact the author at :
+ * - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
+ * - LZ4 source repository : http://code.google.com/p/lz4/
+ */
+
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+
+int LZ4_uncompress_unknownOutputSize(const char *source, char *dest,
+                                           int isize, int maxOutputSize);
+
+/*
+ * CPU Feature Detection
+ */
+
+/* 32 or 64 bits ? */
+#if (GRUB_CPU_SIZEOF_VOID_P == 8)
+#define        LZ4_ARCH64      1
+#else
+#define        LZ4_ARCH64      0
+#endif
+
+/*
+ * Compiler Options
+ */
+
+
+#define        GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+
+#if (GCC_VERSION >= 302) || (defined (__INTEL_COMPILER) && __INTEL_COMPILER >= 800) || defined(__clang__)
+#define        expect(expr, value)    (__builtin_expect((expr), (value)))
+#else
+#define        expect(expr, value)    (expr)
+#endif
+
+#define        likely(expr)    expect((expr) != 0, 1)
+#define        unlikely(expr)  expect((expr) != 0, 0)
+
+/* Basic types */
+#define        BYTE    grub_uint8_t
+#define        U16     grub_uint16_t
+#define        U32     grub_uint32_t
+#define        S32     grub_int32_t
+#define        U64     grub_uint64_t
+
+typedef struct _U16_S {
+       U16 v;
+} GRUB_PACKED U16_S;
+typedef struct _U32_S {
+       U32 v;
+} GRUB_PACKED U32_S;
+typedef struct _U64_S {
+       U64 v;
+} GRUB_PACKED U64_S;
+
+#define        A64(x)  (((U64_S *)(x))->v)
+#define        A32(x)  (((U32_S *)(x))->v)
+#define        A16(x)  (((U16_S *)(x))->v)
+
+/*
+ * Constants
+ */
+#define        MINMATCH 4
+
+#define        COPYLENGTH 8
+#define        LASTLITERALS 5
+
+#define        ML_BITS 4
+#define        ML_MASK ((1U<<ML_BITS)-1)
+#define        RUN_BITS (8-ML_BITS)
+#define        RUN_MASK ((1U<<RUN_BITS)-1)
+
+/*
+ * Architecture-specific macros
+ */
+#if LZ4_ARCH64
+#define        STEPSIZE 8
+#define        UARCH U64
+#define        AARCH A64
+#define        LZ4_COPYSTEP(s, d)      A64(d) = A64(s); d += 8; s += 8;
+#define        LZ4_COPYPACKET(s, d)    LZ4_COPYSTEP(s, d)
+#define        LZ4_SECURECOPY(s, d, e) if (d < e) LZ4_WILDCOPY(s, d, e)
+#define        HTYPE U32
+#define        INITBASE(base)          const BYTE* const base = ip
+#else
+#define        STEPSIZE 4
+#define        UARCH U32
+#define        AARCH A32
+#define        LZ4_COPYSTEP(s, d)      A32(d) = A32(s); d += 4; s += 4;
+#define        LZ4_COPYPACKET(s, d)    LZ4_COPYSTEP(s, d); LZ4_COPYSTEP(s, d);
+#define        LZ4_SECURECOPY          LZ4_WILDCOPY
+#define        HTYPE const BYTE*
+#define        INITBASE(base)          const int base = 0
+#endif
+
+#define        LZ4_READ_LITTLEENDIAN_16(d, s, p) { d = (s) - grub_le_to_cpu16 (A16 (p)); }
+#define        LZ4_WRITE_LITTLEENDIAN_16(p, v)  { A16(p) = grub_cpu_to_le16 (v); p += 2; }
+
+/* Macros */
+#define        LZ4_WILDCOPY(s, d, e) do { LZ4_COPYPACKET(s, d) } while (d < e);
+
+/* Decompression functions */
+grub_err_t
+lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len);
+
+grub_err_t
+lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len)
+{
+       const BYTE *src = s_start;
+       U32 bufsiz = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) |
+           src[3];
+
+       /* invalid compressed buffer size encoded at start */
+       if (bufsiz + 4 > s_len)
+               return grub_error(GRUB_ERR_BAD_FS,"lz4 decompression failed.");
+
+       /*
+        * Returns 0 on success (decompression function returned non-negative)
+        * and appropriate error on failure (decompression function returned negative).
+        */
+       return (LZ4_uncompress_unknownOutputSize((char*)s_start + 4, d_start, bufsiz,
+           d_len) < 0)?grub_error(GRUB_ERR_BAD_FS,"lz4 decompression failed."):0;
+}
+
+int
+LZ4_uncompress_unknownOutputSize(const char *source,
+    char *dest, int isize, int maxOutputSize)
+{
+       /* Local Variables */
+       const BYTE * ip = (const BYTE *) source;
+       const BYTE *const iend = ip + isize;
+       const BYTE * ref;
+
+       BYTE * op = (BYTE *) dest;
+       BYTE *const oend = op + maxOutputSize;
+       BYTE *cpy;
+
+       grub_size_t dec[] = { 0, 3, 2, 3, 0, 0, 0, 0 };
+
+       /* Main Loop */
+       while (ip < iend) {
+               BYTE token;
+               int length;
+
+               /* get runlength */
+               token = *ip++;
+               if ((length = (token >> ML_BITS)) == RUN_MASK) {
+                       int s = 255;
+                       while ((ip < iend) && (s == 255)) {
+                               s = *ip++;
+                               length += s;
+                       }
+               }
+               /* copy literals */
+               if ((grub_addr_t) length > ~(grub_addr_t)op)
+                 goto _output_error;
+               cpy = op + length;
+               if ((cpy > oend - COPYLENGTH) ||
+                   (ip + length > iend - COPYLENGTH)) {
+                       if (cpy > oend)
+                               /*
+                                * Error: request to write beyond destination
+                                * buffer.
+                                */
+                               goto _output_error;
+                       if (ip + length > iend)
+                               /*
+                                * Error : request to read beyond source
+                                * buffer.
+                                */
+                               goto _output_error;
+                       grub_memcpy(op, ip, length);
+                       op += length;
+                       ip += length;
+                       if (ip < iend)
+                               /* Error : LZ4 format violation */
+                               goto _output_error;
+                       /* Necessarily EOF, due to parsing restrictions. */
+                       break;
+               }
+               LZ4_WILDCOPY(ip, op, cpy);
+               ip -= (op - cpy);
+               op = cpy;
+
+               /* get offset */
+               LZ4_READ_LITTLEENDIAN_16(ref, cpy, ip);
+               ip += 2;
+               if (ref < (BYTE * const) dest)
+                       /*
+                        * Error: offset creates reference outside of
+                        * destination buffer.
+                        */
+                       goto _output_error;
+
+               /* get matchlength */
+               if ((length = (token & ML_MASK)) == ML_MASK) {
+                       while (ip < iend) {
+                               int s = *ip++;
+                               length += s;
+                               if (s == 255)
+                                       continue;
+                               break;
+                       }
+               }
+               /* copy repeated sequence */
+               if unlikely(op - ref < STEPSIZE) {
+#if LZ4_ARCH64
+                       grub_size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
+                       grub_size_t dec2 = dec2table[op - ref];
+#else
+                       const int dec2 = 0;
+#endif
+                       *op++ = *ref++;
+                       *op++ = *ref++;
+                       *op++ = *ref++;
+                       *op++ = *ref++;
+                       ref -= dec[op - ref];
+                       A32(op) = A32(ref);
+                       op += STEPSIZE - 4;
+                       ref -= dec2;
+               } else {
+                       LZ4_COPYSTEP(ref, op);
+               }
+               cpy = op + length - (STEPSIZE - 4);
+               if (cpy > oend - COPYLENGTH) {
+                       if (cpy > oend)
+                               /*
+                                * Error: request to write outside of
+                                * destination buffer.
+                                */
+                               goto _output_error;
+                       LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
+                       while (op < cpy)
+                               *op++ = *ref++;
+                       op = cpy;
+                       if (op == oend)
+                               /*
+                                * Check EOF (should never happen, since last
+                                * 5 bytes are supposed to be literals).
+                                */
+                               break;
+                       continue;
+               }
+               LZ4_SECURECOPY(ref, op, cpy);
+               op = cpy;       /* correction */
+       }
+
+       /* end of decoding */
+       return (int)(((char *)op) - dest);
+
+       /* write overflow error detected */
+       _output_error:
+       return (int)(-(((char *)ip) - source));
+}
index c95ca4c73b9c3b54bff0c0852ec9b3c1f5af8ade..2f1f83f7a1423b8e3d6b5618481553b1dcfe9998 100644 (file)
@@ -12,14 +12,14 @@ make install
 PATH=$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/:$PATH
 
 net_modules_legacy="net tftp http"
-all_modules_legacy="file setkey date drivemap blocklist regexp newc vga_text ntldr search at_keyboard usb_keyboard  gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal  linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal  udf gfxmenu gfxterm gfxterm_background gfxterm_menu smbios"
+all_modules_legacy="file setkey date drivemap blocklist regexp newc vga_text ntldr search at_keyboard usb_keyboard  gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal  linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal  udf gfxmenu gfxterm gfxterm_background gfxterm_menu smbios zfs"
 
 net_modules_uefi="efinet net tftp http"
-all_modules_uefi="file setkey blocklist ventoy test true regexp newc search at_keyboard usb_keyboard  gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain  priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu mouse fwload smbios"
+all_modules_uefi="file setkey blocklist ventoy test true regexp newc search at_keyboard usb_keyboard  gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain  priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu mouse fwload smbios zfs"
 
-all_modules_arm64_uefi="file setkey blocklist ventoy test true regexp newc search  gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain  priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu"
+all_modules_arm64_uefi="file setkey blocklist ventoy test true regexp newc search  gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain  priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu zfs"
 
-all_modules_mips64el_uefi="file setkey blocklist ventoy test true regexp newc search  gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain  priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu"
+all_modules_mips64el_uefi="file setkey blocklist ventoy test true regexp newc search  gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain  priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu zfs"
 
 
 if [ "$1" = "uefi" ]; then
diff --git a/INSTALL/grub/arm64-efi/gfxterm_menu.mod b/INSTALL/grub/arm64-efi/gfxterm_menu.mod
deleted file mode 100644 (file)
index 3608436..0000000
Binary files a/INSTALL/grub/arm64-efi/gfxterm_menu.mod and /dev/null differ
index c92f6837368aa9a2410c0677992f19635bb4ebe5..13604371f333f0de83267143275776cf5a4e89cd 100644 (file)
Binary files a/INSTALL/grub/arm64-efi/moddep.lst and b/INSTALL/grub/arm64-efi/moddep.lst differ
index 4ed99c2d8babb390d0bddbb4c655da2466e667fc..5c0a3c4225b9077e3322e942da8a98d234cf183a 100644 (file)
Binary files a/INSTALL/grub/arm64-efi/zfs.mod and b/INSTALL/grub/arm64-efi/zfs.mod differ
index 5ce89d849254051ab4e1bb7ea1ca528ca5ecfe54..1e8687a59d25d4f1415a0f60cbb5f6f3ce5019dd 100644 (file)
@@ -201,7 +201,7 @@ cbmemc: cbtable normal terminfo
 hfsplus: fshelp
 gcry_cast5: crypto
 extcmd:
-squash4: fshelp lzopio xzio gzio
+squash4: fshelp lzopio zfs xzio gzio
 part_plan:
 minix_be:
 gcry_whirlpool: crypto
diff --git a/INSTALL/grub/i386-efi/smbios.mod b/INSTALL/grub/i386-efi/smbios.mod
deleted file mode 100644 (file)
index 5d1555f..0000000
Binary files a/INSTALL/grub/i386-efi/smbios.mod and /dev/null differ
index b5fa5d532034a84f3facda0d0e3fe1a7e66ebefd..6953b93168607890059f9e127fc163e97b1a25d7 100644 (file)
Binary files a/INSTALL/grub/i386-efi/zfs.mod and b/INSTALL/grub/i386-efi/zfs.mod differ
index 25bbd536088268b145cb14780edc324261f32873..8e851501cb47903a6ae67b8ee2855aa4126e33d0 100644 (file)
@@ -208,7 +208,7 @@ cmosdump:
 hfsplus: fshelp
 gcry_cast5: crypto
 extcmd:
-squash4: fshelp lzopio xzio gzio
+squash4: fshelp lzopio zfs xzio gzio
 part_plan:
 minix_be:
 gcry_whirlpool: crypto
index eb5d3264a874e9692beab894605c4051929459d8..9f13caf77c6ec09ac25995a8f8b2155aec14288c 100644 (file)
Binary files a/INSTALL/grub/i386-pc/zfs.mod and b/INSTALL/grub/i386-pc/zfs.mod differ
diff --git a/INSTALL/grub/mips64el-efi/gfxterm_menu.mod b/INSTALL/grub/mips64el-efi/gfxterm_menu.mod
deleted file mode 100644 (file)
index ddc1d55..0000000
Binary files a/INSTALL/grub/mips64el-efi/gfxterm_menu.mod and /dev/null differ
index 66987c4dd3257d55181b9b0553a9b1085c2f4e43..1b5cc71e6bc9fd258473c0e6a4811d316e2db3de 100644 (file)
Binary files a/INSTALL/grub/mips64el-efi/moddep.lst and b/INSTALL/grub/mips64el-efi/moddep.lst differ
index 4d22ea773a3eb57326776a5fc5101df32000562a..46fe08692ca3e110a10a902fe3ff802f8c6c98ad 100644 (file)
Binary files a/INSTALL/grub/mips64el-efi/zfs.mod and b/INSTALL/grub/mips64el-efi/zfs.mod differ
index a0a40bcba0ca745593b9813255d765d908989d75..2f03bb96d2cd1773c5d54f620709c22ee12a4ac2 100644 (file)
@@ -202,7 +202,7 @@ cbmemc: cbtable normal terminfo
 hfsplus: fshelp
 gcry_cast5: crypto
 extcmd:
-squash4: fshelp lzopio xzio gzio
+squash4: fshelp lzopio zfs xzio gzio
 part_plan:
 minix_be:
 gcry_whirlpool: crypto
diff --git a/INSTALL/grub/x86_64-efi/smbios.mod b/INSTALL/grub/x86_64-efi/smbios.mod
deleted file mode 100644 (file)
index 0176d06..0000000
Binary files a/INSTALL/grub/x86_64-efi/smbios.mod and /dev/null differ
index b213ee3f045623eaeb8af7759b0401cb6b3306c4..86bd3a446a0056f0337ab9cba67aa9a4ebaf3583 100644 (file)
Binary files a/INSTALL/grub/x86_64-efi/zfs.mod and b/INSTALL/grub/x86_64-efi/zfs.mod differ