Print this page
%B

Split Close
Expand all
Collapse all
          --- old/usr/src/grub/grub-0.97/stage2/fsys_zfs.c
          +++ new/usr/src/grub/grub-0.97/stage2/fsys_zfs.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18   18   */
  19   19  
  20   20  /*
  21   21   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  22   22   * Use is subject to license terms.
  23   23   */
  24   24  
  25   25  /*
  26   26   * Copyright (c) 2012 by Delphix. All rights reserved.
       27 + * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  27   28   */
  28   29  
  29   30  /*
  30   31   * The zfs plug-in routines for GRUB are:
  31   32   *
  32   33   * zfs_mount() - locates a valid uberblock of the root pool and reads
  33   34   *              in its MOS at the memory address MOS.
  34   35   *
  35   36   * zfs_open() - locates a plain file object by following the MOS
  36   37   *              and places its dnode at the memory address DNODE.
↓ open down ↓ 30 lines elided ↑ open up ↑
  67   68  static uint64_t pool_guid = 0;
  68   69  static uberblock_t current_uberblock;
  69   70  static char *stackbase;
  70   71  
  71   72  decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] =
  72   73  {
  73   74          {"inherit", 0},                 /* ZIO_COMPRESS_INHERIT */
  74   75          {"on", lzjb_decompress},        /* ZIO_COMPRESS_ON */
  75   76          {"off", 0},                     /* ZIO_COMPRESS_OFF */
  76   77          {"lzjb", lzjb_decompress},      /* ZIO_COMPRESS_LZJB */
  77      -        {"empty", 0}                    /* ZIO_COMPRESS_EMPTY */
       78 +        {"empty", 0},                   /* ZIO_COMPRESS_EMPTY */
       79 +        {"gzip-1", 0},                  /* ZIO_COMPRESS_GZIP_1 */
       80 +        {"gzip-2", 0},                  /* ZIO_COMPRESS_GZIP_2 */
       81 +        {"gzip-3", 0},                  /* ZIO_COMPRESS_GZIP_3 */
       82 +        {"gzip-4", 0},                  /* ZIO_COMPRESS_GZIP_4 */
       83 +        {"gzip-5", 0},                  /* ZIO_COMPRESS_GZIP_5 */
       84 +        {"gzip-6", 0},                  /* ZIO_COMPRESS_GZIP_6 */
       85 +        {"gzip-7", 0},                  /* ZIO_COMPRESS_GZIP_7 */
       86 +        {"gzip-8", 0},                  /* ZIO_COMPRESS_GZIP_8 */
       87 +        {"gzip-9", 0},                  /* ZIO_COMPRESS_GZIP_9 */
       88 +        {"zle", 0},                     /* ZIO_COMPRESS_ZLE */
       89 +        {"lz4", lz4_decompress}         /* ZIO_COMPRESS_LZ4 */
  78   90  };
  79   91  
  80   92  static int zio_read_data(blkptr_t *bp, void *buf, char *stack);
  81   93  
  82   94  /*
  83   95   * Our own version of bcmp().
  84   96   */
  85   97  static int
  86   98  zfs_bcmp(const void *s1, const void *s2, size_t n)
  87   99  {
↓ open down ↓ 317 lines elided ↑ open up ↑
 405  417          if (zio_read_data(bp, buf, stack) != 0) {
 406  418                  grub_printf("zio_read_data failed\n");
 407  419                  return (ERR_FSYS_CORRUPT);
 408  420          }
 409  421  
 410  422          if (zio_checksum_verify(bp, buf, psize) != 0) {
 411  423                  grub_printf("checksum verification failed\n");
 412  424                  return (ERR_FSYS_CORRUPT);
 413  425          }
 414  426  
 415      -        if (comp != ZIO_COMPRESS_OFF)
 416      -                decomp_table[comp].decomp_func(buf, retbuf, psize, lsize);
      427 +        if (comp != ZIO_COMPRESS_OFF) {
      428 +                if (decomp_table[comp].decomp_func(buf, retbuf, psize,
      429 +                    lsize) != 0) {
      430 +                        grub_printf("zio_read decompression failed\n");
      431 +                        return (ERR_FSYS_CORRUPT);
      432 +                }
      433 +        }
 417  434  
 418  435          return (0);
 419  436  }
 420  437  
 421  438  /*
 422  439   * Get the block from a block id.
 423  440   * push the block onto the stack.
 424  441   *
 425  442   * Return:
 426  443   *      0 - success
↓ open down ↓ 511 lines elided ↑ open up ↑
 938  955          *obj = objnum;
 939  956          return (0);
 940  957  }
 941  958  
 942  959  /*
 943  960   * List of pool features that the grub implementation of ZFS supports for
 944  961   * read. Note that features that are only required for write do not need
 945  962   * to be listed here since grub opens pools in read-only mode.
 946  963   */
 947  964  static const char *spa_feature_names[] = {
      965 +        "org.illumos:lz4_compress",
 948  966          NULL
 949  967  };
 950  968  
 951  969  /*
 952  970   * Checks whether the MOS features that are active are supported by this
 953  971   * (GRUB's) implementation of ZFS.
 954  972   *
 955  973   * Return:
 956  974   *      0: Success.
 957  975   *      errnum: Failure.
↓ open down ↓ 820 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX