diff options
author | Mike Gilbert <floppym@gentoo.org> | 2014-02-28 18:14:39 +0000 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2014-02-28 18:14:39 +0000 |
commit | c67631cb8ac39621d4359909a5974596c0606b4b (patch) | |
tree | 1f57b4702a291ec0a25110afb4797a84a368bbc3 /sys-boot | |
parent | Remove old ebuilds. (diff) | |
download | gentoo-2-c67631cb8ac39621d4359909a5974596c0606b4b.tar.gz gentoo-2-c67631cb8ac39621d4359909a5974596c0606b4b.tar.bz2 gentoo-2-c67631cb8ac39621d4359909a5974596c0606b4b.zip |
Remove unused files in FILESDIR.
(Portage version: 2.2.8-r1/cvs/Linux x86_64, signed Manifest commit with key 0BBEEA1FEA4843A4)
Diffstat (limited to 'sys-boot')
21 files changed, 18 insertions, 3153 deletions
diff --git a/sys-boot/grub/ChangeLog b/sys-boot/grub/ChangeLog index c42e9d45031b..fe82d6fc358c 100644 --- a/sys-boot/grub/ChangeLog +++ b/sys-boot/grub/ChangeLog @@ -1,6 +1,23 @@ # ChangeLog for sys-boot/grub # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/ChangeLog,v 1.306 2014/02/28 18:10:11 floppym Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/ChangeLog,v 1.307 2014/02/28 18:14:39 floppym Exp $ + + 28 Feb 2014; Mike Gilbert <floppym@gentoo.org> + -files/1.99-call_proper_grub_probe.patch, + -files/1.99-do_not_stat_so_often.patch, -files/1.99-improve_devmapper.patch, + -files/1.99-stat_root_device_properly-p1.patch, + -files/1.99-stat_root_device_properly-p2.patch, + -files/grub-2.00-20_linux_xen.patch, -files/grub-2.00-compression.patch, + -files/grub-2.00-config-quoting.patch, -files/grub-2.00-dmraid.patch, + -files/grub-2.00-freebsd.patch, -files/grub-2.00-hardcoded-awk.patch, + -files/grub-2.00-no-gets.patch, -files/grub-2.00-os-prober-efi-system.patch, + -files/grub-2.00-parallel-make.patch, -files/grub-2.00-texinfo.patch, + -files/grub-2.00-tftp-endian.patch, + -files/grub-2.00-zfs-feature-flag-support-r1.patch, + -files/grub-2.00-zfs-feature-flag-support.patch, + -files/grub-2.02_beta1-only-use-scripts-that-are-executable.patch, + -files/grub.default: + Remove unused files in FILESDIR. 28 Feb 2014; Mike Gilbert <floppym@gentoo.org> -grub-0.97-r10.ebuild, -grub-0.97-r11.ebuild, -grub-1.99-r2.ebuild, -grub-2.00-r4.ebuild, diff --git a/sys-boot/grub/files/1.99-call_proper_grub_probe.patch b/sys-boot/grub/files/1.99-call_proper_grub_probe.patch deleted file mode 100644 index 6d65b5f85d3b..000000000000 --- a/sys-boot/grub/files/1.99-call_proper_grub_probe.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -urN grub-1.99/util/grub.d/30_os-prober.in grub-1.99.new/util/grub.d/30_os-prober.in ---- grub-1.99/util/grub.d/30_os-prober.in 2010-12-25 18:13:57.000000000 +0100 -+++ grub-1.99.new/util/grub.d/30_os-prober.in 2011-08-28 12:35:40.965038455 +0200 -@@ -168,7 +168,7 @@ - done - ;; - macosx) -- OSXUUID="`grub-probe --target=fs_uuid --device ${DEVICE} 2> /dev/null`" -+ OSXUUID="`${grub_probe} --target=fs_uuid --device ${DEVICE} 2> /dev/null`" - osx_entry xnu_kernel 32 - osx_entry xnu_kernel64 64 - ;; diff --git a/sys-boot/grub/files/1.99-do_not_stat_so_often.patch b/sys-boot/grub/files/1.99-do_not_stat_so_often.patch deleted file mode 100644 index ca8a0239003b..000000000000 --- a/sys-boot/grub/files/1.99-do_not_stat_so_often.patch +++ /dev/null @@ -1,65 +0,0 @@ ---- grub-core/kern/emu/getroot.c 2011-05-18 07:35:47 +0000 -+++ grub-core/kern/emu/getroot.c 2011-05-21 05:03:55 +0000 -@@ -358,7 +358,7 @@ - - if (S_ISLNK (st.st_mode)) { - #ifdef __linux__ -- if (strcmp (dir, "mapper") == 0) { -+ if (strcmp (dir, "mapper") == 0 || strcmp (dir, "/dev/mapper") == 0) { - /* Follow symbolic links under /dev/mapper/; the canonical name - may be something like /dev/dm-0, but the names under - /dev/mapper/ are more human-readable and so we prefer them if -@@ -609,20 +609,27 @@ - - if (os_dev) - { -- if (stat (os_dev, &st) >= 0) -- dev = st.st_rdev; -- else -+ char *tmp = os_dev; -+ os_dev = canonicalize_file_name (os_dev); -+ free (tmp); -+ } -+ -+ if (os_dev) -+ { -+ if (strncmp (os_dev, "/dev/dm-", sizeof ("/dev/dm-") - 1) != 0) -+ return os_dev; -+ if (stat (os_dev, &st) < 0) - grub_util_error ("cannot stat `%s'", os_dev); - free (os_dev); -- } -- else -- { -- if (stat (dir, &st) >= 0) -- dev = st.st_dev; -- else -- grub_util_error ("cannot stat `%s'", dir); -- } -- -+ dev = st.st_rdev; -+ return grub_find_device ("/dev/mapper", dev); -+ } -+ -+ if (stat (dir, &st) < 0) -+ grub_util_error ("cannot stat `%s'", dir); -+ -+ dev = st.st_dev; -+ - #ifdef __CYGWIN__ - /* Cygwin specific function. */ - os_dev = grub_find_device (dir, dev); - ---- grub-core/kern/emu/hostdisk.c 2011-05-18 07:35:47 +0000 -+++ grub-core/kern/emu/hostdisk.c 2011-05-21 05:03:55 +0000 -@@ -1408,7 +1408,8 @@ - if (tree) - dm_tree_free (tree); - free (path); -- char *ret = grub_find_device (NULL, (major << 8) | minor); -+ char *ret = grub_find_device ("/dev/mapper", -+ (major << 8) | minor); - return ret; - } - - diff --git a/sys-boot/grub/files/1.99-improve_devmapper.patch b/sys-boot/grub/files/1.99-improve_devmapper.patch deleted file mode 100644 index 5f0a930e3773..000000000000 --- a/sys-boot/grub/files/1.99-improve_devmapper.patch +++ /dev/null @@ -1,279 +0,0 @@ ---- grub-core/kern/emu/getroot.c 2011-04-21 09:26:29 +0000 -+++ grub-core/kern/emu/getroot.c 2011-05-18 07:35:47 +0000 -@@ -34,6 +34,10 @@ - #include <stdint.h> - #include <grub/util/misc.h> - -+#ifdef HAVE_DEVICE_MAPPER -+# include <libdevmapper.h> -+#endif -+ - #ifdef __GNU__ - #include <hurd.h> - #include <hurd/lookup.h> -@@ -634,32 +638,65 @@ - } - - static int --grub_util_is_dmraid (const char *os_dev) -+grub_util_is_lvm (const char *os_dev) - { -- if (! strncmp (os_dev, "/dev/mapper/nvidia_", 19)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/isw_", 16)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/hpt37x_", 19)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/hpt45x_", 19)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/via_", 16)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/lsi_", 16)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/pdc_", 16)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/jmicron_", 20)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/asr_", 16)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/sil_", 16)) -- return 1; -- else if (! strncmp (os_dev, "/dev/mapper/ddf1_", 17)) -- return 1; -- -- return 0; -+ if ((strncmp ("/dev/mapper/", os_dev, 12) != 0)) -+ return 0; -+ -+#ifdef HAVE_DEVICE_MAPPER -+ { -+ struct dm_tree *tree; -+ uint32_t maj, min; -+ struct dm_tree_node *node = NULL; -+ const char *node_uuid; -+ struct stat st; -+ -+ if (stat (os_dev, &st) < 0) -+ return 0; -+ -+ tree = dm_tree_create (); -+ if (! tree) -+ { -+ grub_printf ("Failed to create tree\n"); -+ grub_dprintf ("hostdisk", "dm_tree_create failed\n"); -+ return 0; -+ } -+ -+ maj = major (st.st_rdev); -+ min = minor (st.st_rdev); -+ -+ if (! dm_tree_add_dev (tree, maj, min)) -+ { -+ grub_dprintf ("hostdisk", "dm_tree_add_dev failed\n"); -+ dm_tree_free (tree); -+ return 0; -+ } -+ -+ node = dm_tree_find_node (tree, maj, min); -+ if (! node) -+ { -+ grub_dprintf ("hostdisk", "dm_tree_find_node failed\n"); -+ dm_tree_free (tree); -+ return 0; -+ } -+ node_uuid = dm_tree_node_get_uuid (node); -+ if (! node_uuid) -+ { -+ grub_dprintf ("hostdisk", "%s has no DM uuid\n", os_dev); -+ dm_tree_free (tree); -+ return 0; -+ } -+ if (strncmp (node_uuid, "LVM-", 4) != 0) -+ { -+ dm_tree_free (tree); -+ return 0; -+ } -+ dm_tree_free (tree); -+ return 1; -+ } -+#else -+ return 1; -+#endif /* HAVE_DEVICE_MAPPER */ - } - - int -@@ -671,13 +708,11 @@ - return GRUB_DEV_ABSTRACTION_NONE; - - /* Check for LVM. */ -- if (!strncmp (os_dev, "/dev/mapper/", 12) -- && ! grub_util_is_dmraid (os_dev) -- && strncmp (os_dev, "/dev/mapper/mpath", 17) != 0) -+ if (grub_util_is_lvm (os_dev)) - return GRUB_DEV_ABSTRACTION_LVM; - - /* Check for RAID. */ -- if (!strncmp (os_dev, "/dev/md", 7)) -+ if (!strncmp (os_dev, "/dev/md", 7) && ! grub_util_device_is_mapped (os_dev)) - return GRUB_DEV_ABSTRACTION_RAID; - #endif - - -=== modified file 'grub-core/kern/emu/hostdisk.c' ---- grub-core/kern/emu/hostdisk.c 2011-05-09 16:59:35 +0000 -+++ grub-core/kern/emu/hostdisk.c 2011-05-18 07:35:47 +0000 -@@ -24,6 +24,7 @@ - #include <grub/err.h> - #include <grub/emu/misc.h> - #include <grub/emu/hostdisk.h> -+#include <grub/emu/getroot.h> - #include <grub/misc.h> - #include <grub/i18n.h> - #include <grub/list.h> -@@ -331,18 +332,23 @@ - return GRUB_ERR_NONE; - } - -+int -+grub_util_device_is_mapped (const char *dev) -+{ - #ifdef HAVE_DEVICE_MAPPER --static int --device_is_mapped (const char *dev) --{ - struct stat st; - -+ if (!grub_device_mapper_supported ()) -+ return 0; -+ - if (stat (dev, &st) < 0) - return 0; - - return dm_is_dm_major (major (st.st_rdev)); -+#else -+ return 0; -+#endif /* HAVE_DEVICE_MAPPER */ - } --#endif /* HAVE_DEVICE_MAPPER */ - - #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) - /* FIXME: geom actually gives us the whole container hierarchy. -@@ -418,7 +424,7 @@ - # endif /* !defined(HAVE_DIOCGDINFO) */ - - # ifdef HAVE_DEVICE_MAPPER -- if (grub_device_mapper_supported () && device_is_mapped (dev)) { -+ if (grub_util_device_is_mapped (dev)) { - struct dm_task *task = NULL; - grub_uint64_t start, length; - char *target_type, *params, *space; -@@ -1149,6 +1155,54 @@ - return ret; - } - -+#ifdef HAVE_DEVICE_MAPPER -+static int -+grub_util_get_dm_node_linear_info (const char *dev, -+ int *maj, int *min) -+{ -+ struct dm_task *dmt; -+ void *next = NULL; -+ uint64_t length, start; -+ char *target, *params; -+ char *ptr; -+ int major, minor; -+ -+ dmt = dm_task_create(DM_DEVICE_TABLE); -+ if (!dmt) -+ return 0; -+ -+ if (!dm_task_set_name(dmt, dev)) -+ return 0; -+ dm_task_no_open_count(dmt); -+ if (!dm_task_run(dmt)) -+ return 0; -+ next = dm_get_next_target(dmt, next, &start, &length, -+ &target, ¶ms); -+ if (grub_strcmp (target, "linear") != 0) -+ return 0; -+ major = grub_strtoul (params, &ptr, 10); -+ if (grub_errno) -+ { -+ grub_errno = GRUB_ERR_NONE; -+ return 0; -+ } -+ if (*ptr != ':') -+ return 0; -+ ptr++; -+ minor = grub_strtoul (ptr, 0, 10); -+ if (grub_errno) -+ { -+ grub_errno = GRUB_ERR_NONE; -+ return 0; -+ } -+ if (maj) -+ *maj = major; -+ if (min) -+ *min = minor; -+ return 1; -+} -+#endif -+ - static char * - convert_system_partition_to_system_disk (const char *os_dev, struct stat *st) - { -@@ -1325,9 +1379,39 @@ - node = NULL; - goto devmapper_out; - } -- else if (strncmp (node_uuid, "DMRAID-", 7) != 0) -- { -+ if (strncmp (node_uuid, "LVM-", 4) == 0) -+ { -+ grub_dprintf ("hostdisk", "%s is an LVM\n", path); -+ node = NULL; -+ goto devmapper_out; -+ } -+ if (strncmp (node_uuid, "mpath-", 6) == 0) -+ { -+ /* Multipath partitions have partN-mpath-* UUIDs, and are -+ linear mappings so are handled by -+ grub_util_get_dm_node_linear_info. Multipath disks are not -+ linear mappings and must be handled specially. */ -+ grub_dprintf ("hostdisk", "%s is a multipath disk\n", path); -+ mapper_name = dm_tree_node_get_name (node); -+ goto devmapper_out; -+ } -+ if (strncmp (node_uuid, "DMRAID-", 7) != 0) -+ { -+ int major, minor; -+ const char *node_name; - grub_dprintf ("hostdisk", "%s is not DM-RAID\n", path); -+ -+ if ((node_name = dm_tree_node_get_name (node)) -+ && grub_util_get_dm_node_linear_info (node_name, -+ &major, &minor)) -+ { -+ if (tree) -+ dm_tree_free (tree); -+ free (path); -+ char *ret = grub_find_device (NULL, (major << 8) | minor); -+ return ret; -+ } -+ - node = NULL; - goto devmapper_out; - } - ---- include/grub/emu/misc.h 2010-12-02 13:26:46 +0000 -+++ include/grub/emu/misc.h 2011-05-18 07:35:47 +0000 -@@ -54,6 +54,8 @@ - - char *grub_make_system_path_relative_to_its_root (const char *path) - __attribute__ ((warn_unused_result)); -+int -+grub_util_device_is_mapped (const char *dev); - - void * EXPORT_FUNC(xmalloc) (grub_size_t size) __attribute__ ((warn_unused_result)); - void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) __attribute__ ((warn_unused_result)); - diff --git a/sys-boot/grub/files/1.99-stat_root_device_properly-p1.patch b/sys-boot/grub/files/1.99-stat_root_device_properly-p1.patch deleted file mode 100644 index fc14c536b879..000000000000 --- a/sys-boot/grub/files/1.99-stat_root_device_properly-p1.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- grub-core/kern/emu/getroot.c 2011-05-21 05:03:55 +0000 -+++ grub-core/kern/emu/getroot.c 2011-06-23 17:50:41 +0000 -@@ -616,13 +616,15 @@ - - if (os_dev) - { -- if (strncmp (os_dev, "/dev/dm-", sizeof ("/dev/dm-") - 1) != 0) -+ int dm = (strncmp (os_dev, "/dev/dm-", sizeof ("/dev/dm-") - 1) == 0); -+ int root = (strcmp (os_dev, "/dev/root") == 0); -+ if (!dm && !root) - return os_dev; - if (stat (os_dev, &st) < 0) - grub_util_error ("cannot stat `%s'", os_dev); - free (os_dev); - dev = st.st_rdev; -- return grub_find_device ("/dev/mapper", dev); -+ return grub_find_device (dm ? "/dev/mapper" : "/dev", dev); - } - - if (stat (dir, &st) < 0) - diff --git a/sys-boot/grub/files/1.99-stat_root_device_properly-p2.patch b/sys-boot/grub/files/1.99-stat_root_device_properly-p2.patch deleted file mode 100644 index aa7fd1867560..000000000000 --- a/sys-boot/grub/files/1.99-stat_root_device_properly-p2.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- grub-core/kern/emu/getroot.c 2011-06-23 17:50:41 +0000 -+++ grub-core/kern/emu/getroot.c 2011-06-24 02:32:54 +0000 -@@ -620,11 +620,13 @@ - int root = (strcmp (os_dev, "/dev/root") == 0); - if (!dm && !root) - return os_dev; -- if (stat (os_dev, &st) < 0) -- grub_util_error ("cannot stat `%s'", os_dev); -+ if (stat (os_dev, &st) >= 0) -+ { -+ free (os_dev); -+ dev = st.st_rdev; -+ return grub_find_device (dm ? "/dev/mapper" : "/dev", dev); -+ } - free (os_dev); -- dev = st.st_rdev; -- return grub_find_device (dm ? "/dev/mapper" : "/dev", dev); - } - - if (stat (dir, &st) < 0) - diff --git a/sys-boot/grub/files/grub-2.00-20_linux_xen.patch b/sys-boot/grub/files/grub-2.00-20_linux_xen.patch deleted file mode 100644 index c83f0b04aaa3..000000000000 --- a/sys-boot/grub/files/grub-2.00-20_linux_xen.patch +++ /dev/null @@ -1,14 +0,0 @@ -Fix detection of genkernel initramfs for xen - -https://bugs.gentoo.org/show_bug.cgi?id=463992 - ---- a/util/grub.d/20_linux_xen.in -+++ b/util/grub.d/20_linux_xen.in -@@ -174,6 +174,7 @@ - - title_correction_code= - -+machine=`uname -m` - case "$machine" in - i?86) GENKERNEL_ARCH="x86" ;; - mips|mips64) GENKERNEL_ARCH="mips" ;; diff --git a/sys-boot/grub/files/grub-2.00-compression.patch b/sys-boot/grub/files/grub-2.00-compression.patch deleted file mode 100644 index 58bc1f9327e6..000000000000 --- a/sys-boot/grub/files/grub-2.00-compression.patch +++ /dev/null @@ -1,84 +0,0 @@ -https://bugs.gentoo.org/show_bug.cgi?id=424527 -https://savannah.gnu.org/bugs/index.php?36770 - -=== modified file 'grub-core/lib/xzembed/xz_dec_stream.c' ---- grub-core/lib/xzembed/xz_dec_stream.c 2012-02-29 13:56:51 +0000 -+++ grub-core/lib/xzembed/xz_dec_stream.c 2012-07-22 14:27:03 +0000 -@@ -403,18 +403,25 @@ - } - #endif - -- do { -+ if (b->in_pos == b->in_size) -+ return XZ_OK; -+ -+ if (!crc32 && s->hash_size == 0) -+ s->pos += 8; -+ -+ while (s->pos < (crc32 ? 32 : s->hash_size * 8)) { - if (b->in_pos == b->in_size) - return XZ_OK; - - #ifndef GRUB_EMBED_DECOMPRESSOR -- if (hash && s->hash_value[s->pos / 8] != b->in[b->in_pos++]) -+ if (hash && s->hash_value[s->pos / 8] != b->in[b->in_pos]) - return XZ_DATA_ERROR; - #endif -+ b->in_pos++; - - s->pos += 8; - -- } while (s->pos < (crc32 ? 32 : s->hash_size * 8)); -+ } - - #ifndef GRUB_EMBED_DECOMPRESSOR - if (s->hash) -@@ -529,8 +536,6 @@ - s->hash->init(s->index.hash.hash_context); - s->hash->init(s->block.hash.hash_context); - } -- if (!s->hash) -- return XZ_OPTIONS_ERROR; - #endif - } - else - -=== modified file 'grub-core/normal/autofs.c' ---- grub-core/normal/autofs.c 2012-05-01 13:26:36 +0000 -+++ grub-core/normal/autofs.c 2012-07-22 14:23:46 +0000 -@@ -32,11 +32,21 @@ - autoload_fs_module (void) - { - grub_named_list_t p; -+ int ret = 0; -+ grub_file_filter_t grub_file_filters_was[GRUB_FILE_FILTER_MAX]; -+ -+ grub_memcpy (grub_file_filters_was, grub_file_filters_enabled, -+ sizeof (grub_file_filters_enabled)); -+ grub_memcpy (grub_file_filters_enabled, grub_file_filters_all, -+ sizeof (grub_file_filters_enabled)); - - while ((p = fs_module_list) != NULL) - { - if (! grub_dl_get (p->name) && grub_dl_load (p->name)) -- return 1; -+ { -+ ret = 1; -+ break; -+ } - - if (grub_errno) - grub_print_error (); -@@ -46,7 +56,10 @@ - grub_free (p); - } - -- return 0; -+ grub_memcpy (grub_file_filters_enabled, grub_file_filters_was, -+ sizeof (grub_file_filters_enabled)); -+ -+ return ret; - } - - /* Read the file fs.lst for auto-loading. */ - diff --git a/sys-boot/grub/files/grub-2.00-config-quoting.patch b/sys-boot/grub/files/grub-2.00-config-quoting.patch deleted file mode 100644 index 3b031c626456..000000000000 --- a/sys-boot/grub/files/grub-2.00-config-quoting.patch +++ /dev/null @@ -1,113 +0,0 @@ -https://bugs.gentoo.org/show_bug.cgi?id=426364 -https://savannah.gnu.org/bugs/index.php?36839 ---- util/grub-mkconfig_lib.in -+++ util/grub-mkconfig_lib.in -@@ -255,19 +255,19 @@ - echo "$version_find_latest_a" - } - --# One layer of quotation is eaten by "", the second by sed, and the third by --# printf; so this turns ' into \'. Note that you must use the output of -+# One layer of quotation is eaten by "" and the second by -+# sed; so this turns ' into \'. Note that you must use the output of - # this function in a printf format string. - - grub_quote () { -- sed "s/'/'\\\\\\\\''/g" -+ sed "s/'/'\\\\''/g" - } - - gettext_quoted () { -- gettext "$@" | sed "s/'/'\\\\\\\\''/g" -+ gettext "$@" | grub_quote - } - --# Run the first argument through gettext_quoted, and then pass that and all -+# Run the first argument through gettext, and then pass that and all - # remaining arguments to printf. This is a useful abbreviation and tends to - # be easier to type. - gettext_printf () { - -=== modified file 'util/grub.d/10_hurd.in' ---- util/grub.d/10_hurd.in -+++ util/grub.d/10_hurd.in -@@ -117,7 +117,7 @@ - opts= - fi - sed "s/^/$submenu_indentation/" << EOF -- echo '$message' -+ echo '$(echo "$message" | grub_quote)' - multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} $opts ${GRUB_CMDLINE_GNUMACH} - EOF - -@@ -133,7 +133,7 @@ - fi - - sed "s/^/$submenu_indentation/" << EOF -- echo '$message' -+ echo '$(echo "$message" | grub_quote)' - module /hurd/${hurd_fs}.static ${hurd_fs} $opts \\ - --multiboot-command-line='\${kernel-command-line}' \\ - --host-priv-port='\${host-port}' \\ ---- util/grub.d/10_illumos.in -+++ util/grub.d/10_illumos.in -@@ -46,6 +46,7 @@ - ISADIR= - fi - zfs-bootfs $($grub_mkrelpath /) ZFS_BOOTFS -+ echo '$(echo "$message" | grub_quote)' - multiboot $($grub_mkrelpath /platform/i86pc/kernel)/\$ISADIR/unix /platform/i86pc/kernel/\$ISADIR/unix -B \$ZFS_BOOTFS,console=text - module $($grub_mkrelpath /platform/i86pc)/\$ISADIR/boot_archive /platform/i86pc/\$ISADIR/boot_archive - } ---- util/grub.d/10_kfreebsd.in -+++ util/grub.d/10_kfreebsd.in -@@ -100,7 +100,7 @@ - printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" - message="$(gettext_printf "Loading kernel of FreeBSD %s ..." ${version})" - sed "s/^/$submenu_indentation/" << EOF -- echo '$message' -+ echo '$(echo "$message" | grub_quote)' - kfreebsd ${rel_dirname}/${basename} ${args} - EOF - ---- util/grub.d/10_linux.in -+++ util/grub.d/10_linux.in -@@ -134,14 +134,14 @@ - fi - message="$(gettext_printf "Loading Linux %s ..." ${version})" - sed "s/^/$submenu_indentation/" << EOF -- echo '$message' -+ echo '$(echo "$message" | grub_quote)' - linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} - EOF - if test -n "${initrd}" ; then - # TRANSLATORS: ramdisk isn't identifier. Should be translated. - message="$(gettext_printf "Loading initial ramdisk ...")" - sed "s/^/$submenu_indentation/" << EOF -- echo '$message' -+ echo '$(echo "$message" | grub_quote)' - initrd ${rel_dirname}/${initrd} - EOF - fi ---- util/grub.d/20_linux_xen.in -+++ util/grub.d/20_linux_xen.in -@@ -120,16 +120,16 @@ - xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})" - lmessage="$(gettext_printf "Loading Linux %s ..." ${version})" - sed "s/^/$submenu_indentation/" << EOF -- echo '$xmessage' -+ echo '$(echo "$xmessage" | grub_quote)' - multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} -- echo '$lmessage' -+ echo '$(echo "$lmessage" | grub_quote)' - module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} - EOF - if test -n "${initrd}" ; then - # TRANSLATORS: ramdisk isn't identifier. Should be translated. - message="$(gettext_printf "Loading initial ramdisk ...")" - sed "s/^/$submenu_indentation/" << EOF -- echo '$message' -+ echo '$(echo "$message" | grub_quote)' - module ${rel_dirname}/${initrd} - EOF - fi diff --git a/sys-boot/grub/files/grub-2.00-dmraid.patch b/sys-boot/grub/files/grub-2.00-dmraid.patch deleted file mode 100644 index c39267ae50a6..000000000000 --- a/sys-boot/grub/files/grub-2.00-dmraid.patch +++ /dev/null @@ -1,28 +0,0 @@ -Fix DMRAID partition handling - -https://bugs.gentoo.org/show_bug.cgi?id=430748 -https://savannah.gnu.org/bugs/?37073 -http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4858 - -=== modified file 'util/getroot.c' ---- util/getroot.c 2013-04-12 20:37:59 +0000 -+++ util/getroot.c 2013-04-15 06:37:13 +0000 -@@ -1956,6 +1956,7 @@ - grub_util_info ("dm_tree_find_node failed"); - goto devmapper_out; - } -+ reiterate: - node_uuid = dm_tree_node_get_uuid (node); - if (! node_uuid) - { -@@ -2030,6 +2031,9 @@ - goto devmapper_out; - } - mapper_name = child_name; -+ *is_part = 1; -+ node = child; -+ goto reiterate; - - devmapper_out: - if (! mapper_name && node) - diff --git a/sys-boot/grub/files/grub-2.00-freebsd.patch b/sys-boot/grub/files/grub-2.00-freebsd.patch deleted file mode 100644 index bcfbf2633ccd..000000000000 --- a/sys-boot/grub/files/grub-2.00-freebsd.patch +++ /dev/null @@ -1,382 +0,0 @@ -Taken from -http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4556 -http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4584 -http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4624 -http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4625 - -diff -Nur grub-2.00.orig/grub-core/loader/i386/bsd.c grub-2.00/grub-core/loader/i386/bsd.c ---- grub-2.00.orig/grub-core/loader/i386/bsd.c 2012-06-07 22:06:00.000000000 +0900 -+++ grub-2.00/grub-core/loader/i386/bsd.c 2013-01-04 19:50:55.000000000 +0900 -@@ -1309,7 +1309,7 @@ - && phdr->p_type != PT_DYNAMIC) - return 0; - -- paddr = phdr->p_paddr & 0xFFFFFF; -+ paddr = phdr->p_paddr & 0xFFFFFFF; - - if (paddr < kern_start) - kern_start = paddr; -@@ -1333,7 +1333,7 @@ - } - - *do_load = 1; -- phdr->p_paddr &= 0xFFFFFF; -+ phdr->p_paddr &= 0xFFFFFFF; - paddr = phdr->p_paddr; - - *addr = (grub_addr_t) (paddr - kern_start + (grub_uint8_t *) kern_chunk_src); -@@ -1351,7 +1351,7 @@ - && phdr->p_type != PT_DYNAMIC) - return 0; - -- paddr = phdr->p_paddr & 0xffffff; -+ paddr = phdr->p_paddr & 0xfffffff; - - if (paddr < kern_start) - kern_start = paddr; -@@ -1375,7 +1375,7 @@ - } - - *do_load = 1; -- paddr = phdr->p_paddr & 0xffffff; -+ paddr = phdr->p_paddr & 0xfffffff; - - *addr = (grub_addr_t) (paddr - kern_start + (grub_uint8_t *) kern_chunk_src); - -@@ -1394,7 +1394,7 @@ - { - grub_relocator_chunk_t ch; - -- entry = elf->ehdr.ehdr32.e_entry & 0xFFFFFF; -+ entry = elf->ehdr.ehdr32.e_entry & 0xFFFFFFF; - err = grub_elf32_phdr_iterate (elf, filename, - grub_bsd_elf32_size_hook, NULL); - if (err) -diff -Nur grub-2.00.orig/util/grub-mkconfig_lib.in grub-2.00/util/grub-mkconfig_lib.in ---- grub-2.00.orig/util/grub-mkconfig_lib.in 2012-06-28 00:27:53.000000000 +0900 -+++ grub-2.00/util/grub-mkconfig_lib.in 2013-01-04 19:50:55.000000000 +0900 -@@ -349,3 +349,10 @@ - cat - fi - } -+ -+grub_tab=" " -+ -+grub_add_tab () { -+ sed -e "s/^/$grub_tab/" -+} -+ -diff -Nur grub-2.00.orig/util/grub.d/10_hurd.in grub-2.00/util/grub.d/10_hurd.in ---- grub-2.00.orig/util/grub.d/10_hurd.in 2012-03-05 05:10:04.000000000 +0900 -+++ grub-2.00/util/grub.d/10_hurd.in 2013-01-04 19:50:55.000000000 +0900 -@@ -108,7 +108,7 @@ - EOF - fi - -- prepare_grub_to_access_device "${GRUB_DEVICE_BOOT}" | sed -e "s/^/\t/"|sed "s/^/$submenu_indentation/" -+ prepare_grub_to_access_device "${GRUB_DEVICE_BOOT}" | grub_add_tab|sed "s/^/$submenu_indentation/" - message="$(gettext_printf "Loading GNU Mach ...")" - - if [ x$type = xrecovery ] ; then -@@ -122,9 +122,9 @@ - EOF - - if [ x$type != xrecovery ] ; then -- save_default_entry | sed -e "s/^/\t/"| sed "s/^/$submenu_indentation/" -+ save_default_entry | grub_add_tab| sed "s/^/$submenu_indentation/" - fi -- prepare_grub_to_access_device "${GRUB_DEVICE}" | sed -e "s/^/\t/"| sed "s/^/$submenu_indentation/" -+ prepare_grub_to_access_device "${GRUB_DEVICE}" | grub_add_tab| sed "s/^/$submenu_indentation/" - message="$(gettext_printf "Loading the Hurd ...")" - if [ x$type = xrecovery ] ; then - opts= -@@ -158,7 +158,7 @@ - - if [ "x$is_first_entry" = xtrue ]; then - hurd_entry "$kernel" simple -- submenu_indentation="\t" -+ submenu_indentation="$grub_tab" - - # TRANSLATORS: %s is replaced with an OS name - echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnuhurd-advanced-$(grub_get_device_id "${GRUB_DEVICE_BOOT}")' {" -diff -Nur grub-2.00.orig/util/grub.d/10_illumos.in grub-2.00/util/grub.d/10_illumos.in ---- grub-2.00.orig/util/grub.d/10_illumos.in 2012-03-05 04:03:38.000000000 +0900 -+++ grub-2.00/util/grub.d/10_illumos.in 2013-01-04 19:50:55.000000000 +0900 -@@ -35,8 +35,8 @@ - esac - - echo "menuentry '$(echo "$OS" | grub_quote)' ${CLASS} \$menuentry_id_option 'illumos-$(grub_get_device_id "${GRUB_DEVICE_BOOT}")' {" --save_default_entry | sed -e "s/^/\t/" --prepare_grub_to_access_device "${GRUB_DEVICE_BOOT}" | sed -e "s/^/\t/" -+save_default_entry | grub_add_tab -+prepare_grub_to_access_device "${GRUB_DEVICE_BOOT}" | grub_add_tab - message="$(gettext_printf "Loading kernel of Illumos ...")" - cat << EOF - insmod gzio -diff -Nur grub-2.00.orig/util/grub.d/10_kfreebsd.in grub-2.00/util/grub.d/10_kfreebsd.in ---- grub-2.00.orig/util/grub.d/10_kfreebsd.in 2012-03-05 06:02:30.000000000 +0900 -+++ grub-2.00/util/grub.d/10_kfreebsd.in 2013-01-04 19:50:55.000000000 +0900 -@@ -54,7 +54,7 @@ - fi - - if [ -z "${prepare_module_dir_cache}" ]; then -- prepare_module_dir_cache="$(prepare_grub_to_access_device $(grub-probe -t device "${module_dir}") | sed -e "s/^/\t/")" -+ prepare_module_dir_cache="$(prepare_grub_to_access_device $(${grub_probe} -t device "${module_dir}") | grub_add_tab)" - fi - - printf '%s\n' "${prepare_module_dir_cache}" -@@ -91,10 +91,10 @@ - echo "menuentry '$(echo "$OS" | grub_quote)' ${CLASS} \$menuentry_id_option 'kfreebsd-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" - fi - if [ x$type != xrecovery ] ; then -- save_default_entry | sed -e "s/^/\t/" | sed "s/^/$submenu_indentation/" -+ save_default_entry | grub_add_tab | sed "s/^/$submenu_indentation/" - fi - if [ -z "${prepare_boot_cache}" ]; then -- prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" -+ prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)" - fi - - printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" -@@ -112,7 +112,7 @@ - - load_kfreebsd_module acpi true - -- for abstraction in dummy $(grub-probe -t abstraction --device ${GRUB_DEVICE}) ; do -+ for abstraction in dummy $(${grub_probe} -t abstraction --device ${GRUB_DEVICE}) ; do - case $abstraction in - lvm) load_kfreebsd_module geom_linux_lvm false ;; - esac -@@ -122,10 +122,10 @@ - zfs) - load_kfreebsd_module opensolaris false - -- ls "${dirname}/zfs/zpool.cache" > /dev/null -+ ls "/boot/zfs/zpool.cache" > /dev/null - printf '%s\n' "${prepare_boot_cache}" - sed "s/^/$submenu_indentation/" << EOF -- kfreebsd_module ${rel_dirname}/zfs/zpool.cache type=/boot/zfs/zpool.cache -+ kfreebsd_module $(make_system_path_relative_to_its_root /boot)/zfs/zpool.cache type=/boot/zfs/zpool.cache - EOF - ;; - esac -@@ -179,7 +179,7 @@ - case ${GRUB_FS} in - zfs) - # zpool name -- kfreebsd_device=$(grub-probe -t fs_label --device ${GRUB_DEVICE}) -+ kfreebsd_device=$(${grub_probe} -t fs_label --device ${GRUB_DEVICE}) - # filesystem name (empty string for the main filesystem) - kfreebsd_device="${kfreebsd_device}$(${grub_mkrelpath} / | sed -e "s,/*@$,,")" - ;; -@@ -213,7 +213,7 @@ - - if [ "x$is_first_entry" = xtrue ]; then - kfreebsd_entry "${OS}" "${version}" simple -- submenu_indentation="\t" -+ submenu_indentation="$grub_tab" - - if [ -z "$boot_device_id" ]; then - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" -diff -Nur grub-2.00.orig/util/grub.d/10_linux.in grub-2.00/util/grub.d/10_linux.in ---- grub-2.00.orig/util/grub.d/10_linux.in 2012-04-19 06:24:38.000000000 +0900 -+++ grub-2.00/util/grub.d/10_linux.in 2013-01-04 19:50:55.000000000 +0900 -@@ -101,7 +101,7 @@ - echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" - fi - if [ x$type != xrecovery ] ; then -- save_default_entry | sed -e "s/^/\t/" -+ save_default_entry | grub_add_tab - fi - - # Use ELILO's generic "efifb" when it's known to be available. -@@ -123,12 +123,12 @@ - - if [ x$dirname = x/ ]; then - if [ -z "${prepare_root_cache}" ]; then -- prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/")" -+ prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)" - fi - printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/" - else - if [ -z "${prepare_boot_cache}" ]; then -- prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" -+ prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)" - fi - printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" - fi -@@ -230,7 +230,7 @@ - linux_entry "${OS}" "${version}" simple \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - -- submenu_indentation="\t" -+ submenu_indentation="$grub_tab" - - if [ -z "$boot_device_id" ]; then - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" -diff -Nur grub-2.00.orig/util/grub.d/10_netbsd.in grub-2.00/util/grub.d/10_netbsd.in ---- grub-2.00.orig/util/grub.d/10_netbsd.in 2012-03-05 04:47:35.000000000 +0900 -+++ grub-2.00/util/grub.d/10_netbsd.in 2013-01-04 19:50:55.000000000 +0900 -@@ -77,10 +77,10 @@ - prepare_grub_to_access_device $(${grub_probe} -t device "${kmodule}") | sed -e 's,^, ,' - case "${loader}" in - knetbsd) -- printf "\tknetbsd_module_elf %s\n" "${kmodule_rel}" -+ printf "$grub_tabknetbsd_module_elf %s\n" "${kmodule_rel}" - ;; - multiboot) -- printf "\tmodule %s\n" "${kmodule_rel}" -+ printf "$grub_tabmodule %s\n" "${kmodule_rel}" - ;; - esac - } -@@ -121,11 +121,11 @@ - printf "%s\n" "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" - case "${loader}" in - knetbsd) -- printf "\tknetbsd %s -r %s %s\n" \ -+ printf "$grub_tabknetbsd %s -r %s %s\n" \ - "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}" | sed "s/^/$submenu_indentation/" - ;; - multiboot) -- printf "\tmultiboot %s %s root=%s %s\n" \ -+ printf "$grub_tabmultiboot %s %s root=%s %s\n" \ - "${kernel}" "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}" | sed "s/^/$submenu_indentation/" - ;; - esac -@@ -159,7 +159,7 @@ - - if [ "x$is_first_entry" = xtrue ]; then - netbsd_entry "knetbsd" "$k" simple "${GRUB_CMDLINE_NETBSD_DEFAULT}" -- submenu_indentation="\t" -+ submenu_indentation="$grub_tab" - - if [ -z "$boot_device_id" ]; then - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" -diff -Nur grub-2.00.orig/util/grub.d/10_windows.in grub-2.00/util/grub.d/10_windows.in ---- grub-2.00.orig/util/grub.d/10_windows.in 2012-03-05 06:11:43.000000000 +0900 -+++ grub-2.00/util/grub.d/10_windows.in 2013-01-04 19:50:55.000000000 +0900 -@@ -45,7 +45,7 @@ - sort | uniq | wc -l`" = 1 || return 1 - - # Search 'default=PARTITION' -- get_os_name_from_boot_ini_part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ \t\r]*$,,;1q'` -+ get_os_name_from_boot_ini_part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ $grub_tab\r]*$,,;1q'` - test -n "$get_os_name_from_boot_ini_part" || return 1 - - # Search 'PARTITION="NAME" ...' -@@ -87,8 +87,8 @@ - menuentry '$(echo "$OS" | grub_quote)' \$menuentry_id_option '$osid-$(grub_get_device_id "${dev}")' { - EOF - -- save_default_entry | sed -e 's,^,\t,' -- prepare_grub_to_access_device "$dev" | sed 's,^,\t,' -+ save_default_entry | sed -e 's,^,$grub_tab,' -+ prepare_grub_to_access_device "$dev" | sed 's,^,$grub_tab,' - test -z "$needmap" || cat <<EOF - drivemap -s (hd0) \$root - EOF -diff -Nur grub-2.00.orig/util/grub.d/10_xnu.in grub-2.00/util/grub.d/10_xnu.in ---- grub-2.00.orig/util/grub.d/10_xnu.in 2012-05-29 19:31:03.000000000 +0900 -+++ grub-2.00/util/grub.d/10_xnu.in 2013-01-04 19:50:55.000000000 +0900 -@@ -39,8 +39,8 @@ - cat << EOF - menuentry '$(echo "Darwin/Mac OS X $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${GRUB_DEVICE}")' { - EOF -- save_default_entry | sed -e "s/^/ /" -- prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/ /" -+ save_default_entry | grub_add_tab -+ prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab - cat << EOF - load_video - set do_resume=0 -diff -Nur grub-2.00.orig/util/grub.d/20_linux_xen.in grub-2.00/util/grub.d/20_linux_xen.in ---- grub-2.00.orig/util/grub.d/20_linux_xen.in 2012-06-04 04:57:42.000000000 +0900 -+++ grub-2.00/util/grub.d/20_linux_xen.in 2013-01-04 19:50:55.000000000 +0900 -@@ -110,11 +110,11 @@ - echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'xen-gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" - fi - if [ x$type != xrecovery ] ; then -- save_default_entry | sed -e "s/^/\t/" | sed "s/^/$submenu_indentation/" -+ save_default_entry | grub_add_tab | sed "s/^/$submenu_indentation/" - fi - - if [ -z "${prepare_boot_cache}" ]; then -- prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" -+ prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)" - fi - printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" - xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})" -@@ -236,7 +236,7 @@ - linux_entry "${OS}" "${version}" "${xen_version}" simple \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}" - -- submenu_indentation="\t\t" -+ submenu_indentation="$grub_tab$grub_tab" - - if [ -z "$boot_device_id" ]; then - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" -diff -Nur grub-2.00.orig/util/grub.d/30_os-prober.in grub-2.00/util/grub.d/30_os-prober.in ---- grub-2.00.orig/util/grub.d/30_os-prober.in 2012-03-05 05:52:03.000000000 +0900 -+++ grub-2.00/util/grub.d/30_os-prober.in 2013-01-04 19:50:55.000000000 +0900 -@@ -54,8 +54,8 @@ - cat << EOF - menuentry '$(echo "${LONGNAME} $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")' { - EOF -- save_default_entry | sed -e "s/^/\t/" -- prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" -+ save_default_entry | grub_add_tab -+ prepare_grub_to_access_device ${DEVICE} | grub_add_tab - cat << EOF - load_video - set do_resume=0 -@@ -126,8 +126,8 @@ - cat << EOF - menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' { - EOF -- save_default_entry | sed -e "s/^/\t/" -- prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" -+ save_default_entry | grub_add_tab -+ prepare_grub_to_access_device ${DEVICE} | grub_add_tab - - case ${LONGNAME} in - Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*) -@@ -181,14 +181,14 @@ - used_osprober_linux_ids="$used_osprober_linux_ids 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id'" - - if [ -z "${prepare_boot_cache}" ]; then -- prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")" -+ prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | grub_add_tab)" - fi - - if [ "x$is_first_entry" = xtrue ]; then - cat << EOF - menuentry '$(echo "$OS" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' { - EOF -- save_default_entry | sed -e "s/^/\t/" -+ save_default_entry | grub_add_tab - printf '%s\n' "${prepare_boot_cache}" - cat << EOF - linux ${LKERNEL} ${LPARAMS} -@@ -208,8 +208,8 @@ - cat << EOF - menuentry '$(echo "$title" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-$LKERNEL-${recovery_params}-$boot_device_id' { - EOF -- save_default_entry | sed -e "s/^/\t\t/" -- printf '%s\n' "${prepare_boot_cache}" | sed -e "s/^/\t/" -+ save_default_entry | sed -e "s/^/$grub_tab$grub_tab/" -+ printf '%s\n' "${prepare_boot_cache}" | grub_add_tab - cat << EOF - linux ${LKERNEL} ${LPARAMS} - EOF -@@ -243,8 +243,8 @@ - cat << EOF - menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' { - EOF -- save_default_entry | sed -e "s/^/\t/" -- prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" -+ save_default_entry | grub_add_tab -+ prepare_grub_to_access_device ${DEVICE} | grub_add_tab - grub_device="`${grub_probe} --device ${DEVICE} --target=drive`" - mach_device="`echo "${grub_device}" | sed -e 's/(\(hd.*\),msdos\(.*\))/\1s\2/'`" - grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`" diff --git a/sys-boot/grub/files/grub-2.00-hardcoded-awk.patch b/sys-boot/grub/files/grub-2.00-hardcoded-awk.patch deleted file mode 100644 index 8019a3c74c15..000000000000 --- a/sys-boot/grub/files/grub-2.00-hardcoded-awk.patch +++ /dev/null @@ -1,15 +0,0 @@ -https://bugs.gentoo.org/show_bug.cgi?id=424137 -https://savannah.gnu.org/bugs/?37558 -https://code.google.com/p/original-mawk/issues/detail?id=17 ---- grub-core/Makefile.am 2012-07-07 12:29:01 +0000 -+++ grub-core/Makefile.am 2012-10-12 13:04:02 +0000 -@@ -349,7 +349,7 @@ - - # generate global module dependencies list - moddep.lst: syminfo.lst genmoddep.awk video.lst -- cat $< | sort | awk -f $(srcdir)/genmoddep.awk > $@ || (rm -f $@; exit 1) -+ cat $< | sort | $(AWK) -f $(srcdir)/genmoddep.awk > $@ || (rm -f $@; exit 1) - platform_DATA += moddep.lst - CLEANFILES += config.log syminfo.lst moddep.lst - - diff --git a/sys-boot/grub/files/grub-2.00-no-gets.patch b/sys-boot/grub/files/grub-2.00-no-gets.patch deleted file mode 100644 index c21d4b976e2c..000000000000 --- a/sys-boot/grub/files/grub-2.00-no-gets.patch +++ /dev/null @@ -1,22 +0,0 @@ -hack until gzip pulls a newer gnulib version - -From 66712c23388e93e5c518ebc8515140fa0c807348 Mon Sep 17 00:00:00 2001 -From: Eric Blake <eblake@redhat.com> -Date: Thu, 29 Mar 2012 13:30:41 -0600 -Subject: [PATCH] stdio: don't assume gets any more - -Gnulib intentionally does not have a gets module, and now that C11 -and glibc have dropped it, we should be more proactive about warning -any user on a platform that still has a declaration of this dangerous -interface. - ---- a/grub-core/gnulib/stdio.in.h -+++ b/grub-core/gnulib/stdio.in.h -@@ -125,7 +125,6 @@ - so any use of gets warrants an unconditional warning. Assume it is - always declared, since it is required by C89. */ - #undef gets --_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); - - #if @GNULIB_FOPEN@ - # if @REPLACE_FOPEN@ diff --git a/sys-boot/grub/files/grub-2.00-os-prober-efi-system.patch b/sys-boot/grub/files/grub-2.00-os-prober-efi-system.patch deleted file mode 100644 index 7e0888a86daa..000000000000 --- a/sys-boot/grub/files/grub-2.00-os-prober-efi-system.patch +++ /dev/null @@ -1,27 +0,0 @@ -=== modified file 'util/grub.d/30_os-prober.in' ---- util/grub.d/30_os-prober.in 2013-04-19 08:08:46 +0000 -+++ util/grub.d/30_os-prober.in 2013-05-31 16:29:03 +0000 -@@ -149,6 +149,22 @@ - } - EOF - ;; -+ efi) -+ -+ EFIPATH=${DEVICE#*@} -+ DEVICE=${DEVICE%@*} -+ onstr="$(gettext_printf "(on %s)" "${DEVICE}")" -+ cat << EOF -+menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' { -+EOF -+ save_default_entry | sed -e "s/^/\t/" -+ prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" -+ -+ cat <<EOF -+ chainloader ${EFIPATH} -+} -+EOF -+ ;; - linux) - if [ "x$BTRFS" = "xbtrfs" ]; then - LINUXPROBED="`linux-boot-prober btrfs ${BTRFSuuid} ${BTRFSsubvol} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`" - diff --git a/sys-boot/grub/files/grub-2.00-parallel-make.patch b/sys-boot/grub/files/grub-2.00-parallel-make.patch deleted file mode 100644 index 03d634bb6406..000000000000 --- a/sys-boot/grub/files/grub-2.00-parallel-make.patch +++ /dev/null @@ -1,46 +0,0 @@ -Fix parallel make problems. -Upstream changesets 4547, 4552, 4578. ---- gentpl.py -+++ gentpl.py -@@ -484,10 +484,10 @@ - def installdir(default="bin"): - return "[+ IF installdir +][+ installdir +][+ ELSE +]" + default + "[+ ENDIF +]" - --def manpage(): -+def manpage(adddeps): - r = "if COND_MAN_PAGES\n" - r += gvar_add("man_MANS", "[+ name +].[+ mansection +]\n") -- r += rule("[+ name +].[+ mansection +]", "[+ name +]", """ -+ r += rule("[+ name +].[+ mansection +]", "[+ name +] " + adddeps, """ - chmod a+x [+ name +] - PATH=$(builddir):$$PATH pkgdatadir=$(builddir) $(HELP2MAN) --section=[+ mansection +] -i $(top_srcdir)/docs/man/[+ name +].h2m -o $@ [+ name +] - """) -@@ -503,7 +503,7 @@ - r += gvar_add("TESTS", "[+ name +]") - r += "[+ ELSE +]" - r += var_add(installdir() + "_PROGRAMS", "[+ name +]") -- r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]" -+ r += "[+ IF mansection +]" + manpage("") + "[+ ENDIF +]" - r += "[+ ENDIF +]" - - r += var_set(cname() + "_SOURCES", platform_sources(platform)) -@@ -532,7 +532,7 @@ - r += gvar_add ("TESTS", "[+ name +]") - r += "[+ ELSE +]" - r += var_add(installdir() + "_SCRIPTS", "[+ name +]") -- r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]" -+ r += "[+ IF mansection +]" + manpage("grub-mkconfig_lib") + "[+ ENDIF +]" - r += "[+ ENDIF +]" - - r += rule("[+ name +]", platform_sources(platform) + " $(top_builddir)/config.status", """ ---- grub-core/Makefile.am -+++ grub-core/Makefile.am -@@ -63,7 +63,7 @@ - rs_decoder.S: $(srcdir)/lib/reed_solomon.c - $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Os -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3 -ffreestanding - --kern/i386/pc/startup.S: $(builddir)/rs_decoder.S -+boot/i386/pc/startup_raw.S: $(builddir)/rs_decoder.S - boot/mips/loongson/fwstart.S: $(builddir)/sm712_start.S - - CLEANFILES += grub_script.yy.c grub_script.yy.h diff --git a/sys-boot/grub/files/grub-2.00-texinfo.patch b/sys-boot/grub/files/grub-2.00-texinfo.patch deleted file mode 100644 index 803f3cbc0bc7..000000000000 --- a/sys-boot/grub/files/grub-2.00-texinfo.patch +++ /dev/null @@ -1,16 +0,0 @@ -Fix for texinfo-5.1 - -=== modified file 'docs/grub-dev.texi' ---- docs/grub-dev.texi 2012-05-22 07:15:28 +0000 -+++ docs/grub-dev.texi 2013-04-08 13:23:07 +0000 -@@ -1394,8 +1394,8 @@ - - @node Bitmap API - @section Bitmap API --@itemize - @subsection grub_video_bitmap_create -+@itemize - @item Prototype: - @example - grub_err_t grub_video_bitmap_create (struct grub_video_bitmap **bitmap, unsigned int width, unsigned int height, enum grub_video_blit_format blit_format) - diff --git a/sys-boot/grub/files/grub-2.00-tftp-endian.patch b/sys-boot/grub/files/grub-2.00-tftp-endian.patch deleted file mode 100644 index f4e56445dd59..000000000000 --- a/sys-boot/grub/files/grub-2.00-tftp-endian.patch +++ /dev/null @@ -1,24 +0,0 @@ -https://bugs.gentoo.org/show_bug.cgi?id=438612 - -=== modified file 'grub-core/net/tftp.c' ---- grub-core/net/tftp.c 2012-06-22 20:04:16 +0000 -+++ grub-core/net/tftp.c 2012-07-02 09:22:50 +0000 -@@ -143,7 +143,7 @@ - - tftph_ack = (struct tftphdr *) nb_ack.data; - tftph_ack->opcode = grub_cpu_to_be16 (TFTP_ACK); -- tftph_ack->u.ack.block = block; -+ tftph_ack->u.ack.block = grub_cpu_to_be16 (block); - - err = grub_net_send_udp_packet (data->sock, &nb_ack); - if (err) -@@ -225,7 +225,7 @@ - grub_priority_queue_pop (data->pq); - - if (file->device->net->packs.count < 50) -- err = ack (data, tftph->u.data.block); -+ err = ack (data, data->block + 1); - else - { - file->device->net->stall = 1; - diff --git a/sys-boot/grub/files/grub-2.00-zfs-feature-flag-support-r1.patch b/sys-boot/grub/files/grub-2.00-zfs-feature-flag-support-r1.patch deleted file mode 100644 index b7d780f21d2e..000000000000 --- a/sys-boot/grub/files/grub-2.00-zfs-feature-flag-support-r1.patch +++ /dev/null @@ -1,893 +0,0 @@ -ZFS Feature Flag Support - -This is a monolithic version of the following commits: - -https://github.com/maxximino/grub2/commit/31a32560fd7948ae5ff5c63105d7c068de7890c8 -https://github.com/maxximino/grub2/commit/595d76e8ca0690a963f5533689de8db54ef07e75 -https://github.com/maxximino/grub2/commit/58344034e40218b20500fa2936eb4d7d019e1e88 -https://github.com/maxximino/grub2/commit/f98cb078abab2c14bb0766b5a0ceb055683dab81 -https://github.com/maxximino/grub2/commit/f12806f43a969a654dee7bb89b2e8fd5c42f0e2e - -A change was made to account for d8a0feb6 from upstream. This change prevents a -compile time failure that is caused by a change in the callback interface used -by mzap_interate(). Modifications to nvlist_find_value() were reverted to -resolve Gentoo bug #462740. This eliminated the need for the new nvpair_type() -and nvpair_value() functions. They have been removed to silence a compiler -warning and reduce the size of the patch. Further adjustments were made to -silence the following warnings: - -/var/tmp/portage/sys-boot/grub-2.00-r2/work/grub-2.00/grub-core/fs/zfs/zfs_lz4.c:77:5: -warning: "__STDC_VERSION__" is not defined [-Wundef] -/var/tmp/portage/sys-boot/grub-2.00-r2/work/grub-2.00/grub-core/fs/zfs/zfs.c:4079:3: -warning: passing argument 4 of 'mzap_iterate' from incompatible pointer type -[enabled by default] - -The initial feature flag support patches were written by Delphix while the LZ4 -support was written by Saso Kiselkov. The work porting this to GRUB2 was done -by Massimo Maggi, while the adaption to Gentoo's GRUB2 package was done by -Richard Yao. - -diff --git a/Makefile.util.def b/Makefile.util.def -index b80187c..1bf3038 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -95,6 +95,7 @@ library = { - common = grub-core/fs/zfs/zfs.c; - common = grub-core/fs/zfs/zfsinfo.c; - common = grub-core/fs/zfs/zfs_lzjb.c; -+ common = grub-core/fs/zfs/zfs_lz4.c; - common = grub-core/fs/zfs/zfs_sha256.c; - common = grub-core/fs/zfs/zfs_fletcher.c; - common = grub-core/lib/envblk.c; -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 39e77a4..1550b90 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1186,6 +1186,7 @@ module = { - name = zfs; - common = fs/zfs/zfs.c; - common = fs/zfs/zfs_lzjb.c; -+ common = fs/zfs/zfs_lz4.c; - common = fs/zfs/zfs_sha256.c; - common = fs/zfs/zfs_fletcher.c; - }; -diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c -index ba0554a..811e3df 100644 ---- a/grub-core/fs/zfs/zfs.c -+++ b/grub-core/fs/zfs/zfs.c -@@ -2,6 +2,7 @@ - * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2009,2010,2011 Free Software Foundation, Inc. - * Copyright 2010 Sun Microsystems, Inc. -+ * Copyright (c) 2012 by Delphix. All rights reserved. - * - * GRUB is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by -@@ -153,11 +154,13 @@ ZAP_LEAF_ENTRY(zap_leaf_phys_t *l, int bs, int idx) - - - /* -- * Decompression Entry - lzjb -+ * Decompression Entry - lzjb & lz4 - */ - - extern grub_err_t lzjb_decompress (void *, void *, grub_size_t, grub_size_t); - -+extern grub_err_t lz4_decompress (void *, void *, grub_size_t, grub_size_t); -+ - typedef grub_err_t zfs_decomp_func_t (void *s_start, void *d_start, - grub_size_t s_len, grub_size_t d_len); - typedef struct decomp_entry -@@ -263,6 +266,19 @@ grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key - grub_size_t keysize, - grub_uint64_t salt, - grub_uint64_t algo) = NULL; -+/* -+ * List of pool features that the grub implementation of ZFS supports for -+ * read. Note that features that are only required for write do not need -+ * to be listed here since grub opens pools in read-only mode. -+ */ -+static const char *spa_feature_names[] = { -+ "org.illumos:lz4_compress",NULL -+}; -+ -+static int NESTED_FUNC_ATTR -+check_feature(const char *name, grub_uint64_t val); -+static int -+check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ); - - static grub_err_t - zlib_decompress (void *s, void *d, -@@ -322,6 +338,7 @@ static decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = { - {"gzip-8", zlib_decompress}, /* ZIO_COMPRESS_GZIP8 */ - {"gzip-9", zlib_decompress}, /* ZIO_COMPRESS_GZIP9 */ - {"zle", zle_decompress}, /* ZIO_COMPRESS_ZLE */ -+ {"lz4", lz4_decompress}, /* ZIO_COMPRESS_LZ4 */ - }; - - static grub_err_t zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, -@@ -482,15 +499,11 @@ uberblock_verify (uberblock_phys_t * ub, grub_uint64_t offset, - - if (grub_zfs_to_cpu64 (uber->ub_magic, GRUB_ZFS_LITTLE_ENDIAN) - == UBERBLOCK_MAGIC -- && grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_LITTLE_ENDIAN) > 0 -- && grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_LITTLE_ENDIAN) -- <= SPA_VERSION) -- endian = GRUB_ZFS_LITTLE_ENDIAN; -+ && SPA_VERSION_IS_SUPPORTED(grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_LITTLE_ENDIAN))) -+ endian = GRUB_ZFS_LITTLE_ENDIAN; - - if (grub_zfs_to_cpu64 (uber->ub_magic, GRUB_ZFS_BIG_ENDIAN) == UBERBLOCK_MAGIC -- && grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_BIG_ENDIAN) > 0 -- && grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_BIG_ENDIAN) -- <= SPA_VERSION) -+ && SPA_VERSION_IS_SUPPORTED(grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_BIG_ENDIAN))) - endian = GRUB_ZFS_BIG_ENDIAN; - - if (endian == GRUB_ZFS_UNKNOWN_ENDIAN) -@@ -764,6 +777,99 @@ fill_vdev_info (struct grub_zfs_data *data, - } - - /* -+ * For a given XDR packed nvlist, verify the first 4 bytes and move on. -+ * -+ * An XDR packed nvlist is encoded as (comments from nvs_xdr_create) : -+ * -+ * encoding method/host endian (4 bytes) -+ * nvl_version (4 bytes) -+ * nvl_nvflag (4 bytes) -+ * encoded nvpairs: -+ * encoded size of the nvpair (4 bytes) -+ * decoded size of the nvpair (4 bytes) -+ * name string size (4 bytes) -+ * name string data (sizeof(NV_ALIGN4(string)) -+ * data type (4 bytes) -+ * # of elements in the nvpair (4 bytes) -+ * data -+ * 2 zero's for the last nvpair -+ * (end of the entire list) (8 bytes) -+ * -+ */ -+ -+/* -+ * The nvlist_next_nvpair() function returns a handle to the next nvpair in the -+ * list following nvpair. If nvpair is NULL, the first pair is returned. If -+ * nvpair is the last pair in the nvlist, NULL is returned. -+ */ -+static const char * -+nvlist_next_nvpair(const char *nvl, const char *nvpair) -+{ -+ const char *nvp; -+ int encode_size; -+ int name_len; -+ if (nvl == NULL) -+ return (NULL); -+ -+ if (nvpair == NULL) { -+ /* skip over header, nvl_version and nvl_nvflag */ -+ nvpair = nvl + 4 * 3; -+ } else { -+ /* skip to the next nvpair */ -+ encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvpair)); -+ nvpair += encode_size; -+ } -+ /* 8 bytes of 0 marks the end of the list */ -+ if (*(grub_uint64_t*)nvpair == 0) -+ return (NULL); -+ /*consistency checks*/ -+ if (nvpair + 4 * 3 >= nvl + VDEV_PHYS_SIZE) -+ { -+ grub_dprintf ("zfs", "nvlist overflow\n"); -+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); -+ return (NULL); -+ } -+ encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvpair)); -+ -+ nvp = nvpair + 4*2; -+ name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); -+ nvp += 4; -+ -+ nvp = nvp + ((name_len + 3) & ~3); // align -+ if (nvp + 4 >= nvl + VDEV_PHYS_SIZE -+ || encode_size < 0 -+ || nvp + 4 + encode_size > nvl + VDEV_PHYS_SIZE) -+ { -+ grub_dprintf ("zfs", "nvlist overflow\n"); -+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); -+ return (NULL); -+ } -+ /* end consistency checks */ -+ -+ return (nvpair); -+} -+/* -+ * This function returns 0 on success and 1 on failure. On success, a string -+ * containing the name of nvpair is saved in buf. -+ */ -+static int -+nvpair_name(const char *nvp, char **buf, int* buflen) -+{ -+ int len; -+ -+ /* skip over encode/decode size */ -+ nvp += 4 * 2; -+ -+ len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); -+ nvp=nvp+4; -+ -+ *buf=(char*)nvp; -+ *buflen=len; -+ -+ return (0); -+} -+ -+/* - * Check the disk label information and retrieve needed vdev name-value pairs. - * - */ -@@ -773,7 +879,7 @@ check_pool_label (struct grub_zfs_data *data, - int *inserted) - { - grub_uint64_t pool_state, txg = 0; -- char *nvlist; -+ char *nvlist,*features; - #if 0 - char *nv; - #endif -@@ -837,13 +943,13 @@ check_pool_label (struct grub_zfs_data *data, - } - grub_dprintf ("zfs", "check 8 passed\n"); - -- if (version > SPA_VERSION) -+ if (!SPA_VERSION_IS_SUPPORTED(version)) - { - grub_free (nvlist); - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "too new version %llu > %llu", - (unsigned long long) version, -- (unsigned long long) SPA_VERSION); -+ (unsigned long long) SPA_VERSION_BEFORE_FEATURES); - } - grub_dprintf ("zfs", "check 9 passed\n"); - -@@ -893,7 +999,30 @@ check_pool_label (struct grub_zfs_data *data, - grub_free (nv); - } - grub_dprintf ("zfs", "check 10 passed\n"); -- -+ if ((features=grub_zfs_nvlist_lookup_nvlist(nvlist, ZPOOL_CONFIG_FEATURES_FOR_READ))) -+ { -+ const char *nvp=NULL; -+ char *name = grub_zalloc(51); -+ char *nameptr; -+ int namelen; -+ while ((nvp = nvlist_next_nvpair(features, nvp)) != NULL) -+ { -+ nvpair_name(nvp, &nameptr,&namelen); -+ if(namelen > 50){namelen=50;} -+ grub_strncpy(name,nameptr,namelen); -+ name[namelen]=0; -+ grub_dprintf("zfs","namelen=%u str=%s\n",namelen,name); -+ if (check_feature(name,1) != 0) -+ { -+ grub_dprintf("zfs","feature missing in check_pool_label:%s\n",name); -+ err= grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET," check_pool_label missing feature '%s' for read",name); -+ grub_free(name); -+ return err; -+ } -+ } -+ grub_free(name); -+ } -+ grub_dprintf ("zfs", "check 12 passed (feature flags)\n"); - grub_free (nvlist); - - return GRUB_ERR_NONE; -@@ -3034,27 +3163,6 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, - return err; - } - --/* -- * For a given XDR packed nvlist, verify the first 4 bytes and move on. -- * -- * An XDR packed nvlist is encoded as (comments from nvs_xdr_create) : -- * -- * encoding method/host endian (4 bytes) -- * nvl_version (4 bytes) -- * nvl_nvflag (4 bytes) -- * encoded nvpairs: -- * encoded size of the nvpair (4 bytes) -- * decoded size of the nvpair (4 bytes) -- * name string size (4 bytes) -- * name string data (sizeof(NV_ALIGN4(string)) -- * data type (4 bytes) -- * # of elements in the nvpair (4 bytes) -- * data -- * 2 zero's for the last nvpair -- * (end of the entire list) (8 bytes) -- * -- */ -- - static int - nvlist_find_value (const char *nvlist_in, const char *name, - int valtype, char **val, -@@ -3386,6 +3494,10 @@ zfs_mount (grub_device_t dev) - return NULL; - } - -+ if (ub->ub_version >= SPA_VERSION_FEATURES && -+ check_mos_features(&((objset_phys_t *) osp)->os_meta_dnode,ub_endian, data) != 0) -+ return NULL; -+ - /* Got the MOS. Save it at the memory addr MOS. */ - grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode, - DNODE_SIZE); -@@ -3910,6 +4022,64 @@ grub_zfs_dir (grub_device_t device, const char *path, - return grub_errno; - } - -+static int NESTED_FUNC_ATTR -+check_feature(const char *name, grub_uint64_t val) -+{ -+ int i; -+ if(val ==0) return 0; -+ if(*name==0) return 0; -+ for (i = 0; spa_feature_names[i] != NULL; i++) -+ { -+ if (grub_strcmp(name, spa_feature_names[i]) == 0) -+ return 0; -+ } -+ grub_printf("missing feature for read '%s'\n",name); -+ return 1; -+} -+ -+/* -+ * Checks whether the MOS features that are active are supported by this -+ * (GRUB's) implementation of ZFS. -+ * -+ * Return: -+ * 0: Success. -+ * errnum: Failure. -+ */ -+ -+static int -+check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ) -+{ -+ grub_uint64_t objnum; -+ grub_uint8_t errnum = 0; -+ dnode_end_t dn,mosmdn; -+ mzap_phys_t* mzp; -+ grub_zfs_endian_t endianzap; -+ int size; -+ grub_memmove(&(mosmdn.dn),mosmdn_phys,sizeof(dnode_phys_t)); -+ mosmdn.endian=endian; -+ if ((errnum = dnode_get(&mosmdn, DMU_POOL_DIRECTORY_OBJECT, -+ DMU_OT_OBJECT_DIRECTORY, &dn,data)) != 0) -+ return (errnum); -+ -+ /* -+ * Find the object number for 'features_for_read' and retrieve its -+ * corresponding dnode. Note that we don't check features_for_write -+ * because GRUB is not opening the pool for write. -+ */ -+ if ((errnum = zap_lookup(&dn, DMU_POOL_FEATURES_FOR_READ, &objnum, data,0)) != 0) -+ return (errnum); -+ -+ if ((errnum = dnode_get(&mosmdn, objnum, DMU_OTN_ZAP_METADATA, &dn, data)) != 0) -+ return (errnum); -+ -+ if ((errnum = dmu_read(&dn, 0, (void**)&mzp, &endianzap,data)) != 0) -+ return (errnum); -+ -+ size = grub_zfs_to_cpu16 (dn.dn.dn_datablkszsec, dn.endian) << SPA_MINBLOCKSHIFT; -+ return (mzap_iterate(mzp,endianzap, size, check_feature)); -+} -+ -+ - #ifdef GRUB_UTIL - static grub_err_t - grub_zfs_embed (grub_device_t device __attribute__ ((unused)), -diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c -new file mode 100644 -index 0000000..ff85a77 ---- /dev/null -+++ b/grub-core/fs/zfs/zfs_lz4.c -@@ -0,0 +1,321 @@ -+/* -+ * 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> -+ -+static int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, -+ int isize, int maxOutputSize); -+ -+/* -+ * CPU Feature Detection -+ */ -+ -+/* 32 or 64 bits ? */ -+#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || \ -+ defined(__amd64) || defined(__ppc64__) || defined(_WIN64) || \ -+ defined(__LP64__) || defined(_LP64)) -+#define LZ4_ARCH64 1 -+#else -+#define LZ4_ARCH64 0 -+#endif -+ -+/* -+ * Little Endian or Big Endian? -+ * Note: overwrite the below #define if you know your architecture endianess. -+ */ -+#if (defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || \ -+ defined(_BIG_ENDIAN) || defined(_ARCH_PPC) || defined(__PPC__) || \ -+ defined(__PPC) || defined(PPC) || defined(__powerpc__) || \ -+ defined(__powerpc) || defined(powerpc) || \ -+ ((defined(__BYTE_ORDER__)&&(__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)))) -+#define LZ4_BIG_ENDIAN 1 -+#else -+ /* -+ * Little Endian assumed. PDP Endian and other very rare endian format -+ * are unsupported. -+ */ -+#endif -+ -+/* -+ * Compiler Options -+ */ -+ -+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -+/* "restrict" is a known keyword */ -+#else -+/* Disable restrict */ -+#ifndef restrict -+#define restrict /* Only if somebody already didn't take care of that.*/ -+#endif -+#endif -+ -+#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) -+ -+#define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) \ -+ | (((x) & 0xffu) << 8))) -+ -+#if (GCC_VERSION >= 302) || (__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 grub_size_t size_t; -+ -+typedef struct _U16_S { -+ U16 v; -+} U16_S; -+typedef struct _U32_S { -+ U32 v; -+} U32_S; -+typedef struct _U64_S { -+ U64 v; -+} 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 -+ -+#if (defined(LZ4_BIG_ENDIAN) && !defined(BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE)) -+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \ -+ { U16 v = A16(p); v = lz4_bswap16(v); d = (s) - v; } -+#define LZ4_WRITE_LITTLEENDIAN_16(p, i) \ -+ { U16 v = (U16)(i); v = lz4_bswap16(v); A16(p) = v; p += 2; } -+#else -+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) { d = (s) - A16(p); } -+#define LZ4_WRITE_LITTLEENDIAN_16(p, v) { A16(p) = v; p += 2; } -+#endif -+ -+/* 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, size_t s_len, size_t d_len); -+ -+grub_err_t -+lz4_decompress(void *s_start, void *d_start, size_t s_len, 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; -+} -+ -+static int -+LZ4_uncompress_unknownOutputSize(const char *source, -+ char *dest, int isize, int maxOutputSize) -+{ -+ /* Local Variables */ -+ const BYTE *restrict ip = (const BYTE *) source; -+ const BYTE *const iend = ip + isize; -+ const BYTE *restrict ref; -+ -+ BYTE *restrict op = (BYTE *) dest; -+ BYTE *const oend = op + maxOutputSize; -+ BYTE *cpy; -+ -+ 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 */ -+ 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 -+ size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; -+ 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)); -+} -diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c -index fdb587a..c96bf21 100644 ---- a/grub-core/fs/zfs/zfsinfo.c -+++ b/grub-core/fs/zfs/zfsinfo.c -@@ -132,21 +132,31 @@ print_vdev_info (char *nvlist, int tab) - grub_free (path); - return GRUB_ERR_NONE; - } -+ char is_mirror=(grub_strcmp(type,VDEV_TYPE_MIRROR) == 0); -+ char is_raidz=(grub_strcmp(type,VDEV_TYPE_RAIDZ) == 0); - -- if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0) -+ if (is_mirror || is_raidz) - { - int nelm, i; - - nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm - (nvlist, ZPOOL_CONFIG_CHILDREN); - -+ if(is_mirror){ -+ grub_puts_ (N_("This VDEV is a mirror")); -+ } -+ else if(is_raidz){ -+ grub_uint64_t parity; -+ grub_zfs_nvlist_lookup_uint64(nvlist,"nparity",&parity); -+ grub_printf_ (N_("This VDEV is a RAIDZ%llu\n"),(unsigned long long)parity); -+ } - print_tabs (tab); - if (nelm <= 0) - { -- grub_puts_ (N_("Incorrect mirror")); -+ grub_puts_ (N_("Incorrect VDEV")); - return GRUB_ERR_NONE; - } -- grub_printf_ (N_("Mirror with %d children\n"), nelm); -+ grub_printf_ (N_("VDEV with %d children\n"), nelm); - print_state (nvlist, tab); - for (i = 0; i < nelm; i++) - { -@@ -162,14 +172,14 @@ print_vdev_info (char *nvlist, int tab) - total element number. And the number itself is fine, - only the element isn't. - */ -- grub_printf_ (N_("Mirror element number %d isn't correct\n"), i); -+ grub_printf_ (N_("VDEV element number %d isn't correct\n"), i); - continue; - } - - /* TRANSLATORS: it's the element carying the number %d, not - total element number. This is used in enumeration - "Element number 1", "Element number 2", ... */ -- grub_printf_ (N_("Mirror element number %d:\n"), i); -+ grub_printf_ (N_("VDEV element number %d:\n"), i); - print_vdev_info (child, tab + 1); - - grub_free (child); -diff --git a/include/grub/zfs/dmu.h b/include/grub/zfs/dmu.h -index 8fc6dc5..4ad616c 100644 ---- a/include/grub/zfs/dmu.h -+++ b/include/grub/zfs/dmu.h -@@ -22,6 +22,39 @@ - - #ifndef _SYS_DMU_H - #define _SYS_DMU_H -+#define B_FALSE 0 -+#define B_TRUE 1 -+ -+#define DMU_OT_NEWTYPE 0x80 -+#define DMU_OT_METADATA 0x40 -+#define DMU_OT_BYTESWAP_MASK 0x3f -+ -+#define DMU_OT(byteswap, metadata) \ -+ (DMU_OT_NEWTYPE | \ -+ ((metadata) ? DMU_OT_METADATA : 0) | \ -+ ((byteswap) & DMU_OT_BYTESWAP_MASK)) -+ -+#define DMU_OT_IS_VALID(ot) (((ot) & DMU_OT_NEWTYPE) ? \ -+ ((ot) & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS : \ -+ (ot) < DMU_OT_NUMTYPES) -+ -+#define DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \ -+ ((ot) & DMU_OT_METADATA) : \ -+ dmu_ot[(ot)].ot_metadata) -+ -+typedef enum dmu_object_byteswap { -+ DMU_BSWAP_UINT8, -+ DMU_BSWAP_UINT16, -+ DMU_BSWAP_UINT32, -+ DMU_BSWAP_UINT64, -+ DMU_BSWAP_ZAP, -+ DMU_BSWAP_DNODE, -+ DMU_BSWAP_OBJSET, -+ DMU_BSWAP_ZNODE, -+ DMU_BSWAP_OLDACL, -+ DMU_BSWAP_ACL, -+ DMU_BSWAP_NUMFUNCS -+} dmu_object_byteswap_t; - - /* - * This file describes the interface that the DMU provides for its -@@ -89,7 +122,17 @@ typedef enum dmu_object_type { - DMU_OT_SA_ATTR_REGISTRATION, /* ZAP */ - DMU_OT_SA_ATTR_LAYOUTS, /* ZAP */ - DMU_OT_DSL_KEYCHAIN = 54, -- DMU_OT_NUMTYPES -+ DMU_OT_NUMTYPES, -+ DMU_OTN_UINT8_DATA = DMU_OT(DMU_BSWAP_UINT8, B_FALSE), -+ DMU_OTN_UINT8_METADATA = DMU_OT(DMU_BSWAP_UINT8, B_TRUE), -+ DMU_OTN_UINT16_DATA = DMU_OT(DMU_BSWAP_UINT16, B_FALSE), -+ DMU_OTN_UINT16_METADATA = DMU_OT(DMU_BSWAP_UINT16, B_TRUE), -+ DMU_OTN_UINT32_DATA = DMU_OT(DMU_BSWAP_UINT32, B_FALSE), -+ DMU_OTN_UINT32_METADATA = DMU_OT(DMU_BSWAP_UINT32, B_TRUE), -+ DMU_OTN_UINT64_DATA = DMU_OT(DMU_BSWAP_UINT64, B_FALSE), -+ DMU_OTN_UINT64_METADATA = DMU_OT(DMU_BSWAP_UINT64, B_TRUE), -+ DMU_OTN_ZAP_DATA = DMU_OT(DMU_BSWAP_ZAP, B_FALSE), -+ DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE), - } dmu_object_type_t; - - typedef enum dmu_objset_type { -@@ -116,5 +159,6 @@ typedef enum dmu_objset_type { - #define DMU_POOL_HISTORY "history" - #define DMU_POOL_PROPS "pool_props" - #define DMU_POOL_L2CACHE "l2cache" -+#define DMU_POOL_FEATURES_FOR_READ "features_for_read" - - #endif /* _SYS_DMU_H */ -diff --git a/include/grub/zfs/zfs.h b/include/grub/zfs/zfs.h -index e326c8b..761ade7 100644 ---- a/include/grub/zfs/zfs.h -+++ b/include/grub/zfs/zfs.h -@@ -36,8 +36,13 @@ typedef enum grub_zfs_endian - /* - * On-disk version number. - */ --#define SPA_VERSION 33ULL -- -+#define SPA_VERSION_INITIAL 1ULL -+#define SPA_VERSION_BEFORE_FEATURES 33ULL -+#define SPA_VERSION 5000ULL -+#define SPA_VERSION_FEATURES 5000ULL -+#define SPA_VERSION_IS_SUPPORTED(v) \ -+ (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \ -+ ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION)) - /* - * The following are configuration names used in the nvlist describing a pool's - * configuration. -@@ -76,6 +81,7 @@ typedef enum grub_zfs_endian - #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" - #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" - #define ZPOOL_CONFIG_DDT_STATS "ddt_stats" -+#define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read" - /* - * The persistent vdev state is stored as separate values rather than a single - * 'vdev_state' entry. This is because a device can be in multiple states, such -diff --git a/include/grub/zfs/zio.h b/include/grub/zfs/zio.h -index b1c46da..8fad2cc 100644 ---- a/include/grub/zfs/zio.h -+++ b/include/grub/zfs/zio.h -@@ -88,6 +88,7 @@ enum zio_compress { - ZIO_COMPRESS_GZIP8, - ZIO_COMPRESS_GZIP9, - ZIO_COMPRESS_ZLE, -+ ZIO_COMPRESS_LZ4, - ZIO_COMPRESS_FUNCTIONS - }; - -diff --git a/po/POTFILES.in b/po/POTFILES.in -index 987b37a..c55d9e3 100644 ---- a/po/POTFILES.in -+++ b/po/POTFILES.in -@@ -173,6 +173,7 @@ - ./grub-core/fs/zfs/zfs_fletcher.c - ./grub-core/fs/zfs/zfsinfo.c - ./grub-core/fs/zfs/zfs_lzjb.c -+./grub-core/fs/zfs/zfs_lz4.c - ./grub-core/fs/zfs/zfs_sha256.c - ./grub-core/gdb/cstub.c - ./grub-core/gdb/gdb.c diff --git a/sys-boot/grub/files/grub-2.00-zfs-feature-flag-support.patch b/sys-boot/grub/files/grub-2.00-zfs-feature-flag-support.patch deleted file mode 100644 index 998dc0733683..000000000000 --- a/sys-boot/grub/files/grub-2.00-zfs-feature-flag-support.patch +++ /dev/null @@ -1,1017 +0,0 @@ -ZFS Feature Flag Support - -This is a monolithic version of the following commits: - -https://github.com/maxximino/grub2/commit/31a32560fd7948ae5ff5c63105d7c068de7890c8 -https://github.com/maxximino/grub2/commit/595d76e8ca0690a963f5533689de8db54ef07e75 -https://github.com/maxximino/grub2/commit/58344034e40218b20500fa2936eb4d7d019e1e88 -https://github.com/maxximino/grub2/commit/f98cb078abab2c14bb0766b5a0ceb055683dab81 -https://github.com/maxximino/grub2/commit/f12806f43a969a654dee7bb89b2e8fd5c42f0e2e - -A minor change was made to account for d8a0feb6 from upstream. This change -prevents a compile time failure that is caused by a change in the callback -interface used by mzap_interate(). - -The initial feature flag support patches were written by Delphix while the LZ4 -support was written by Saso Kiselkov. The work porting this to GRUB2 was done -by Massimo Maggi, while the adaption to Gentoo's GRUB2 package was done by -Richard Yao. - -diff --git a/Makefile.util.def b/Makefile.util.def -index b80187c..1bf3038 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -95,6 +95,7 @@ library = { - common = grub-core/fs/zfs/zfs.c; - common = grub-core/fs/zfs/zfsinfo.c; - common = grub-core/fs/zfs/zfs_lzjb.c; -+ common = grub-core/fs/zfs/zfs_lz4.c; - common = grub-core/fs/zfs/zfs_sha256.c; - common = grub-core/fs/zfs/zfs_fletcher.c; - common = grub-core/lib/envblk.c; -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 39e77a4..1550b90 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1186,6 +1186,7 @@ module = { - name = zfs; - common = fs/zfs/zfs.c; - common = fs/zfs/zfs_lzjb.c; -+ common = fs/zfs/zfs_lz4.c; - common = fs/zfs/zfs_sha256.c; - common = fs/zfs/zfs_fletcher.c; - }; -diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c -index ba0554a..de31e6c 100644 ---- a/grub-core/fs/zfs/zfs.c -+++ b/grub-core/fs/zfs/zfs.c -@@ -2,6 +2,7 @@ - * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2009,2010,2011 Free Software Foundation, Inc. - * Copyright 2010 Sun Microsystems, Inc. -+ * Copyright (c) 2012 by Delphix. All rights reserved. - * - * GRUB is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by -@@ -153,11 +154,13 @@ ZAP_LEAF_ENTRY(zap_leaf_phys_t *l, int bs, int idx) - - - /* -- * Decompression Entry - lzjb -+ * Decompression Entry - lzjb & lz4 - */ - - extern grub_err_t lzjb_decompress (void *, void *, grub_size_t, grub_size_t); - -+extern grub_err_t lz4_decompress (void *, void *, grub_size_t, grub_size_t); -+ - typedef grub_err_t zfs_decomp_func_t (void *s_start, void *d_start, - grub_size_t s_len, grub_size_t d_len); - typedef struct decomp_entry -@@ -263,6 +266,19 @@ grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key - grub_size_t keysize, - grub_uint64_t salt, - grub_uint64_t algo) = NULL; -+/* -+ * List of pool features that the grub implementation of ZFS supports for -+ * read. Note that features that are only required for write do not need -+ * to be listed here since grub opens pools in read-only mode. -+ */ -+static const char *spa_feature_names[] = { -+ "org.illumos:lz4_compress",NULL -+}; -+ -+static int -+check_feature(const char *name, grub_uint64_t val); -+static int -+check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ); - - static grub_err_t - zlib_decompress (void *s, void *d, -@@ -322,6 +338,7 @@ static decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = { - {"gzip-8", zlib_decompress}, /* ZIO_COMPRESS_GZIP8 */ - {"gzip-9", zlib_decompress}, /* ZIO_COMPRESS_GZIP9 */ - {"zle", zle_decompress}, /* ZIO_COMPRESS_ZLE */ -+ {"lz4", lz4_decompress}, /* ZIO_COMPRESS_LZ4 */ - }; - - static grub_err_t zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, -@@ -482,15 +499,11 @@ uberblock_verify (uberblock_phys_t * ub, grub_uint64_t offset, - - if (grub_zfs_to_cpu64 (uber->ub_magic, GRUB_ZFS_LITTLE_ENDIAN) - == UBERBLOCK_MAGIC -- && grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_LITTLE_ENDIAN) > 0 -- && grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_LITTLE_ENDIAN) -- <= SPA_VERSION) -- endian = GRUB_ZFS_LITTLE_ENDIAN; -+ && SPA_VERSION_IS_SUPPORTED(grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_LITTLE_ENDIAN))) -+ endian = GRUB_ZFS_LITTLE_ENDIAN; - - if (grub_zfs_to_cpu64 (uber->ub_magic, GRUB_ZFS_BIG_ENDIAN) == UBERBLOCK_MAGIC -- && grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_BIG_ENDIAN) > 0 -- && grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_BIG_ENDIAN) -- <= SPA_VERSION) -+ && SPA_VERSION_IS_SUPPORTED(grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_BIG_ENDIAN))) - endian = GRUB_ZFS_BIG_ENDIAN; - - if (endian == GRUB_ZFS_UNKNOWN_ENDIAN) -@@ -764,6 +777,155 @@ fill_vdev_info (struct grub_zfs_data *data, - } - - /* -+ * For a given XDR packed nvlist, verify the first 4 bytes and move on. -+ * -+ * An XDR packed nvlist is encoded as (comments from nvs_xdr_create) : -+ * -+ * encoding method/host endian (4 bytes) -+ * nvl_version (4 bytes) -+ * nvl_nvflag (4 bytes) -+ * encoded nvpairs: -+ * encoded size of the nvpair (4 bytes) -+ * decoded size of the nvpair (4 bytes) -+ * name string size (4 bytes) -+ * name string data (sizeof(NV_ALIGN4(string)) -+ * data type (4 bytes) -+ * # of elements in the nvpair (4 bytes) -+ * data -+ * 2 zero's for the last nvpair -+ * (end of the entire list) (8 bytes) -+ * -+ */ -+ -+/* -+ * The nvlist_next_nvpair() function returns a handle to the next nvpair in the -+ * list following nvpair. If nvpair is NULL, the first pair is returned. If -+ * nvpair is the last pair in the nvlist, NULL is returned. -+ */ -+static const char * -+nvlist_next_nvpair(const char *nvl, const char *nvpair) -+{ -+ const char *nvp; -+ int encode_size; -+ int name_len; -+ if (nvl == NULL) -+ return (NULL); -+ -+ if (nvpair == NULL) { -+ /* skip over header, nvl_version and nvl_nvflag */ -+ nvpair = nvl + 4 * 3; -+ } else { -+ /* skip to the next nvpair */ -+ encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvpair)); -+ nvpair += encode_size; -+ } -+ /* 8 bytes of 0 marks the end of the list */ -+ if (*(grub_uint64_t*)nvpair == 0) -+ return (NULL); -+ /*consistency checks*/ -+ if (nvpair + 4 * 3 >= nvl + VDEV_PHYS_SIZE) -+ { -+ grub_dprintf ("zfs", "nvlist overflow\n"); -+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); -+ return (NULL); -+ } -+ encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvpair)); -+ -+ nvp = nvpair + 4*2; -+ name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); -+ nvp += 4; -+ -+ nvp = nvp + ((name_len + 3) & ~3); // align -+ if (nvp + 4 >= nvl + VDEV_PHYS_SIZE -+ || encode_size < 0 -+ || nvp + 4 + encode_size > nvl + VDEV_PHYS_SIZE) -+ { -+ grub_dprintf ("zfs", "nvlist overflow\n"); -+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); -+ return (NULL); -+ } -+ /* end consistency checks */ -+ -+ return (nvpair); -+} -+/* -+ * This function returns 0 on success and 1 on failure. On success, a string -+ * containing the name of nvpair is saved in buf. -+ */ -+static int -+nvpair_name(const char *nvp, char **buf, int* buflen) -+{ -+ int len; -+ -+ /* skip over encode/decode size */ -+ nvp += 4 * 2; -+ -+ len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); -+ nvp=nvp+4; -+ -+ *buf=(char*)nvp; -+ *buflen=len; -+ -+ return (0); -+} -+/* -+ * This function retrieves the value of the nvpair in the form of enumerated -+ * type data_type_t. -+ */ -+static int -+nvpair_type(const char *nvp) -+{ -+ int name_len, type; -+ -+ /* skip over encode/decode size */ -+ nvp += 4 * 2; -+ -+ /* skip over name_len */ -+ name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); -+ nvp += 4; -+ -+ /* skip over name */ -+ nvp = nvp + ((name_len + 3) & ~3); /* align */ -+ -+ type = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); -+ -+ return (type); -+} -+static int -+nvpair_value(const char *nvp,char **val, -+ grub_size_t *size_out, grub_size_t *nelm_out) -+{ -+ int name_len,nelm,encode_size; -+ -+ /* skip over encode/decode size */ -+ encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvp)); -+ nvp += 8; -+ -+ /* skip over name_len */ -+ name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); -+ nvp += 4; -+ -+ /* skip over name */ -+ nvp = nvp + ((name_len + 3) & ~3); /* align */ -+ -+ /* skip over type */ -+ nvp += 4; -+ nelm = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); -+ nvp +=4; -+ if (nelm < 1) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "empty nvpair"); -+ return 0; -+ } -+ *val = (char *) nvp; -+ *size_out = encode_size; -+ if (nelm_out) -+ *nelm_out = nelm; -+ -+ return 1; -+} -+ -+/* - * Check the disk label information and retrieve needed vdev name-value pairs. - * - */ -@@ -773,7 +935,7 @@ check_pool_label (struct grub_zfs_data *data, - int *inserted) - { - grub_uint64_t pool_state, txg = 0; -- char *nvlist; -+ char *nvlist,*features; - #if 0 - char *nv; - #endif -@@ -837,13 +999,13 @@ check_pool_label (struct grub_zfs_data *data, - } - grub_dprintf ("zfs", "check 8 passed\n"); - -- if (version > SPA_VERSION) -+ if (!SPA_VERSION_IS_SUPPORTED(version)) - { - grub_free (nvlist); - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "too new version %llu > %llu", - (unsigned long long) version, -- (unsigned long long) SPA_VERSION); -+ (unsigned long long) SPA_VERSION_BEFORE_FEATURES); - } - grub_dprintf ("zfs", "check 9 passed\n"); - -@@ -893,7 +1055,30 @@ check_pool_label (struct grub_zfs_data *data, - grub_free (nv); - } - grub_dprintf ("zfs", "check 10 passed\n"); -- -+ if ((features=grub_zfs_nvlist_lookup_nvlist(nvlist, ZPOOL_CONFIG_FEATURES_FOR_READ))) -+ { -+ const char *nvp=NULL; -+ char *name = grub_zalloc(51); -+ char *nameptr; -+ int namelen; -+ while ((nvp = nvlist_next_nvpair(features, nvp)) != NULL) -+ { -+ nvpair_name(nvp, &nameptr,&namelen); -+ if(namelen > 50){namelen=50;} -+ grub_strncpy(name,nameptr,namelen); -+ name[namelen]=0; -+ grub_dprintf("zfs","namelen=%u str=%s\n",namelen,name); -+ if (check_feature(name,1) != 0) -+ { -+ grub_dprintf("zfs","feature missing in check_pool_label:%s\n",name); -+ err= grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET," check_pool_label missing feature '%s' for read",name); -+ grub_free(name); -+ return err; -+ } -+ } -+ grub_free(name); -+ } -+ grub_dprintf ("zfs", "check 12 passed (feature flags)\n"); - grub_free (nvlist); - - return GRUB_ERR_NONE; -@@ -3034,34 +3219,14 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, - return err; - } - --/* -- * For a given XDR packed nvlist, verify the first 4 bytes and move on. -- * -- * An XDR packed nvlist is encoded as (comments from nvs_xdr_create) : -- * -- * encoding method/host endian (4 bytes) -- * nvl_version (4 bytes) -- * nvl_nvflag (4 bytes) -- * encoded nvpairs: -- * encoded size of the nvpair (4 bytes) -- * decoded size of the nvpair (4 bytes) -- * name string size (4 bytes) -- * name string data (sizeof(NV_ALIGN4(string)) -- * data type (4 bytes) -- * # of elements in the nvpair (4 bytes) -- * data -- * 2 zero's for the last nvpair -- * (end of the entire list) (8 bytes) -- * -- */ -- - static int - nvlist_find_value (const char *nvlist_in, const char *name, - int valtype, char **val, - grub_size_t *size_out, grub_size_t *nelm_out) - { -- int name_len, type, encode_size; -- const char *nvpair, *nvp_name, *nvlist = nvlist_in; -+ int name_len, type ; -+ const char *nvpair=NULL,*nvlist=nvlist_in; -+ char *nvp_name; - - /* Verify if the 1st and 2nd byte in the nvlist are valid. */ - /* NOTE: independently of what endianness header announces all -@@ -3074,62 +3239,18 @@ nvlist_find_value (const char *nvlist_in, const char *name, - return 0; - } - -- /* skip the header, nvl_version, and nvl_nvflag */ -- nvlist = nvlist + 4 * 3; - /* - * Loop thru the nvpair list - * The XDR representation of an integer is in big-endian byte order. - */ -- while ((encode_size = grub_be_to_cpu32 (grub_get_unaligned32 (nvlist)))) -+ while ((nvpair=nvlist_next_nvpair(nvlist,nvpair))) - { -- int nelm; -- -- if (nvlist + 4 * 4 >= nvlist_in + VDEV_PHYS_SIZE) -- { -- grub_dprintf ("zfs", "nvlist overflow\n"); -- grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); -- return 0; -- } -- -- nvpair = nvlist + 4 * 2; /* skip the encode/decode size */ -- -- name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvpair)); -- nvpair += 4; -- -- nvp_name = nvpair; -- nvpair = nvpair + ((name_len + 3) & ~3); /* align */ -- -- if (nvpair + 8 >= nvlist_in + VDEV_PHYS_SIZE -- || encode_size < 0 -- || nvpair + 8 + encode_size > nvlist_in + VDEV_PHYS_SIZE) -+ nvpair_name(nvpair,&nvp_name,&name_len); -+ type = nvpair_type(nvpair); -+ if ((grub_strncmp (nvp_name, name, grub_strlen(name)) == 0) && type == valtype) - { -- grub_dprintf ("zfs", "nvlist overflow\n"); -- grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); -- return 0; -+ return nvpair_value(nvpair,val,size_out,nelm_out); - } -- -- type = grub_be_to_cpu32 (grub_get_unaligned32 (nvpair)); -- nvpair += 4; -- -- nelm = grub_be_to_cpu32 (grub_get_unaligned32 (nvpair)); -- if (nelm < 1) -- { -- grub_error (GRUB_ERR_BAD_FS, "empty nvpair"); -- return 0; -- } -- -- nvpair += 4; -- -- if ((grub_strncmp (nvp_name, name, name_len) == 0) && type == valtype) -- { -- *val = (char *) nvpair; -- *size_out = encode_size; -- if (nelm_out) -- *nelm_out = nelm; -- return 1; -- } -- -- nvlist += encode_size; /* goto the next nvpair */ - } - return 0; - } -@@ -3386,6 +3507,10 @@ zfs_mount (grub_device_t dev) - return NULL; - } - -+ if (ub->ub_version >= SPA_VERSION_FEATURES && -+ check_mos_features(&((objset_phys_t *) osp)->os_meta_dnode,ub_endian, data) != 0) -+ return NULL; -+ - /* Got the MOS. Save it at the memory addr MOS. */ - grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode, - DNODE_SIZE); -@@ -3910,6 +4035,64 @@ grub_zfs_dir (grub_device_t device, const char *path, - return grub_errno; - } - -+static int -+check_feature(const char *name, grub_uint64_t val) -+{ -+ int i; -+ if(val ==0) return 0; -+ if(*name==0) return 0; -+ for (i = 0; spa_feature_names[i] != NULL; i++) -+ { -+ if (grub_strcmp(name, spa_feature_names[i]) == 0) -+ return 0; -+ } -+ grub_printf("missing feature for read '%s'\n",name); -+ return 1; -+} -+ -+/* -+ * Checks whether the MOS features that are active are supported by this -+ * (GRUB's) implementation of ZFS. -+ * -+ * Return: -+ * 0: Success. -+ * errnum: Failure. -+ */ -+ -+static int -+check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ) -+{ -+ grub_uint64_t objnum; -+ grub_uint8_t errnum = 0; -+ dnode_end_t dn,mosmdn; -+ mzap_phys_t* mzp; -+ grub_zfs_endian_t endianzap; -+ int size; -+ grub_memmove(&(mosmdn.dn),mosmdn_phys,sizeof(dnode_phys_t)); -+ mosmdn.endian=endian; -+ if ((errnum = dnode_get(&mosmdn, DMU_POOL_DIRECTORY_OBJECT, -+ DMU_OT_OBJECT_DIRECTORY, &dn,data)) != 0) -+ return (errnum); -+ -+ /* -+ * Find the object number for 'features_for_read' and retrieve its -+ * corresponding dnode. Note that we don't check features_for_write -+ * because GRUB is not opening the pool for write. -+ */ -+ if ((errnum = zap_lookup(&dn, DMU_POOL_FEATURES_FOR_READ, &objnum, data,0)) != 0) -+ return (errnum); -+ -+ if ((errnum = dnode_get(&mosmdn, objnum, DMU_OTN_ZAP_METADATA, &dn, data)) != 0) -+ return (errnum); -+ -+ if ((errnum = dmu_read(&dn, 0, (void**)&mzp, &endianzap,data)) != 0) -+ return (errnum); -+ -+ size = grub_zfs_to_cpu16 (dn.dn.dn_datablkszsec, dn.endian) << SPA_MINBLOCKSHIFT; -+ return (mzap_iterate(mzp,endianzap, size, check_feature)); -+} -+ -+ - #ifdef GRUB_UTIL - static grub_err_t - grub_zfs_embed (grub_device_t device __attribute__ ((unused)), -diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c -new file mode 100644 -index 0000000..f199434 ---- /dev/null -+++ b/grub-core/fs/zfs/zfs_lz4.c -@@ -0,0 +1,321 @@ -+/* -+ * 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> -+ -+static int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, -+ int isize, int maxOutputSize); -+ -+/* -+ * CPU Feature Detection -+ */ -+ -+/* 32 or 64 bits ? */ -+#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || \ -+ defined(__amd64) || defined(__ppc64__) || defined(_WIN64) || \ -+ defined(__LP64__) || defined(_LP64)) -+#define LZ4_ARCH64 1 -+#else -+#define LZ4_ARCH64 0 -+#endif -+ -+/* -+ * Little Endian or Big Endian? -+ * Note: overwrite the below #define if you know your architecture endianess. -+ */ -+#if (defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || \ -+ defined(_BIG_ENDIAN) || defined(_ARCH_PPC) || defined(__PPC__) || \ -+ defined(__PPC) || defined(PPC) || defined(__powerpc__) || \ -+ defined(__powerpc) || defined(powerpc) || \ -+ ((defined(__BYTE_ORDER__)&&(__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)))) -+#define LZ4_BIG_ENDIAN 1 -+#else -+ /* -+ * Little Endian assumed. PDP Endian and other very rare endian format -+ * are unsupported. -+ */ -+#endif -+ -+/* -+ * Compiler Options -+ */ -+ -+#if __STDC_VERSION__ >= 199901L /* C99 */ -+/* "restrict" is a known keyword */ -+#else -+/* Disable restrict */ -+#ifndef restrict -+#define restrict /* Only if somebody already didn't take care of that.*/ -+#endif -+#endif -+ -+#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) -+ -+#define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) \ -+ | (((x) & 0xffu) << 8))) -+ -+#if (GCC_VERSION >= 302) || (__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 grub_size_t size_t; -+ -+typedef struct _U16_S { -+ U16 v; -+} U16_S; -+typedef struct _U32_S { -+ U32 v; -+} U32_S; -+typedef struct _U64_S { -+ U64 v; -+} 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 -+ -+#if (defined(LZ4_BIG_ENDIAN) && !defined(BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE)) -+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \ -+ { U16 v = A16(p); v = lz4_bswap16(v); d = (s) - v; } -+#define LZ4_WRITE_LITTLEENDIAN_16(p, i) \ -+ { U16 v = (U16)(i); v = lz4_bswap16(v); A16(p) = v; p += 2; } -+#else -+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) { d = (s) - A16(p); } -+#define LZ4_WRITE_LITTLEENDIAN_16(p, v) { A16(p) = v; p += 2; } -+#endif -+ -+/* 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, size_t s_len, size_t d_len); -+ -+grub_err_t -+lz4_decompress(void *s_start, void *d_start, size_t s_len, 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; -+} -+ -+static int -+LZ4_uncompress_unknownOutputSize(const char *source, -+ char *dest, int isize, int maxOutputSize) -+{ -+ /* Local Variables */ -+ const BYTE *restrict ip = (const BYTE *) source; -+ const BYTE *const iend = ip + isize; -+ const BYTE *restrict ref; -+ -+ BYTE *restrict op = (BYTE *) dest; -+ BYTE *const oend = op + maxOutputSize; -+ BYTE *cpy; -+ -+ 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 */ -+ 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 -+ size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; -+ 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)); -+} -diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c -index fdb587a..c96bf21 100644 ---- a/grub-core/fs/zfs/zfsinfo.c -+++ b/grub-core/fs/zfs/zfsinfo.c -@@ -132,21 +132,31 @@ print_vdev_info (char *nvlist, int tab) - grub_free (path); - return GRUB_ERR_NONE; - } -+ char is_mirror=(grub_strcmp(type,VDEV_TYPE_MIRROR) == 0); -+ char is_raidz=(grub_strcmp(type,VDEV_TYPE_RAIDZ) == 0); - -- if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0) -+ if (is_mirror || is_raidz) - { - int nelm, i; - - nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm - (nvlist, ZPOOL_CONFIG_CHILDREN); - -+ if(is_mirror){ -+ grub_puts_ (N_("This VDEV is a mirror")); -+ } -+ else if(is_raidz){ -+ grub_uint64_t parity; -+ grub_zfs_nvlist_lookup_uint64(nvlist,"nparity",&parity); -+ grub_printf_ (N_("This VDEV is a RAIDZ%llu\n"),(unsigned long long)parity); -+ } - print_tabs (tab); - if (nelm <= 0) - { -- grub_puts_ (N_("Incorrect mirror")); -+ grub_puts_ (N_("Incorrect VDEV")); - return GRUB_ERR_NONE; - } -- grub_printf_ (N_("Mirror with %d children\n"), nelm); -+ grub_printf_ (N_("VDEV with %d children\n"), nelm); - print_state (nvlist, tab); - for (i = 0; i < nelm; i++) - { -@@ -162,14 +172,14 @@ print_vdev_info (char *nvlist, int tab) - total element number. And the number itself is fine, - only the element isn't. - */ -- grub_printf_ (N_("Mirror element number %d isn't correct\n"), i); -+ grub_printf_ (N_("VDEV element number %d isn't correct\n"), i); - continue; - } - - /* TRANSLATORS: it's the element carying the number %d, not - total element number. This is used in enumeration - "Element number 1", "Element number 2", ... */ -- grub_printf_ (N_("Mirror element number %d:\n"), i); -+ grub_printf_ (N_("VDEV element number %d:\n"), i); - print_vdev_info (child, tab + 1); - - grub_free (child); -diff --git a/include/grub/zfs/dmu.h b/include/grub/zfs/dmu.h -index 8fc6dc5..4ad616c 100644 ---- a/include/grub/zfs/dmu.h -+++ b/include/grub/zfs/dmu.h -@@ -22,6 +22,39 @@ - - #ifndef _SYS_DMU_H - #define _SYS_DMU_H -+#define B_FALSE 0 -+#define B_TRUE 1 -+ -+#define DMU_OT_NEWTYPE 0x80 -+#define DMU_OT_METADATA 0x40 -+#define DMU_OT_BYTESWAP_MASK 0x3f -+ -+#define DMU_OT(byteswap, metadata) \ -+ (DMU_OT_NEWTYPE | \ -+ ((metadata) ? DMU_OT_METADATA : 0) | \ -+ ((byteswap) & DMU_OT_BYTESWAP_MASK)) -+ -+#define DMU_OT_IS_VALID(ot) (((ot) & DMU_OT_NEWTYPE) ? \ -+ ((ot) & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS : \ -+ (ot) < DMU_OT_NUMTYPES) -+ -+#define DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \ -+ ((ot) & DMU_OT_METADATA) : \ -+ dmu_ot[(ot)].ot_metadata) -+ -+typedef enum dmu_object_byteswap { -+ DMU_BSWAP_UINT8, -+ DMU_BSWAP_UINT16, -+ DMU_BSWAP_UINT32, -+ DMU_BSWAP_UINT64, -+ DMU_BSWAP_ZAP, -+ DMU_BSWAP_DNODE, -+ DMU_BSWAP_OBJSET, -+ DMU_BSWAP_ZNODE, -+ DMU_BSWAP_OLDACL, -+ DMU_BSWAP_ACL, -+ DMU_BSWAP_NUMFUNCS -+} dmu_object_byteswap_t; - - /* - * This file describes the interface that the DMU provides for its -@@ -89,7 +122,17 @@ typedef enum dmu_object_type { - DMU_OT_SA_ATTR_REGISTRATION, /* ZAP */ - DMU_OT_SA_ATTR_LAYOUTS, /* ZAP */ - DMU_OT_DSL_KEYCHAIN = 54, -- DMU_OT_NUMTYPES -+ DMU_OT_NUMTYPES, -+ DMU_OTN_UINT8_DATA = DMU_OT(DMU_BSWAP_UINT8, B_FALSE), -+ DMU_OTN_UINT8_METADATA = DMU_OT(DMU_BSWAP_UINT8, B_TRUE), -+ DMU_OTN_UINT16_DATA = DMU_OT(DMU_BSWAP_UINT16, B_FALSE), -+ DMU_OTN_UINT16_METADATA = DMU_OT(DMU_BSWAP_UINT16, B_TRUE), -+ DMU_OTN_UINT32_DATA = DMU_OT(DMU_BSWAP_UINT32, B_FALSE), -+ DMU_OTN_UINT32_METADATA = DMU_OT(DMU_BSWAP_UINT32, B_TRUE), -+ DMU_OTN_UINT64_DATA = DMU_OT(DMU_BSWAP_UINT64, B_FALSE), -+ DMU_OTN_UINT64_METADATA = DMU_OT(DMU_BSWAP_UINT64, B_TRUE), -+ DMU_OTN_ZAP_DATA = DMU_OT(DMU_BSWAP_ZAP, B_FALSE), -+ DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE), - } dmu_object_type_t; - - typedef enum dmu_objset_type { -@@ -116,5 +159,6 @@ typedef enum dmu_objset_type { - #define DMU_POOL_HISTORY "history" - #define DMU_POOL_PROPS "pool_props" - #define DMU_POOL_L2CACHE "l2cache" -+#define DMU_POOL_FEATURES_FOR_READ "features_for_read" - - #endif /* _SYS_DMU_H */ -diff --git a/include/grub/zfs/zfs.h b/include/grub/zfs/zfs.h -index e326c8b..761ade7 100644 ---- a/include/grub/zfs/zfs.h -+++ b/include/grub/zfs/zfs.h -@@ -36,8 +36,13 @@ typedef enum grub_zfs_endian - /* - * On-disk version number. - */ --#define SPA_VERSION 33ULL -- -+#define SPA_VERSION_INITIAL 1ULL -+#define SPA_VERSION_BEFORE_FEATURES 33ULL -+#define SPA_VERSION 5000ULL -+#define SPA_VERSION_FEATURES 5000ULL -+#define SPA_VERSION_IS_SUPPORTED(v) \ -+ (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \ -+ ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION)) - /* - * The following are configuration names used in the nvlist describing a pool's - * configuration. -@@ -76,6 +81,7 @@ typedef enum grub_zfs_endian - #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" - #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" - #define ZPOOL_CONFIG_DDT_STATS "ddt_stats" -+#define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read" - /* - * The persistent vdev state is stored as separate values rather than a single - * 'vdev_state' entry. This is because a device can be in multiple states, such -diff --git a/include/grub/zfs/zio.h b/include/grub/zfs/zio.h -index b1c46da..8fad2cc 100644 ---- a/include/grub/zfs/zio.h -+++ b/include/grub/zfs/zio.h -@@ -88,6 +88,7 @@ enum zio_compress { - ZIO_COMPRESS_GZIP8, - ZIO_COMPRESS_GZIP9, - ZIO_COMPRESS_ZLE, -+ ZIO_COMPRESS_LZ4, - ZIO_COMPRESS_FUNCTIONS - }; - -diff --git a/po/POTFILES.in b/po/POTFILES.in -index 987b37a..c55d9e3 100644 ---- a/po/POTFILES.in -+++ b/po/POTFILES.in -@@ -173,6 +173,7 @@ - ./grub-core/fs/zfs/zfs_fletcher.c - ./grub-core/fs/zfs/zfsinfo.c - ./grub-core/fs/zfs/zfs_lzjb.c -+./grub-core/fs/zfs/zfs_lz4.c - ./grub-core/fs/zfs/zfs_sha256.c - ./grub-core/gdb/cstub.c - ./grub-core/gdb/gdb.c diff --git a/sys-boot/grub/files/grub-2.02_beta1-only-use-scripts-that-are-executable.patch b/sys-boot/grub/files/grub-2.02_beta1-only-use-scripts-that-are-executable.patch deleted file mode 100644 index 1d293eb1d99f..000000000000 --- a/sys-boot/grub/files/grub-2.02_beta1-only-use-scripts-that-are-executable.patch +++ /dev/null @@ -1,35 +0,0 @@ -From b8ff36598b7c77d85984b5cb6b5f95a0b679dd52 Mon Sep 17 00:00:00 2001 -From: Lars Wendler <polynomial-c@gentoo.org> -Date: Thu, 19 Dec 2013 14:04:23 +0100 -Subject: [PATCH] grub-mkconfig: only use scripts that are executable - -commit ec824e0f2a399ce2ab3a2e3353d372a236595059 breaks grub-mkconfig if one of -the pre-defined config files are not executable. - -This patch fixes https://bugs.gentoo.org/494716 - -Signed-off-by: Lars Wendler <polynomial-c@gentoo.org> ---- - util/grub-mkconfig.in | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 0ca0db1..fe33092 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -260,10 +260,12 @@ for i in "${grub_mkconfig_dir}"/* ; do - | "${grub_mkconfig_dir}"/30_os-prober \ - | "${grub_mkconfig_dir}"/40_custom \ - | "${grub_mkconfig_dir}"/41_custom) -+ if test -x "$i" ; then - echo - echo "### BEGIN $i ###" - "$i" - echo "### END $i ###" -+ fi - ;; - # emacsen backup files. FIXME: support other editors - *~) ;; --- -1.8.5.2 - diff --git a/sys-boot/grub/files/grub.default b/sys-boot/grub/files/grub.default deleted file mode 100644 index 061e4d1b9de7..000000000000 --- a/sys-boot/grub/files/grub.default +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 1999-2012 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/files/grub.default,v 1.3 2012/02/29 01:52:23 floppym Exp $ -# -# To populate all changes in this file you need to regenerate your -# grub configuration file afterwards: -# 'grub2-mkconfig -o /boot/grub2/grub.cfg' -# -# See the grub info page for documentation on possible variables and -# their associated values. - -GRUB_DISTRIBUTOR="Gentoo" - -GRUB_DEFAULT=0 -GRUB_HIDDEN_TIMEOUT=0 -GRUB_HIDDEN_TIMEOUT_QUIET=true -GRUB_TIMEOUT=10 - -GRUB_CMDLINE_LINUX_DEFAULT="" -GRUB_CMDLINE_LINUX="" - -# Uncomment to disable graphical terminal (grub-pc only) -#GRUB_TERMINAL=console - -# The resolution used on graphical terminal. -# Note that you can use only modes which your graphic card supports via VBE. -# You can see them in real GRUB with the command `vbeinfo'. -#GRUB_GFXMODE=640x480 - -# Background image used on graphical terminal. -# Can be in various bitmap formats. -#GRUB_BACKGROUND="/boot/grub2/mybackground.png" - -# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to kernel -#GRUB_DISABLE_LINUX_UUID=true - -# Uncomment to disable generation of recovery mode menu entries -#GRUB_DISABLE_RECOVERY=true |