Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VeUVT-0003kj-OD for mharc-grub-devel@gnu.org; Thu, 07 Nov 2013 13:40:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeUVP-0003kY-1G for grub-devel@gnu.org; Thu, 07 Nov 2013 13:40:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VeUVM-0007ls-0p for grub-devel@gnu.org; Thu, 07 Nov 2013 13:40:34 -0500 Received: from mail-ve0-x249.google.com ([2607:f8b0:400c:c01::249]:44124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeUVL-0007le-Kg for grub-devel@gnu.org; Thu, 07 Nov 2013 13:40:31 -0500 Received: by mail-ve0-f201.google.com with SMTP id jy13so66091veb.0 for ; Thu, 07 Nov 2013 10:40:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Ppz7rKu3gwL8c7f29uErN7vCx5pFdFNKmOvglWPCueE=; b=oyB3sDxa55h7U5aWvkY8vnF2alVMAvvZID5NhYrRLS6AD+KixaUIxMWd+x7ddBZIr0 YfskEHFYHW9ESyjnLESolqedGhg3GoSDj8X+w5IXEWc5gz7kJ8zf8bqwAF9SlHeSjqEt G0mLvofbloCOlexePeAfTw+ktCzgfe2F5mM4yoszB0Ds9oUaT2fsmjXu2gKmcEDZ13wG 9a+mMSfbkm5aEN4iy8QoPfYRh5Sx3XDPaUVgRhZTn4wEt7lbJdOhfn6O5nXtqt0o/e1k Fu+Lcxs4ZK/g/ceBPbLjmVGz3NHeqv9A3yq6C2Y/OfChDAcHaI3mBChph6tYRFfplUcO LXZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ppz7rKu3gwL8c7f29uErN7vCx5pFdFNKmOvglWPCueE=; b=nLz0ClT1aJKKaz6pVipNSmWoeU6kjIh3oRiRp9A4sKhWd5yfd2XVuQRULEt2cOpj/w tjpBnYxWC36+VgyqxFA0YQsagHSGyw/HefEr/lqeS0G07hF+iOPJpkVTJdmcFSitXDI6 fziFIRy18o3tPQ8c0xrcXKIll+qNNYPE1HQ2yB0I37kGz8FyNtuXdlw6lrVFmQYx28uj YsToogni2JrblFFmcyhkxKOcHmXXQ1X2IQRifl8UwiM4bZWZrngH57oetxiEAKEfcIYU gyei2IflMSSr28exDKZXJLqBFto1WIp2uIS6kx3Em3L5bHpQfxDJKFnwCUyqwl1b/oq0 gG1A== X-Gm-Message-State: ALoCoQkmlSm2aN1IGL8/91nj/VC9sRlJxu1zz0+nWRALh6A2aVRoNTaD6fzrE+kBKo/nGDeeGuplW6SK6Uzy/kBTaPryF31Q810mbVKIw7CMpR6OGUkfyqHt5CeYSgcdh5vv7nEL1/dkvIWucmOEdhkOkedizc8nONvIoyDLQq6rft0q5JWSxdyQQQE12d8AHNqyYni8JDFZAqmmml+Fcv9LJPxUEqapG+CSGrhI7uYdnYImtg/ag8k= X-Received: by 10.236.145.34 with SMTP id o22mr672634yhj.22.1383849630565; Thu, 07 Nov 2013 10:40:30 -0800 (PST) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id x74si686219yhh.0.2013.11.07.10.40.30 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Nov 2013 10:40:30 -0800 (PST) Received: from yinz.mtv.corp.google.com (yinz.mtv.corp.google.com [172.17.81.122]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 5531431C078; Thu, 7 Nov 2013 10:40:30 -0800 (PST) Received: by yinz.mtv.corp.google.com (Postfix, from userid 184367) id C4367C08A7; Thu, 7 Nov 2013 10:40:29 -0800 (PST) From: Jon McCune To: grub-devel@gnu.org Subject: [PATCH v1] Support to disable reed-solomon codes Date: Thu, 7 Nov 2013 10:40:18 -0800 Message-Id: <1383849618-17129-1-git-send-email-jonmccune@google.com> X-Mailer: git-send-email 1.8.4.1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c01::249 Cc: Jon McCune X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Nov 2013 18:40:37 -0000 [v0] new grub-*-setup flag to disable insertion of reed solomon codes [v0] grub-install support for option --no-rs-codes [v1] bugfix: also change the maxsec value in util/setup.c Signed-off-by: Jon McCune --- include/grub/util/install.h | 4 ++-- util/grub-install.in | 7 +++++- util/grub-setup.c | 12 +++++++++- util/setup.c | 53 +++++++++++++++++++++++++-------------------- 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/include/grub/util/install.h b/include/grub/util/install.h index 7eb6141..9b33368 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -53,12 +53,12 @@ void grub_util_bios_setup (const char *dir, const char *boot_file, const char *core_file, const char *dest, int force, - int fs_probe, int allow_floppy); + int fs_probe, int allow_floppy, int no_rs_codes); void grub_util_sparc_setup (const char *dir, const char *boot_file, const char *core_file, const char *dest, int force, - int fs_probe, int allow_floppy); + int fs_probe, int allow_floppy, int no_rs_codes); char * grub_install_get_image_targets_string (void); diff --git a/util/grub-install.in b/util/grub-install.in index 7cd089b..79d103f 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -87,6 +87,7 @@ usage () { print_option_help "--removable" "$(gettext "the installation device is removable. This option is only available on EFI.")" print_option_help "--bootloader-id=$(gettext "ID")" "$(gettext "the ID of bootloader. This option is only available on EFI.")" print_option_help "--efi-directory=$(gettext "DIR")" "$(gettext "use DIR as the EFI System Partition root.")" + print_option_help "--no-rs-codes" "$(gettext "Do not apply any reed-solomon codes, even if there is enough space.")" echo gettext "INSTALL_DEVICE must be system device filename.";echo echo @@ -100,6 +101,7 @@ gettext "Report bugs to ."; echo allow_floppy="" force_file_id= efidir= +no_rs_codes="" # Check the arguments. while test $# -gt 0 @@ -199,6 +201,9 @@ do --no-nvram) update_nvram=no ;; + --no-rs-codes) + no_rs_codes="--no-rs-codes" ;; + # This is an undocumented feature... --debug) debug=yes ;; @@ -680,7 +685,7 @@ fi # Perform the grub_modinfo_platform-dependent install if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ] ; then # Now perform the installation. - "$grub_setup" ${allow_floppy} ${setup_verbose} ${setup_force} --directory="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform" \ + "$grub_setup" ${allow_floppy} ${setup_verbose} ${setup_force} ${no_rs_codes} --directory="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform" \ --device-map="${device_map}" "${install_device}" || exit 1 elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-ieee1275" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "powerpc-ieee1275" ]; then diff --git a/util/grub-setup.c b/util/grub-setup.c index 90b9de0..088efcf 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -83,6 +83,10 @@ static struct argp_option options[] = { likely to make the install unbootable from HDD. */ N_("make the drive also bootable as floppy (default for fdX devices). May break on some BIOSes."), 0}, + {"no-rs-codes", 'n', 0, 0, + N_("Do not apply any reed-solomon codes, even if there is enough space."), 0}, + + { 0, 0, 0, 0, 0, 0 } }; @@ -118,6 +122,7 @@ struct arguments int fs_probe; int allow_floppy; char *device; + int no_rs_codes; }; static error_t @@ -173,6 +178,10 @@ argp_parser (int key, char *arg, struct argp_state *state) verbosity++; break; + case 'n': + arguments->no_rs_codes = 1; + break; + case ARGP_KEY_ARG: if (state->arg_num == 0) arguments->device = xstrdup(arg); @@ -292,7 +301,8 @@ main (int argc, char *argv[]) arguments.boot_file ? : DEFAULT_BOOT_FILE, arguments.core_file ? : DEFAULT_CORE_FILE, dest_dev, arguments.force, - arguments.fs_probe, arguments.allow_floppy); + arguments.fs_probe, arguments.allow_floppy, + arguments.no_rs_codes); /* Free resources. */ grub_fini_all (); diff --git a/util/setup.c b/util/setup.c index 337c304..b60a109 100644 --- a/util/setup.c +++ b/util/setup.c @@ -248,7 +248,7 @@ void SETUP (const char *dir, const char *boot_file, const char *core_file, const char *dest, int force, - int fs_probe, int allow_floppy) + int fs_probe, int allow_floppy, int no_rs_codes) { char *core_path; char *boot_img, *core_img, *boot_path; @@ -486,7 +486,11 @@ SETUP (const char *dir, nsec = core_sectors; - maxsec = 2 * core_sectors; + if (!no_rs_codes) + maxsec = 2 * core_sectors; + else + maxsec = core_sectors; + if (maxsec > ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR) >> GRUB_DISK_SECTOR_BITS)) maxsec = ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR) @@ -547,27 +551,29 @@ SETUP (const char *dir, bl.first_block = (struct grub_boot_blocklist *) (core_img + GRUB_DISK_SECTOR_SIZE - sizeof (*bl.block)); - - grub_size_t no_rs_length; - grub_set_unaligned32 ((core_img + GRUB_DISK_SECTOR_SIZE - + GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY), - grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size)); - no_rs_length = grub_target_to_host16 - (grub_get_unaligned16 (core_img - + GRUB_DISK_SECTOR_SIZE - + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH)); - - if (no_rs_length == 0xffff) - grub_util_error ("%s", _("core.img version mismatch")); - - void *tmp = xmalloc (core_size); - grub_memcpy (tmp, core_img, core_size); - grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE, - core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE, - nsec * GRUB_DISK_SECTOR_SIZE - - core_size); - assert (grub_memcmp (tmp, core_img, core_size) == 0); - free (tmp); + if (!no_rs_codes) + { + grub_size_t no_rs_length; + grub_set_unaligned32 ((core_img + GRUB_DISK_SECTOR_SIZE + + GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY), + grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size)); + no_rs_length = grub_target_to_host16 + (grub_get_unaligned16 (core_img + + GRUB_DISK_SECTOR_SIZE + + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH)); + + if (no_rs_length == 0xffff) + grub_util_error ("%s", _("core.img version mismatch")); + + void *tmp = xmalloc (core_size); + grub_memcpy (tmp, core_img, core_size); + grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE, + core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE, + nsec * GRUB_DISK_SECTOR_SIZE + - core_size); + assert (grub_memcmp (tmp, core_img, core_size) == 0); + free (tmp); + } /* Write the core image onto the disk. */ for (i = 0; i < nsec; i++) @@ -762,4 +768,3 @@ unable_to_embed: grub_device_close (dest_dev); grub_device_close (root_dev); } - -- 1.8.4.1