SHA256
1
0
forked from pool/grub2

Accepting request 295632 from home:michael-chang:sle-12-merge

- Merge changes from SLE12
- Do not pass root= when root is on nfs (bnc#894374) 
  * modified grub2-pass-corret-root-for-nfsroot.patch
  * modified grub2-secureboot-provide-linuxefi-config.patch
  * modified grub2-secureboot-use-linuxefi-on-uefi.patch
- Fix xen pvops kernel not appear on menu (bnc#895286)
  * modified grub2-fix-menu-in-xen-host-server.patch 
- Workaround grub2-once (bnc#892358)
  * added grub2-btrfs-workaround-grub2-once.patch
  * added grub2-once.service
  * modified grub2-once
- Fix busy-loop and hang while network booting (bnc#870613)
  * added grub2-netboot-hang.patch
- Add warning in grubenv file about editing it directly (bnc#887008)
  * added grub2-editenv-add-warning-message.patch
- Fix broken graphics with efifb on QEMU/KVM and nomodeset (bnc#884558)
  * added grub2-efi-disable-video-cirrus-and-bochus.patch 
- Disable video support on Power (bnc#877142) 
  * added grub2-ppc64le-disable-video.patch
- Track occupied memory so it can be released on exit (bnc#885026)
  * added grub2-ppc64le-memory-map.patch
- Fix grub.xen config searching path on boot partition (bnc#884828)
- Add linux16 and initrd16 to grub.xen (bnc#884830)
  * added grub2-xen-linux16.patch
- VLAN tag support (fate#315753)
  * added 0001-Add-bootargs-parser-for-open-firmware.patch
  * added 0002-Add-Virtual-LAN-support.patch
- Use chainloader to boot xen.efi under UEFI (bnc#871857)
  * added grub2-efi-xen-chainload.patch
- Use device part of chainloader target, if present (bnc#871857)

OBS-URL: https://build.opensuse.org/request/show/295632
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=148
This commit is contained in:
Andrei Borzenkov 2015-04-13 17:58:16 +00:00 committed by Git OBS Bridge
parent cc058dfd41
commit 9bc71d03db
33 changed files with 4312 additions and 154 deletions

View File

@ -0,0 +1,372 @@
From 0787fba15352ef47958e0c9fcc912b8bbcf8ab4e Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Mon, 30 Jun 2014 10:31:59 -0300
Subject: [PATCH 1/2] Add bootargs parser for open firmware.
It enables net boot even when there is no bootp/dhcp server.
---
ChangeLog | 16 +++++
grub-core/kern/ieee1275/init.c | 7 +--
grub-core/net/bootp.c | 63 +++++--------------
grub-core/net/drivers/ieee1275/ofnet.c | 107 ++++++++++++++++++++++++++++++++-
grub-core/net/net.c | 38 ++++++++++++
include/grub/ieee1275/ieee1275.h | 3 +-
include/grub/net.h | 4 ++
7 files changed, 185 insertions(+), 53 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 41bcebf..a659369 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2014-01-24 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ Add bootargs parser for open firmware.
+
+ It enables net boot even when there is no bootp/dhcp server.
+
+ * grub-core/net/drivers/ieee1275/ofnet.c: Add grub_ieee1275_parse_bootargs
+ and call it at grub_ieee1275_net_config_real.
+
+2013-12-23 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ Add grub_env_set_net_property function.
+
+ * grub-core/net/bootp.c: Remove set_env_limn_ro.
+ * grub-core/net/net.c: Add grub_env_set_net_property.
+
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Set version to 2.02~beta2.
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index 89b2822..d5bd74d 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -80,9 +80,8 @@ grub_translate_ieee1275_path (char *filepath)
}
}
-void (*grub_ieee1275_net_config) (const char *dev,
- char **device,
- char **path);
+void (*grub_ieee1275_net_config) (const char *dev, char **device, char **path,
+ char *bootpath);
void
grub_machine_get_bootlocation (char **device, char **path)
{
@@ -126,7 +125,7 @@ grub_machine_get_bootlocation (char **device, char **path)
*ptr = 0;
if (grub_ieee1275_net_config)
- grub_ieee1275_net_config (canon, device, path);
+ grub_ieee1275_net_config (canon, device, path, bootpath);
grub_free (dev);
grub_free (canon);
}
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index c14e9de..6310ed4 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -25,41 +25,6 @@
#include <grub/net/udp.h>
#include <grub/datetime.h>
-static char *
-grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)),
- const char *val __attribute__ ((unused)))
-{
- return NULL;
-}
-
-static void
-set_env_limn_ro (const char *intername, const char *suffix,
- const char *value, grub_size_t len)
-{
- char *varname, *varvalue;
- char *ptr;
- varname = grub_xasprintf ("net_%s_%s", intername, suffix);
- if (!varname)
- return;
- for (ptr = varname; *ptr; ptr++)
- if (*ptr == ':')
- *ptr = '_';
- varvalue = grub_malloc (len + 1);
- if (!varvalue)
- {
- grub_free (varname);
- return;
- }
-
- grub_memcpy (varvalue, value, len);
- varvalue[len] = 0;
- grub_env_set (varname, varvalue);
- grub_register_variable_hook (varname, 0, grub_env_write_readonly);
- grub_env_export (varname);
- grub_free (varname);
- grub_free (varvalue);
-}
-
static void
parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask)
{
@@ -136,20 +101,24 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask)
}
continue;
case GRUB_NET_BOOTP_HOSTNAME:
- set_env_limn_ro (name, "hostname", (const char *) ptr, taglength);
- break;
+ grub_env_set_net_property (name, "hostname", (const char *) ptr,
+ taglength);
+ break;
case GRUB_NET_BOOTP_DOMAIN:
- set_env_limn_ro (name, "domain", (const char *) ptr, taglength);
- break;
+ grub_env_set_net_property (name, "domain", (const char *) ptr,
+ taglength);
+ break;
case GRUB_NET_BOOTP_ROOT_PATH:
- set_env_limn_ro (name, "rootpath", (const char *) ptr, taglength);
- break;
+ grub_env_set_net_property (name, "rootpath", (const char *) ptr,
+ taglength);
+ break;
case GRUB_NET_BOOTP_EXTENSIONS_PATH:
- set_env_limn_ro (name, "extensionspath", (const char *) ptr, taglength);
- break;
+ grub_env_set_net_property (name, "extensionspath", (const char *) ptr,
+ taglength);
+ break;
/* If you need any other options please contact GRUB
development team. */
@@ -211,8 +180,8 @@ grub_net_configure_by_dhcp_ack (const char *name,
}
if (size > OFFSET_OF (boot_file, bp))
- set_env_limn_ro (name, "boot_file", (char *) bp->boot_file,
- sizeof (bp->boot_file));
+ grub_env_set_net_property (name, "boot_file", bp->boot_file,
+ sizeof (bp->boot_file));
if (is_def)
grub_net_default_server = 0;
if (is_def && !grub_net_default_server && bp->server_ip)
@@ -243,8 +212,8 @@ grub_net_configure_by_dhcp_ack (const char *name,
if (size > OFFSET_OF (server_name, bp)
&& bp->server_name[0])
{
- set_env_limn_ro (name, "dhcp_server_name", (char *) bp->server_name,
- sizeof (bp->server_name));
+ grub_env_set_net_property (name, "dhcp_server_name", bp->server_name,
+ sizeof (bp->server_name));
if (is_def && !grub_net_default_server)
{
grub_net_default_server = grub_strdup (bp->server_name);
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
index ceb5931..a079065 100644
--- a/grub-core/net/drivers/ieee1275/ofnet.c
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
@@ -127,8 +127,111 @@ bootp_response_properties[] =
{ .name = "bootpreply-packet", .offset = 0x2a},
};
+enum
+{
+ BOOTARGS_SERVER_ADDR,
+ BOOTARGS_FILENAME,
+ BOOTARGS_CLIENT_ADDR,
+ BOOTARGS_GATEWAY_ADDR,
+ BOOTARGS_BOOTP_RETRIES,
+ BOOTARGS_TFTP_RETRIES,
+ BOOTARGS_SUBNET_MASK,
+ BOOTARGS_BLOCKSIZE
+};
+
+static int
+grub_ieee1275_parse_bootargs (const char *devpath, char *bootpath,
+ char **device, struct grub_net_card **card)
+{
+ char *args;
+ char *comma_char = 0;
+ char *equal_char = 0;
+ grub_size_t field_counter = 0;
+
+ grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask;
+ grub_net_link_level_address_t hw_addr;
+ grub_net_interface_flags_t flags = 0;
+ struct grub_net_network_level_interface *inter;
+
+ hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+
+ args = bootpath + grub_strlen (devpath) + 1;
+ do
+ {
+ comma_char = grub_strchr (args, ',');
+ if (comma_char != 0)
+ *comma_char = 0;
+
+ /* Check if it's an option (like speed=auto) and not a default parameter */
+ equal_char = grub_strchr (args, '=');
+ if (equal_char != 0)
+ {
+ *equal_char = 0;
+ grub_env_set_net_property ((*card)->name, args, equal_char + 1,
+ grub_strlen(equal_char + 1));
+ *equal_char = '=';
+ }
+ else
+ {
+ switch (field_counter++)
+ {
+ case BOOTARGS_SERVER_ADDR:
+ *device = grub_xasprintf ("tftp,%s", args);
+ if (!*device)
+ return grub_errno;
+ break;
+
+ case BOOTARGS_CLIENT_ADDR:
+ grub_net_resolve_address (args, &client_addr);
+ break;
+
+ case BOOTARGS_GATEWAY_ADDR:
+ grub_net_resolve_address (args, &gateway_addr);
+ break;
+
+ case BOOTARGS_SUBNET_MASK:
+ grub_net_resolve_address (args, &subnet_mask);
+ break;
+ }
+ }
+ args = comma_char + 1;
+ if (comma_char != 0)
+ *comma_char = ',';
+ } while (comma_char != 0);
+
+ if ((client_addr.ipv4 != 0) && (subnet_mask.ipv4 != 0))
+ {
+ grub_ieee1275_phandle_t devhandle;
+ grub_ieee1275_finddevice (devpath, &devhandle);
+ grub_ieee1275_get_property (devhandle, "mac-address",
+ hw_addr.mac, sizeof(hw_addr.mac), 0);
+ inter = grub_net_add_addr ((*card)->name, *card, &client_addr, &hw_addr,
+ flags);
+ grub_net_add_ipv4_local (inter,
+ __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4)));
+ }
+
+ if (gateway_addr.ipv4 != 0)
+ {
+ grub_net_network_level_netaddress_t target;
+ char *rname;
+
+ target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ target.ipv4.base = 0;
+ target.ipv4.masksize = 0;
+ rname = grub_xasprintf ("%s:default", ((*card)->name));
+ if (rname)
+ grub_net_add_route_gw (rname, target, gateway_addr);
+ else
+ return grub_errno;
+ }
+
+ return 0;
+}
+
static void
-grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
+grub_ieee1275_net_config_real (const char *devpath, char **device, char **path,
+ char *bootpath)
{
struct grub_net_card *card;
@@ -158,6 +261,8 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
}
grub_free (canon);
+ grub_ieee1275_parse_bootargs (devpath, bootpath, device, &card);
+
for (i = 0; i < ARRAY_SIZE (bootp_response_properties); i++)
if (grub_ieee1275_get_property_length (grub_ieee1275_chosen,
bootp_response_properties[i].name,
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index 0e57e93..8f9d183 100644
--- a/grub-core/net/net.c
+++ b/grub-core/net/net.c
@@ -1480,6 +1480,44 @@ receive_packets (struct grub_net_card *card, int *stop_condition)
grub_print_error ();
}
+static char *
+grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+grub_err_t
+grub_env_set_net_property (const char *intername, const char *suffix,
+ const char *value, grub_size_t len)
+{
+ char *varname, *varvalue;
+ char *ptr;
+
+ varname = grub_xasprintf ("net_%s_%s", intername, suffix);
+ if (!varname)
+ return grub_errno;
+ for (ptr = varname; *ptr; ptr++)
+ if (*ptr == ':')
+ *ptr = '_';
+ varvalue = grub_malloc (len + 1);
+ if (!varvalue)
+ {
+ grub_free (varname);
+ return grub_errno;
+ }
+
+ grub_memcpy (varvalue, value, len);
+ varvalue[len] = 0;
+ grub_err_t ret = grub_env_set (varname, varvalue);
+ grub_register_variable_hook (varname, 0, grub_env_write_readonly);
+ grub_env_export (varname);
+ grub_free (varname);
+ grub_free (varvalue);
+
+ return ret;
+}
+
void
grub_net_poll_cards (unsigned time, int *stop_condition)
{
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 7fefd16..f8b3d79 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -73,7 +73,8 @@ struct grub_ieee1275_devalias
extern void (*EXPORT_VAR(grub_ieee1275_net_config)) (const char *dev,
char **device,
- char **path);
+ char **path,
+ char *bootargs);
/* Maps a device alias to a pathname. */
extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen);
diff --git a/include/grub/net.h b/include/grub/net.h
index de6259e..843f74f 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -480,6 +480,10 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target,
void
grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str);
+grub_err_t
+grub_env_set_net_property (const char *intername, const char *suffix,
+ const char *value, grub_size_t len);
+
void
grub_net_poll_cards (unsigned time, int *stop_condition);
--
1.9.3

View File

@ -0,0 +1,387 @@
From d17c80ca8de35f8cb06175965d428bdabbda3c19 Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Mon, 30 Jun 2014 10:37:08 -0300
Subject: [PATCH 2/2] Add Virtual LAN support.
This patch adds support for virtual LAN (VLAN) tagging. VLAN tagging allows
multiple VLANs in a bridged network to share the same physical network link
but maintain isolation:
http://en.wikipedia.org/wiki/IEEE_802.1Q
---
ChangeLog | 17 ++++++++++++
grub-core/net/arp.c | 10 +++++--
grub-core/net/drivers/ieee1275/ofnet.c | 20 +++++++++++++-
grub-core/net/ethernet.c | 49 ++++++++++++++++++++++++++++++----
grub-core/net/ip.c | 31 ++++++++++++++-------
include/grub/net.h | 9 +++++++
include/grub/net/arp.h | 5 ++--
include/grub/net/ip.h | 3 ++-
8 files changed, 124 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a659369..188c882 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2014-02-04 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ Add Virtual LAN support.
+
+ This patch adds support for virtual LAN (VLAN) tagging. VLAN tagging allows
+ multiple VLANs in a bridged network to share the same physical network link
+ but maintain isolation:
+
+ http://en.wikipedia.org/wiki/IEEE_802.1Q
+
+ * grub-core/net/ethernet.c: Add check, get, and set vlan tag id.
+ * grub-core/net/drivers/ieee1275/ofnet.c: Get vlan tag id from bootargs.
+ * grub-core/net/arp.c: Add check.
+ * grub-core/net/ip.c: Likewise.
+ * include/grub/net/arp.h: Add vlantag attribute.
+ * include/grub/net/ip.h: Likewise.
+
2014-01-24 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Add bootargs parser for open firmware.
diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c
index e92c7e7..3a3ee29 100644
--- a/grub-core/net/arp.c
+++ b/grub-core/net/arp.c
@@ -121,8 +121,8 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf,
}
grub_err_t
-grub_net_arp_receive (struct grub_net_buff *nb,
- struct grub_net_card *card)
+grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card,
+ grub_uint16_t vlantag_vid)
{
struct arphdr *arp_header = (struct arphdr *) nb->data;
grub_uint8_t *sender_hardware_address;
@@ -157,6 +157,12 @@ grub_net_arp_receive (struct grub_net_buff *nb,
FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
{
+ /* Check vlantag id */
+ if (inf->card == card &&
+ ((inf->vlantag.set && vlantag_vid != inf->vlantag.vid) ||
+ (!inf->vlantag.set && vlantag_vid != 0)))
+ continue;
+
/* Am I the protocol address target? */
if (grub_net_addr_cmp (&inf->address, &target_addr) == 0
&& grub_be_to_cpu16 (arp_header->op) == ARP_REQUEST)
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
index a079065..2a4f27c 100644
--- a/grub-core/net/drivers/ieee1275/ofnet.c
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
@@ -147,11 +147,11 @@ grub_ieee1275_parse_bootargs (const char *devpath, char *bootpath,
char *comma_char = 0;
char *equal_char = 0;
grub_size_t field_counter = 0;
-
grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask;
grub_net_link_level_address_t hw_addr;
grub_net_interface_flags_t flags = 0;
struct grub_net_network_level_interface *inter;
+ grub_uint32_t vlantag = 0;
hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
@@ -169,6 +169,18 @@ grub_ieee1275_parse_bootargs (const char *devpath, char *bootpath,
*equal_char = 0;
grub_env_set_net_property ((*card)->name, args, equal_char + 1,
grub_strlen(equal_char + 1));
+
+ if ((grub_strcmp (args, "vtag") == 0) &&
+ (grub_strlen (equal_char + 1) > 4))
+ {
+ vlantag = grub_strtoul (equal_char + 1, 0, 16) & 0xffff;
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ vlantag = 0;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+
*equal_char = '=';
}
else
@@ -207,6 +219,12 @@ grub_ieee1275_parse_bootargs (const char *devpath, char *bootpath,
hw_addr.mac, sizeof(hw_addr.mac), 0);
inter = grub_net_add_addr ((*card)->name, *card, &client_addr, &hw_addr,
flags);
+ if (vlantag > 0)
+ {
+ inter->vlantag.set = 1;
+ inter->vlantag.vid = vlantag & 0xfff;
+ }
+
grub_net_add_ipv4_local (inter,
__builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4)));
}
diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c
index c397b1b..3a526b3 100644
--- a/grub-core/net/ethernet.c
+++ b/grub-core/net/ethernet.c
@@ -18,6 +18,7 @@
#include <grub/misc.h>
#include <grub/mm.h>
+#include <grub/env.h>
#include <grub/net/ethernet.h>
#include <grub/net/ip.h>
#include <grub/net/arp.h>
@@ -56,10 +57,16 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf,
{
struct etherhdr *eth;
grub_err_t err;
+ grub_uint8_t etherhdr_size;
- COMPILE_TIME_ASSERT (sizeof (*eth) < GRUB_NET_MAX_LINK_HEADER_SIZE);
+ etherhdr_size = sizeof (*eth);
+ COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE);
- err = grub_netbuff_push (nb, sizeof (*eth));
+ /* Increase ethernet header in case of vlantag */
+ if (inf->vlantag.set)
+ etherhdr_size += 4;
+
+ err = grub_netbuff_push (nb, etherhdr_size);
if (err)
return err;
eth = (struct etherhdr *) nb->data;
@@ -76,6 +83,21 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf,
return err;
inf->card->opened = 1;
}
+
+ /* Check and add a vlan-tag if needed. */
+ if (inf->vlantag.set)
+ {
+ grub_uint32_t vlantag;
+ vlantag = grub_cpu_to_be32 ((VLANTAG_IDENTIFIER << 16) | inf->vlantag.vid);
+
+ /* Move eth type to the right */
+ grub_memcpy ((char *) nb->data + etherhdr_size - 2,
+ (char *) nb->data + etherhdr_size - 6, 2);
+
+ /* Add the tag in the middle */
+ grub_memcpy ((char *) nb->data + etherhdr_size - 6, &vlantag, 4);
+ }
+
return inf->card->driver->send (inf->card, nb);
}
@@ -90,10 +112,26 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb,
grub_net_link_level_address_t hwaddress;
grub_net_link_level_address_t src_hwaddress;
grub_err_t err;
+ grub_uint8_t etherhdr_size = sizeof (*eth);
+ grub_uint16_t vlantag_vid = 0;
+
+ /* Check if a vlan-tag is present. If so, the ethernet header is 4 bytes */
+ /* longer than the original one. The vlantag id is extracted and the header */
+ /* is reseted to the original size. */
+ if (grub_get_unaligned16 (nb->data + etherhdr_size - 2) ==
+ grub_cpu_to_be16_compile_time (VLANTAG_IDENTIFIER))
+ {
+ vlantag_vid = grub_be_to_cpu16 (grub_get_unaligned16 (nb->data +
+ etherhdr_size)) & 0x1fff;
+ etherhdr_size += 4;
+ /* Move eth type to the original position */
+ grub_memcpy((char *) nb->data + etherhdr_size - 6,
+ (char *) nb->data + etherhdr_size - 2, 2);
+ }
eth = (struct etherhdr *) nb->data;
type = grub_be_to_cpu16 (eth->type);
- err = grub_netbuff_pull (nb, sizeof (*eth));
+ err = grub_netbuff_pull (nb, etherhdr_size);
if (err)
return err;
@@ -121,13 +159,14 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb,
{
/* ARP packet. */
case GRUB_NET_ETHERTYPE_ARP:
- grub_net_arp_receive (nb, card);
+ grub_net_arp_receive (nb, card, vlantag_vid);
grub_netbuff_free (nb);
return GRUB_ERR_NONE;
/* IP packet. */
case GRUB_NET_ETHERTYPE_IP:
case GRUB_NET_ETHERTYPE_IP6:
- return grub_net_recv_ip_packets (nb, card, &hwaddress, &src_hwaddress);
+ return grub_net_recv_ip_packets (nb, card, &hwaddress, &src_hwaddress,
+ vlantag_vid);
}
grub_netbuff_free (nb);
return GRUB_ERR_NONE;
diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c
index c6971f9..8041905 100644
--- a/grub-core/net/ip.c
+++ b/grub-core/net/ip.c
@@ -225,12 +225,13 @@ handle_dgram (struct grub_net_buff *nb,
grub_net_ip_protocol_t proto,
const grub_net_network_level_address_t *source,
const grub_net_network_level_address_t *dest,
+ grub_uint16_t vlantag_vid,
grub_uint8_t ttl)
{
struct grub_net_network_level_interface *inf = NULL;
grub_err_t err;
int multicast = 0;
-
+
/* DHCP needs special treatment since we don't know IP yet. */
{
struct udphdr *udph;
@@ -290,6 +291,13 @@ handle_dgram (struct grub_net_buff *nb,
&& grub_net_addr_cmp (&inf->address, dest) == 0
&& grub_net_hwaddr_cmp (&inf->hwaddress, hwaddress) == 0)
break;
+
+ /* Check vlantag id */
+ if (inf->card == card &&
+ ((inf->vlantag.set && vlantag_vid != inf->vlantag.vid) ||
+ (!inf->vlantag.set && vlantag_vid != 0)))
+ continue;
+
/* Solicited node multicast. */
if (inf->card == card
&& inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6
@@ -378,7 +386,8 @@ static grub_err_t
grub_net_recv_ip4_packets (struct grub_net_buff *nb,
struct grub_net_card *card,
const grub_net_link_level_address_t *hwaddress,
- const grub_net_link_level_address_t *src_hwaddress)
+ const grub_net_link_level_address_t *src_hwaddress,
+ grub_uint16_t vlantag_vid)
{
struct iphdr *iph = (struct iphdr *) nb->data;
grub_err_t err;
@@ -453,7 +462,7 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb,
dest.ipv4 = iph->dest;
return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol,
- &source, &dest, iph->ttl);
+ &source, &dest, vlantag_vid, iph->ttl);
}
for (prev = &reassembles, rsm = *prev; rsm; prev = &rsm->next, rsm = *prev)
@@ -589,7 +598,7 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb,
dest.ipv4 = dst;
return handle_dgram (ret, card, src_hwaddress,
- hwaddress, proto, &source, &dest,
+ hwaddress, proto, &source, &dest, vlantag_vid,
ttl);
}
}
@@ -644,7 +653,8 @@ static grub_err_t
grub_net_recv_ip6_packets (struct grub_net_buff *nb,
struct grub_net_card *card,
const grub_net_link_level_address_t *hwaddress,
- const grub_net_link_level_address_t *src_hwaddress)
+ const grub_net_link_level_address_t *src_hwaddress,
+ grub_uint16_t vlantag_vid)
{
struct ip6hdr *iph = (struct ip6hdr *) nb->data;
grub_err_t err;
@@ -695,21 +705,24 @@ grub_net_recv_ip6_packets (struct grub_net_buff *nb,
grub_memcpy (dest.ipv6, &iph->dest, sizeof (dest.ipv6));
return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol,
- &source, &dest, iph->ttl);
+ &source, &dest, vlantag_vid, iph->ttl);
}
grub_err_t
grub_net_recv_ip_packets (struct grub_net_buff *nb,
struct grub_net_card *card,
const grub_net_link_level_address_t *hwaddress,
- const grub_net_link_level_address_t *src_hwaddress)
+ const grub_net_link_level_address_t *src_hwaddress,
+ grub_uint16_t vlantag_vid)
{
struct iphdr *iph = (struct iphdr *) nb->data;
if ((iph->verhdrlen >> 4) == 4)
- return grub_net_recv_ip4_packets (nb, card, hwaddress, src_hwaddress);
+ return grub_net_recv_ip4_packets (nb, card, hwaddress, src_hwaddress,
+ vlantag_vid);
if ((iph->verhdrlen >> 4) == 6)
- return grub_net_recv_ip6_packets (nb, card, hwaddress, src_hwaddress);
+ return grub_net_recv_ip6_packets (nb, card, hwaddress, src_hwaddress,
+ vlantag_vid);
grub_dprintf ("net", "Bad IP version: %d\n", (iph->verhdrlen >> 4));
grub_netbuff_free (nb);
return GRUB_ERR_NONE;
diff --git a/include/grub/net.h b/include/grub/net.h
index 843f74f..db5f6b3 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -268,6 +268,12 @@ typedef struct grub_net
extern grub_net_t (*EXPORT_VAR (grub_net_open)) (const char *name);
+struct grub_net_vlantag
+{
+ grub_uint8_t set;
+ grub_uint16_t vid;
+};
+
struct grub_net_network_level_interface
{
struct grub_net_network_level_interface *next;
@@ -279,6 +285,7 @@ struct grub_net_network_level_interface
grub_net_interface_flags_t flags;
struct grub_net_bootp_packet *dhcp_ack;
grub_size_t dhcp_acklen;
+ struct grub_net_vlantag vlantag;
void *data;
};
@@ -537,4 +544,6 @@ extern char *grub_net_default_server;
#define GRUB_NET_TRIES 40
#define GRUB_NET_INTERVAL 400
+#define VLANTAG_IDENTIFIER 0x8100
+
#endif /* ! GRUB_NET_HEADER */
diff --git a/include/grub/net/arp.h b/include/grub/net/arp.h
index bb17036..56336b3 100644
--- a/include/grub/net/arp.h
+++ b/include/grub/net/arp.h
@@ -22,10 +22,11 @@
#include <grub/net.h>
extern grub_err_t grub_net_arp_receive (struct grub_net_buff *nb,
- struct grub_net_card *card);
+ struct grub_net_card *card,
+ grub_uint16_t vlantag_vid);
grub_err_t
grub_net_arp_send_request (struct grub_net_network_level_interface *inf,
- const grub_net_network_level_address_t *proto_addr);
+ const grub_net_network_level_address_t *proto_addr);
#endif
diff --git a/include/grub/net/ip.h b/include/grub/net/ip.h
index 7a8e614..e79dec9 100644
--- a/include/grub/net/ip.h
+++ b/include/grub/net/ip.h
@@ -48,7 +48,8 @@ grub_err_t
grub_net_recv_ip_packets (struct grub_net_buff *nb,
struct grub_net_card *card,
const grub_net_link_level_address_t *hwaddress,
- const grub_net_link_level_address_t *src_hwaddress);
+ const grub_net_link_level_address_t *src_hwaddress,
+ grub_uint16_t vlantag_vid);
grub_err_t
grub_net_send_ip_packet (struct grub_net_network_level_interface *inf,
--
1.9.3

59
README.ibm3215 Normal file
View File

@ -0,0 +1,59 @@
[Disclaimer: I do not know enough (by far) about the inner workings
and secrets of these printer-consoles, so please correct me/send advice,
if there are better solutions!]
On 3215/327x things are dramatically different from everywhere else.
You'll have to live with some severe limitations:
0. Interactivity is quite limited. You'll need to "blindly" type,
most of the time, to see the effect only on "submission" ([Enter]).
In edit and shell mode it's sometimes useful to insert underlines
just to see, where the curser (AKA "point") is. (BTW, 3270 is _much_
better at displaying/refreshing grub2 screens than 3215.)
1. No cursor-movement-, alt-, meta-, and control-keys (like [ESC]).
2. To work around the lack of control-keys, the "[^][C]-sends-interrupt"-
trick is extended to translate sequences of caret followed by character
to the respective control-character. In the following this sequence
of two keystrokes is referred to as '^c' instead of that somewhat balky
[^][C]. Thus an [ESC] keypress can be generated with '^[' ("caret"
followed by "opening square bracket").
3. If a caret itself is needed, send one on it's own (i.e. a solitary [^]
followed by [Enter] -- or use '^^'.
4. No '[Enter]', because it can't be avoided on *any* input.
5. If you still need one to arrive at the application, you may either
press '[Enter]' *twice* (one empty line, sort of) or add '^j' to your
input. In menu mode '^f' works as well (see below). But using "empty
lines" does now work very reliably, so explicit control sequences
are to be preferred. This has the additional advantage, that combined
sequences can be sent, e.g. to exit from 'grub2-emu' without doing
anything, you can simply type 'cexit^j' and submit that with [Enter].
Common Substitutes:
'^j'` => [Enter] "engage"
'^[' => [ESC] "abort" / return to previous "state"
'^i' => [TAB] try completion (in edit & shell mode)
Available Keys in Menu Mode:
'^a' first entry '^e' last entry
'^p' previous entry '^n' next entry
'^g' previous page '^c' next page
'^f' boot selected entry/enter sub-menu (same as '^j')
'e' edit selected entry 'c' enter grub-shell
Available Keys in Edit Mode:
'^p' previous line '^n' next line
'^b' backward char '^f' forward char
'^a' beginning of line '^e' end of line
'^h' backspace '^d' delete
'^k' kill (to end of) line '^y' yank
'^o' open line '^l' refresh screen
'^x' boot entry '^c' enter grub-shell
Availble Keys on Command Line Mode:
'^p' previous command '^n' next command (from history)
'^a' beginning of line '^e' end of line
'^b' backward char '^f' forward char
'^h' backspace '^d' delete
'^k' kill (to end of) line '^u' discard line
'^y' yank

View File

@ -70,7 +70,7 @@ Index: grub-2.02~beta2/util/grub-install.c
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/util/grub-install.c --- grub-2.02~beta2.orig/util/grub-install.c
+++ grub-2.02~beta2/util/grub-install.c +++ grub-2.02~beta2/util/grub-install.c
@@ -803,6 +803,8 @@ fill_core_services (const char *core_ser @@ -816,6 +816,8 @@ fill_core_services (const char *core_ser
free (sysv_plist); free (sysv_plist);
} }
@ -79,7 +79,7 @@ Index: grub-2.02~beta2/util/grub-install.c
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
@@ -836,6 +838,9 @@ main (int argc, char *argv[]) @@ -849,6 +851,9 @@ main (int argc, char *argv[])
grub_util_load_config (&config); grub_util_load_config (&config);
@ -89,7 +89,7 @@ Index: grub-2.02~beta2/util/grub-install.c
if (!bootloader_id && config.grub_distributor) if (!bootloader_id && config.grub_distributor)
{ {
char *ptr; char *ptr;
@@ -1305,6 +1310,16 @@ main (int argc, char *argv[]) @@ -1334,6 +1339,16 @@ main (int argc, char *argv[])
fprintf (load_cfg_f, "set debug='%s'\n", fprintf (load_cfg_f, "set debug='%s'\n",
debug_image); debug_image);
} }

View File

@ -51,8 +51,8 @@ Index: grub-2.02~beta2/util/grub.d/00_header.in
+elif [ -s \$prefix/grubenv ]; then +elif [ -s \$prefix/grubenv ]; then
load_env load_env
fi fi
EOF
@@ -356,3 +366,14 @@ fi @@ -367,3 +377,14 @@ fi
if [ "x${GRUB_BADRAM}" != "x" ] ; then if [ "x${GRUB_BADRAM}" != "x" ] ; then
echo "badram ${GRUB_BADRAM}" echo "badram ${GRUB_BADRAM}"
fi fi
@ -85,7 +85,7 @@ Index: grub-2.02~beta2/util/grub.d/10_linux.in
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/util/grub.d/10_linux.in --- grub-2.02~beta2.orig/util/grub.d/10_linux.in
+++ grub-2.02~beta2/util/grub.d/10_linux.in +++ grub-2.02~beta2/util/grub.d/10_linux.in
@@ -53,10 +53,14 @@ fi @@ -57,10 +57,14 @@ fi
case x"$GRUB_FS" in case x"$GRUB_FS" in
xbtrfs) xbtrfs)
@ -100,11 +100,25 @@ Index: grub-2.02~beta2/util/grub.d/10_linux.in
fi;; fi;;
xzfs) xzfs)
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
@@ -230,7 +234,12 @@ while [ "x$list" != "x" ] ; do
if [ $PLATFORM != "emu" ]; then
hotkey=0
else
- rel_dirname=$dirname
+ if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&
+ [ "x${GRUB_FS}" = "xbtrfs" ] ; then
+ rel_dirname="\${btrfs_subvol}$dirname"
+ else
+ rel_dirname="$dirname"
+ fi
fi
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
alt_version=`echo $version | sed -e "s,\.old$,,g"`
Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in --- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in
+++ grub-2.02~beta2/util/grub.d/20_linux_xen.in +++ grub-2.02~beta2/util/grub.d/20_linux_xen.in
@@ -67,10 +67,14 @@ fi @@ -71,10 +71,14 @@ fi
case x"$GRUB_FS" in case x"$GRUB_FS" in
xbtrfs) xbtrfs)

View File

@ -0,0 +1,463 @@
Index: grub-2.02~beta2/grub-core/kern/fs.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/kern/fs.c
+++ grub-2.02~beta2/grub-core/kern/fs.c
@@ -27,6 +27,7 @@
#include <grub/mm.h>
#include <grub/term.h>
#include <grub/i18n.h>
+#include <grub/partition.h>
grub_fs_t grub_fs_list = 0;
@@ -228,6 +229,13 @@ grub_fs_blocklist_read (grub_file_t file
size, buf) != GRUB_ERR_NONE)
return -1;
+ if (file->read_hook)
+ {
+ grub_disk_addr_t part_start;
+
+ part_start = grub_partition_get_start (file->device->disk->partition);
+ file->read_hook (p->offset + sector + part_start, (unsigned)offset, (unsigned)size, file->read_hook_data);
+ }
ret += size;
len -= size;
sector -= ((size + offset) >> GRUB_DISK_SECTOR_BITS);
Index: grub-2.02~beta2/util/grub-editenv.c
===================================================================
--- grub-2.02~beta2.orig/util/grub-editenv.c
+++ grub-2.02~beta2/util/grub-editenv.c
@@ -23,8 +23,10 @@
#include <grub/util/misc.h>
#include <grub/lib/envblk.h>
#include <grub/i18n.h>
-#include <grub/emu/hostfile.h>
+#include <grub/emu/hostdisk.h>
#include <grub/util/install.h>
+#include <grub/emu/getroot.h>
+#include <grub/fs.h>
#include <stdio.h>
#include <unistd.h>
@@ -120,6 +122,140 @@ block, use `rm %s'."),
NULL, help_filter, NULL
};
+struct fs_envblk_spec {
+ const char *fs_name;
+ int offset;
+ int size;
+} fs_envblk_spec[] = {
+ { "btrfs", 256 * 1024, GRUB_DISK_SECTOR_SIZE },
+ { NULL, 0, 0 }
+};
+
+struct fs_envblk {
+ struct fs_envblk_spec *spec;
+ const char *dev;
+};
+
+typedef struct fs_envblk_spec *fs_envblk_spec_t;
+typedef struct fs_envblk *fs_envblk_t;
+
+fs_envblk_t fs_envblk = NULL;
+
+static int
+read_envblk_fs (const char *varname, const char *value, void *hook_data)
+{
+ grub_envblk_t *p_envblk = (grub_envblk_t *)hook_data;
+
+ if (!p_envblk || !fs_envblk)
+ return 0;
+
+ if (strcmp (varname, "env_block") == 0)
+ {
+ int off, sz;
+ char *p;
+
+ off = strtol (value, &p, 10);
+ if (*p == '+')
+ sz = strtol (p+1, &p, 10);
+
+ if (*p == '\0')
+ {
+ FILE *fp;
+ char *buf;
+
+ off <<= GRUB_DISK_SECTOR_BITS;
+ sz <<= GRUB_DISK_SECTOR_BITS;
+
+ fp = grub_util_fopen (fs_envblk->dev, "rb");
+ if (! fp)
+ grub_util_error (_("cannot open `%s': %s"), fs_envblk->dev,
+ strerror (errno));
+
+
+ if (fseek (fp, off, SEEK_SET) < 0)
+ grub_util_error (_("cannot seek `%s': %s"), fs_envblk->dev,
+ strerror (errno));
+
+ buf = xmalloc (sz);
+ if ((fread (buf, 1, sz, fp)) != sz)
+ grub_util_error (_("cannot read `%s': %s"), fs_envblk->dev,
+ strerror (errno));
+
+ fclose (fp);
+
+ *p_envblk = grub_envblk_open (buf, sz);
+ }
+ }
+
+ return 0;
+}
+
+static void
+create_envblk_fs (void)
+{
+ FILE *fp;
+ char *buf;
+ const char *device;
+ int offset, size;
+
+ if (!fs_envblk)
+ return;
+
+ device = fs_envblk->dev;
+ offset = fs_envblk->spec->offset;
+ size = fs_envblk->spec->size;
+
+ fp = grub_util_fopen (device, "r+b");
+ if (! fp)
+ grub_util_error (_("cannot open `%s': %s"), device, strerror (errno));
+
+ buf = xmalloc (size);
+ memcpy (buf, GRUB_ENVBLK_SIGNATURE, sizeof (GRUB_ENVBLK_SIGNATURE) - 1);
+ memset (buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1, '#', size - sizeof (GRUB_ENVBLK_SIGNATURE) + 1);
+
+ if (fseek (fp, offset, SEEK_SET) < 0)
+ grub_util_error (_("cannot seek `%s': %s"), device, strerror (errno));
+
+ if (fwrite (buf, 1, size, fp) != size)
+ grub_util_error (_("cannot write to `%s': %s"), device, strerror (errno));
+
+ grub_util_file_sync (fp);
+ free (buf);
+ fclose (fp);
+}
+
+static grub_envblk_t
+open_envblk_fs (grub_envblk_t envblk)
+{
+ grub_envblk_t envblk_fs = NULL;
+ char *val;
+ int offset, size;
+
+ if (!fs_envblk)
+ return NULL;
+
+ offset = fs_envblk->spec->offset;
+ size = fs_envblk->spec->size;
+
+ grub_envblk_iterate (envblk, &envblk_fs, read_envblk_fs);
+
+ if (envblk_fs && grub_envblk_size (envblk_fs) == size)
+ return envblk_fs;
+
+ create_envblk_fs ();
+
+ offset = offset >> GRUB_DISK_SECTOR_BITS;
+ size = (size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS;
+
+ val = xasprintf ("%d+%d", offset, size);
+ if (! grub_envblk_set (envblk, "env_block", val))
+ grub_util_error ("%s", _("environment block too small"));
+ grub_envblk_iterate (envblk, &envblk_fs, read_envblk_fs);
+ free (val);
+
+ return envblk_fs;
+}
+
static grub_envblk_t
open_envblk_file (const char *name)
{
@@ -176,10 +312,17 @@ static void
list_variables (const char *name)
{
grub_envblk_t envblk;
+ grub_envblk_t envblk_fs = NULL;
envblk = open_envblk_file (name);
+ grub_envblk_iterate (envblk, &envblk_fs, read_envblk_fs);
grub_envblk_iterate (envblk, NULL, print_var);
grub_envblk_close (envblk);
+ if (envblk_fs)
+ {
+ grub_envblk_iterate (envblk_fs, NULL, print_var);
+ grub_envblk_close (envblk_fs);
+ }
}
static void
@@ -202,6 +345,38 @@ write_envblk (const char *name, grub_env
}
static void
+write_envblk_fs (grub_envblk_t envblk)
+{
+ FILE *fp;
+ const char *device;
+ int offset, size;
+
+ if (!fs_envblk)
+ return;
+
+ device = fs_envblk->dev;
+ offset = fs_envblk->spec->offset;
+ size = fs_envblk->spec->size;
+
+ if (grub_envblk_size (envblk) > size)
+ grub_util_error ("%s", _("environment block too small"));
+
+ fp = grub_util_fopen (device, "r+b");
+
+ if (! fp)
+ grub_util_error (_("cannot open `%s': %s"), device, strerror (errno));
+
+ if (fseek (fp, offset, SEEK_SET) < 0)
+ grub_util_error (_("cannot seek `%s': %s"), device, strerror (errno));
+
+ if (fwrite (grub_envblk_buffer (envblk), 1, grub_envblk_size (envblk), fp) != grub_envblk_size (envblk))
+ grub_util_error (_("cannot write to `%s': %s"), device, strerror (errno));
+
+ grub_util_file_sync (fp);
+ fclose (fp);
+}
+
+static void
set_variables (const char *name, int argc, char *argv[])
{
grub_envblk_t envblk;
@@ -217,8 +392,26 @@ set_variables (const char *name, int arg
*(p++) = 0;
- if (! grub_envblk_set (envblk, argv[0], p))
- grub_util_error ("%s", _("environment block too small"));
+ if (strcmp (argv[0], "next_entry") == 0 && fs_envblk)
+ {
+ grub_envblk_t envblk_fs;
+ envblk_fs = open_envblk_fs (envblk);
+ if (!envblk_fs)
+ grub_util_error ("%s", _("can't open fs environment block"));
+ if (! grub_envblk_set (envblk_fs, argv[0], p))
+ grub_util_error ("%s", _("environment block too small"));
+ write_envblk_fs (envblk_fs);
+ grub_envblk_close (envblk_fs);
+ }
+ else if (strcmp (argv[0], "env_block") == 0)
+ {
+ grub_util_warn ("can't set env_block as it's read-only");
+ }
+ else
+ {
+ if (! grub_envblk_set (envblk, argv[0], p))
+ grub_util_error ("%s", _("environment block too small"));
+ }
argc--;
argv++;
@@ -226,26 +419,147 @@ set_variables (const char *name, int arg
write_envblk (name, envblk);
grub_envblk_close (envblk);
+
}
static void
unset_variables (const char *name, int argc, char *argv[])
{
grub_envblk_t envblk;
+ grub_envblk_t envblk_fs;
envblk = open_envblk_file (name);
+
+ envblk_fs = NULL;
+ if (fs_envblk)
+ envblk_fs = open_envblk_fs (envblk);
+
while (argc)
{
grub_envblk_delete (envblk, argv[0]);
+ if (envblk_fs)
+ grub_envblk_delete (envblk_fs, argv[0]);
+
argc--;
argv++;
}
write_envblk (name, envblk);
grub_envblk_close (envblk);
+
+ if (envblk_fs)
+ {
+ write_envblk_fs (envblk_fs);
+ grub_envblk_close (envblk_fs);
+ }
+}
+
+int have_abstraction = 0;
+static void
+probe_abstraction (grub_disk_t disk)
+{
+ if (disk->partition == NULL)
+ grub_util_info ("no partition map found for %s", disk->name);
+
+ if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID ||
+ disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
+ {
+ have_abstraction = 1;
+ }
+}
+
+static fs_envblk_t
+probe_fs_envblk (fs_envblk_spec_t spec)
+{
+ char **grub_devices;
+ char **curdev, **curdrive;
+ size_t ndev = 0;
+ char **grub_drives;
+ grub_device_t grub_dev = NULL;
+ grub_fs_t grub_fs;
+ const char *fs_envblk_device;
+
+#ifdef __s390x__
+ return NULL;
+#endif
+
+ grub_util_biosdisk_init (DEFAULT_DEVICE_MAP);
+ grub_init_all ();
+
+ grub_devices = grub_guess_root_devices (DEFAULT_DIRECTORY);
+
+ if (!grub_devices || !grub_devices[0])
+ grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), DEFAULT_DIRECTORY);
+
+ fs_envblk_device = grub_devices[0];
+
+ for (curdev = grub_devices; *curdev; curdev++)
+ {
+ grub_util_pull_device (*curdev);
+ ndev++;
+ }
+
+ grub_drives = xmalloc (sizeof (grub_drives[0]) * (ndev + 1));
+
+ for (curdev = grub_devices, curdrive = grub_drives; *curdev; curdev++,
+ curdrive++)
+ {
+ *curdrive = grub_util_get_grub_dev (*curdev);
+ if (! *curdrive)
+ grub_util_error (_("cannot find a GRUB drive for %s. Check your device.map"),
+ *curdev);
+ }
+ *curdrive = 0;
+
+ grub_dev = grub_device_open (grub_drives[0]);
+ if (! grub_dev)
+ grub_util_error ("%s", grub_errmsg);
+
+ grub_fs = grub_fs_probe (grub_dev);
+ if (! grub_fs)
+ grub_util_error ("%s", grub_errmsg);
+
+ if (grub_dev->disk)
+ {
+ probe_abstraction (grub_dev->disk);
+ }
+ for (curdrive = grub_drives + 1; *curdrive; curdrive++)
+ {
+ grub_device_t dev = grub_device_open (*curdrive);
+ if (!dev)
+ continue;
+ if (dev->disk)
+ probe_abstraction (dev->disk);
+ grub_device_close (dev);
+ }
+
+ free (grub_drives);
+ grub_device_close (grub_dev);
+ grub_fini_all ();
+ grub_util_biosdisk_fini ();
+
+ fs_envblk_spec_t p;
+
+ for (p = spec; p->fs_name; p++)
+ {
+ if (strcmp (grub_fs->name, p->fs_name) == 0 && !have_abstraction)
+ {
+ if (p->offset % GRUB_DISK_SECTOR_SIZE == 0 &&
+ p->size % GRUB_DISK_SECTOR_SIZE == 0)
+ {
+ fs_envblk = xmalloc (sizeof (fs_envblk_t));
+ fs_envblk->spec = p;
+ fs_envblk->dev = strdup(fs_envblk_device);
+ return fs_envblk;
+ }
+ }
+ }
+
+ return NULL;
}
+
int
main (int argc, char *argv[])
{
@@ -277,6 +591,9 @@ main (int argc, char *argv[])
command = argv[curindex++];
}
+ if (strcmp (filename, DEFAULT_ENVBLK_PATH) == 0)
+ fs_envblk = probe_fs_envblk (fs_envblk_spec);
+
if (strcmp (command, "create") == 0)
grub_util_create_envblk_file (filename);
else if (strcmp (command, "list") == 0)
Index: grub-2.02~beta2/util/grub.d/00_header.in
===================================================================
--- grub-2.02~beta2.orig/util/grub.d/00_header.in
+++ grub-2.02~beta2/util/grub.d/00_header.in
@@ -46,6 +46,11 @@ cat << EOF
if [ -s \$prefix/grubenv ]; then
load_env
fi
+
+if [ "\${env_block}" ] ; then
+ load_env -f "\${env_block}"
+fi
+
EOF
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
cat <<EOF
@@ -55,6 +60,9 @@ elif [ "\${next_entry}" ] ; then
set default="\${next_entry}"
set next_entry=
save_env next_entry
+ if [ "\${env_block}" ] ; then
+ save_env -f "\${env_block}" next_entry
+ fi
set boot_once=true
else
set default="${GRUB_DEFAULT}"
@@ -66,6 +74,9 @@ if [ "\${next_entry}" ] ; then
set default="\${next_entry}"
set next_entry=
save_env next_entry
+ if [ "\${env_block}" ] ; then
+ save_env -f "\${env_block}" next_entry
+ fi
set boot_once=true
else
set default="${GRUB_DEFAULT}"

View File

@ -0,0 +1,36 @@
Index: grub-2.02~beta2/util/editenv.c
===================================================================
--- grub-2.02~beta2.orig/util/editenv.c
+++ grub-2.02~beta2/util/editenv.c
@@ -30,12 +30,14 @@
#include <string.h>
#define DEFAULT_ENVBLK_SIZE 1024
+#define GRUB_ENVBLK_MESSAGE "# WARNING: Do not edit this file other than by grub2-editenv\n"
void
grub_util_create_envblk_file (const char *name)
{
FILE *fp;
char *buf;
+ char *pbuf;
char *namenew;
buf = xmalloc (DEFAULT_ENVBLK_SIZE);
@@ -46,9 +48,13 @@ grub_util_create_envblk_file (const char
grub_util_error (_("cannot open `%s': %s"), namenew,
strerror (errno));
- memcpy (buf, GRUB_ENVBLK_SIGNATURE, sizeof (GRUB_ENVBLK_SIGNATURE) - 1);
- memset (buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1, '#',
- DEFAULT_ENVBLK_SIZE - sizeof (GRUB_ENVBLK_SIGNATURE) + 1);
+ pbuf = buf;
+ memcpy (pbuf, GRUB_ENVBLK_SIGNATURE, sizeof (GRUB_ENVBLK_SIGNATURE) - 1);
+ pbuf += sizeof (GRUB_ENVBLK_SIGNATURE) - 1;
+ memcpy (pbuf, GRUB_ENVBLK_MESSAGE, sizeof (GRUB_ENVBLK_MESSAGE) - 1);
+ pbuf += sizeof (GRUB_ENVBLK_MESSAGE) - 1;
+ memset (pbuf , '#',
+ DEFAULT_ENVBLK_SIZE - sizeof (GRUB_ENVBLK_SIGNATURE) - sizeof (GRUB_ENVBLK_MESSAGE) + 2);
if (fwrite (buf, 1, DEFAULT_ENVBLK_SIZE, fp) != DEFAULT_ENVBLK_SIZE)
grub_util_error (_("cannot write to `%s': %s"), namenew,

View File

@ -0,0 +1,39 @@
From: Raymund Will <rw@suse.com>
Subject: Use device part of chainloader target, if present.
References: bnc#871857, bnc#880177
Patch-Mainline: no
Otherwise chainloading is restricted to '$root', which might not even
be readable by EFI!
v1. use grub_file_get_device_name() to get device name
Signed-off-by: Michael Chang <mchang@suse.com>
---
grub-core/loader/efi/chainloader.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
Index: grub-2.02~beta2/grub-core/loader/efi/chainloader.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/loader/efi/chainloader.c
+++ grub-2.02~beta2/grub-core/loader/efi/chainloader.c
@@ -706,12 +706,16 @@ grub_cmd_chainloader (grub_command_t cmd
*(--p16) = 0;
}
+ grub_dprintf ("chain", "cmd='%s'\n", filename);
file = grub_file_open (filename);
if (! file)
goto fail;
- /* Get the root device's device path. */
- dev = grub_device_open (0);
+ /* Get the device path from filename. */
+ char *devname = grub_file_get_device_name (filename);
+ dev = grub_device_open (devname);
+ if (devname)
+ grub_free (devname);
if (! dev)
goto fail;

View File

@ -0,0 +1,35 @@
Index: grub-2.02~beta2/grub-core/Makefile.core.def
===================================================================
--- grub-2.02~beta2.orig/grub-core/Makefile.core.def
+++ grub-2.02~beta2/grub-core/Makefile.core.def
@@ -1921,13 +1921,13 @@ module = {
module = {
name = video_cirrus;
x86 = video/cirrus.c;
- enable = x86;
+ enable = x86_noefi;
};
module = {
name = video_bochs;
x86 = video/bochs.c;
- enable = x86;
+ enable = x86_noefi;
};
module = {
Index: grub-2.02~beta2/gentpl.py
===================================================================
--- grub-2.02~beta2.orig/gentpl.py
+++ grub-2.02~beta2/gentpl.py
@@ -80,6 +80,10 @@ GROUPS["fdt"] = [ "arm64_efi", "arm_uboo
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc")
+# x86 without efi
+GROUPS["x86_noefi"] = GROUPS["x86"][:]
+GROUPS["x86_noefi"].remove("i386_efi"); GROUPS["x86_noefi"].remove("x86_64_efi");
+
#
# Create platform => groups reverse map, where groups covering that
# platform are ordered by their sizes

View File

@ -0,0 +1,164 @@
From: Raymund Will <rw@suse.com>
Subject: Use chainloader to boot xen.efi under UEFI.
References: bnc#871857, bnc#879148
Patch-Mainline: no
As XEN on SLE12 is not multiboot2 ready, some very dirty hacking
is necessary to boot via xen.efi and separate configfile snippets
(as done in SLE11SP3 secureboot).
To that end said configfile snippets, xen efi-binaries, kernels and initrds
need to copied to the EFI system partition during 'grub2-mkconfig'!
V0:
- first, somewhat fragile version, without any sort of cleanup for ESP.
V1:
- add missing whitespace. (bnc879148)
V2:
- second, much less fragile version, using only one config file per
XEN hypervisor version with sections for different kernels, avoiding
useless duplicates for sym-linked hypervisors. and removing previously
installed files from ESP.
---
util/grub.d/20_linux_xen.in | 88 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 86 insertions(+), 2 deletions(-)
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -21,6 +21,8 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
+ME=$(basename $0)
+
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
export TEXTDOMAIN=@PACKAGE@
@@ -36,9 +38,11 @@ CLASS="--class gnu-linux --class gnu --c
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
+ os=linux
else
OS="${GRUB_DISTRIBUTOR}"
- CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
+ os="$(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1)"
+ CLASS="--class ${os} ${CLASS}"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but
@@ -81,6 +85,31 @@ esac
title_correction_code=
+if [ -d /sys/firmware/efi ]; then
+ is_efi=true
+ err_msg=""
+ efi_dir="/boot/efi/efi/${os}"
+ grub_dir=/boot/@PACKAGE@
+ xen_dir=/usr/lib64/efi
+ for d in $grub_dir $efi_dir $xen_dir; do
+ [ ! -d "$d" ] || continue
+ err_msg="${err_msg}$ME: Essential directory '$d' not found!\n"
+ done
+ if ! [ -d "$efi_dir" -a -d "$grub_dir" -a -d "$xen_dir" ]; then
+ err_msg="${err_msg}$ME: XEN configuration skipped!\n"
+ else
+ rm -f $grub_dir/xen*.cfg
+ if [ -s $efi_dir/grub.xen-files ]; then
+ for f in $(sort $efi_dir/grub.xen-files| uniq); do
+ rm -f $efi_dir/$f
+ done
+ : > $efi_dir/grub.xen-files
+ fi
+ fi
+else
+ is_efi=false
+fi
+
linux_entry ()
{
os="$1"
@@ -113,6 +142,40 @@ linux_entry ()
save_default_entry | grub_add_tab | sed "s/^/$submenu_indentation/"
fi
+ if $is_efi; then
+ xen_cfg=${xen_basename/.efi/.cfg}
+ if [ "$section_count" = 0 ]; then
+ cat <<-EOF > $grub_dir/$xen_cfg
+ # disclaimer
+ [global]
+ #default=
+ EOF
+ fi
+ section_count=$(expr $section_count + 1)
+ if [ x$type != xrecovery ] ; then
+ section="config.$section_count"
+ else
+ section="failsafe.$section_count"
+ fi
+ cat <<-EOF >> $grub_dir/$xen_cfg
+
+ [$section]
+ options=${xen_args}
+ kernel=${basename} root=${linux_root_device_thisversion} ${args}
+ ramdisk=${initrd}
+ EOF
+ message="$(gettext_printf "Loading Xen %s with Linux %s ..." ${xen_version} ${version})"
+ sed "s/^/$submenu_indentation/" <<-EOF
+ echo '$(echo "$message" | grub_quote)'
+ chainloader \$cmdpath/${xen_basename} ${xen_basename} $section
+ }
+ EOF
+ for f in ${grub_dir}/$xen_cfg ${xen_dir}/${xen_basename} ${rel_dirname}/${basename} ${rel_dirname}/${initrd}; do
+ cp --preserve=timestamps $f $efi_dir
+ echo $(basename $f) >> $efi_dir/grub.xen-files
+ done
+ return
+ fi
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
fi
@@ -220,6 +283,24 @@ while [ "x${xen_list}" != "x" ] ; do
xen_dirname=`dirname ${current_xen}`
rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
xen_version=`echo $xen_basename | sed -e "s,.gz$,,g;s,^xen-,,g"`
+ xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`
+ if $is_efi; then
+ xen_basename=${xen_basename/.gz/.efi}
+ if ! [ -f ${xen_dir}/${xen_basename} ]; then
+ echo "Skip missing hypervisor $xen_dir/$xen_basename" >&2
+ continue
+ elif [ -L ${xen_dir}/${xen_basename} ]; then
+ xen_target=$(basename $(readlink -e ${xen_dir}/${xen_basename}))
+ if [ -f ${efi_dir}/${xen_target} ]; then
+ echo "Skip duplicate $xen_dir/$xen_basename for $xen_target" >&2
+ continue
+ fi
+ elif [ -n "$err_msg" ]; then
+ break
+ fi
+ gettext_printf "Found hypervisor: %s\n" "$current_xen" >&2
+ section_count=0
+ fi
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
@@ -284,7 +365,6 @@ while [ "x${xen_list}" != "x" ] ; do
if [ x"$is_top_level" != xtrue ]; then
echo ' }'
fi
- xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`
done
# If at least one kernel was found, then we need to
@@ -294,3 +374,7 @@ if [ x"$is_top_level" != xtrue ]; then
fi
echo "$title_correction_code"
+
+if [ -n "$err_msg" ]; then
+ echo -en "$err_msg" >&2
+fi

View File

@ -21,10 +21,10 @@ Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in --- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in
+++ grub-2.02~beta2/util/grub.d/20_linux_xen.in +++ grub-2.02~beta2/util/grub.d/20_linux_xen.in
@@ -175,6 +175,16 @@ file_is_not_sym () { @@ -182,6 +182,16 @@ else
xen_list=`for i in /boot/xen*.gz; do
if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n "$i " ; fi if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n "$i " ; fi
done` done`
fi
+ +
+# bnc#774666 - Grub2 does not offer a Xen entry after installing hypervisor and tools +# bnc#774666 - Grub2 does not offer a Xen entry after installing hypervisor and tools
+# This is a workaround to the install sequence of xen-kernel and xen is unpredictable +# This is a workaround to the install sequence of xen-kernel and xen is unpredictable

View File

@ -14,6 +14,13 @@ grub2 menu is not well organized. We could see some issues on it.
- The -dbg xen hypervisor takes precedence over release version - The -dbg xen hypervisor takes precedence over release version
This patch fixes above three issues. This patch fixes above three issues.
v2:
References: bnc#877040
Create only hypervisor pointed by /boot/xen.gz symlink to not clutter
the menu with multiple versions and also not include -dbg. Use custom.cfg
if you need any other custom entries.
--- ---
util/grub-mkconfig_lib.in | 5 +++++ util/grub-mkconfig_lib.in | 5 +++++
util/grub.d/10_linux.in | 12 ++++++++++-- util/grub.d/10_linux.in | 12 ++++++++++--
@ -53,17 +60,26 @@ Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
CLASS="--class gnu-linux --class gnu --class os --class xen" CLASS="--class gnu-linux --class gnu --class os --class xen"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
@@ -165,7 +171,9 @@ file_is_not_sym () { @@ -165,9 +171,17 @@ file_is_not_sym () {
esac esac
} }
-xen_list=`for i in /boot/xen*; do -xen_list=`for i in /boot/xen*; do
+# bnc#877040 - Duplicate entries for boot menu created
+# only create /boot/xen.gz symlink boot entry
+if test -L /boot/xen.gz; then
+ xen_list=`readlink -f /boot/xen.gz`
+else
+ # bnc#757895 - Grub2 menu items incorrect when "Xen Virtual Machines Host Server" selected + # bnc#757895 - Grub2 menu items incorrect when "Xen Virtual Machines Host Server" selected
+ # wildcard expasion with correct suffix (.gz) for not generating many duplicated menu entries + # wildcard expasion with correct suffix (.gz) for not generating many duplicated menu entries
+ xen_list=`for i in /boot/xen*.gz; do + xen_list=`for i in /boot/xen*.gz; do
if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n "$i " ; fi if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n "$i " ; fi
done` - done`
+ done`
+fi
prepare_boot_cache= prepare_boot_cache=
boot_device_id=
Index: grub-2.02~beta2/util/grub.d/10_linux.in Index: grub-2.02~beta2/util/grub.d/10_linux.in
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/util/grub.d/10_linux.in --- grub-2.02~beta2.orig/util/grub.d/10_linux.in

View File

@ -0,0 +1,36 @@
From 9706066791b994a55fb2d3d532a86aa1fde2a457 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Thu, 3 Apr 2014 21:31:12 +0200
Subject: [PATCH] * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Support NVMe device names.
References: bnc#873132
---
Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/osdep/linux/getroot.c
+++ grub-2.02~beta2/grub-core/osdep/linux/getroot.c
@@ -883,6 +883,23 @@ grub_util_part_to_disk (const char *os_d
*pp = '\0';
return path;
}
+
+ /* If this is a NVMe device */
+ if ((strncmp ("nvme", p, 4) == 0) && p[4] >= '0' && p[4] <= '9')
+ {
+ char *pp = p + 4;
+ while (*pp >= '0' && *pp <= '9')
+ pp++;
+ if (*pp == 'n')
+ pp++;
+ while (*pp >= '0' && *pp <= '9')
+ pp++;
+ if (*pp == 'p')
+ *is_part = 1;
+ /* /dev/nvme[0-9]+n[0-9]+p[0-9]* */
+ *pp = '\0';
+ return path;
+ }
}
return path;

View File

@ -0,0 +1,68 @@
From: Michael Chang <mchang@suse.com>
Subject: treat mdadm ddf fakeraid as simple device
References: bnc#872360
Patch-Mainline: no
Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/osdep/linux/getroot.c
+++ grub-2.02~beta2/grub-core/osdep/linux/getroot.c
@@ -117,7 +117,7 @@ struct btrfs_ioctl_search_args {
struct btrfs_ioctl_fs_info_args)
static int
-grub_util_is_imsm (const char *os_dev);
+grub_util_is_imsm_or_ddf (const char *os_dev);
#define ESCAPED_PATH_MAX (4 * PATH_MAX)
@@ -603,10 +603,10 @@ out:
}
static int
-grub_util_is_imsm (const char *os_dev)
+grub_util_is_imsm_or_ddf (const char *os_dev)
{
int retry;
- int is_imsm = 0;
+ int is_imsm_or_ddf = 0;
int container_seen = 0;
const char *dev = os_dev;
@@ -667,10 +667,17 @@ grub_util_is_imsm (const char *os_dev)
if (strncmp (buf, "MD_METADATA=imsm",
sizeof ("MD_METADATA=imsm") - 1) == 0)
{
- is_imsm = 1;
+ is_imsm_or_ddf = 1;
grub_util_info ("%s is imsm", dev);
break;
}
+ if (strncmp (buf, "MD_METADATA=ddf",
+ sizeof ("MD_METADATA=ddf") - 1) == 0)
+ {
+ is_imsm_or_ddf = 1;
+ grub_util_info ("%s is ddf", dev);
+ break;
+ }
}
free (buf);
@@ -681,7 +688,7 @@ grub_util_is_imsm (const char *os_dev)
if (dev != os_dev)
free ((void *) dev);
- return is_imsm;
+ return is_imsm_or_ddf;
}
char *
@@ -1018,7 +1025,7 @@ grub_util_get_dev_abstraction_os (const
/* Check for RAID. */
if (!strncmp (os_dev, "/dev/md", 7) && ! grub_util_device_is_mapped (os_dev)
- && !grub_util_is_imsm (os_dev))
+ && !grub_util_is_imsm_or_ddf (os_dev))
return GRUB_DEV_ABSTRACTION_RAID;
return GRUB_DEV_ABSTRACTION_NONE;
}

View File

@ -1,7 +1,7 @@
Index: grub-2.00/util/grub.d/10_linux.in Index: grub-2.02~beta2/util/grub.d/10_linux.in
=================================================================== ===================================================================
--- grub-2.00.orig/util/grub.d/10_linux.in --- grub-2.02~beta2.orig/util/grub.d/10_linux.in
+++ grub-2.00/util/grub.d/10_linux.in +++ grub-2.02~beta2/util/grub.d/10_linux.in
@@ -31,7 +31,7 @@ CLASS="--class gnu-linux --class gnu --c @@ -31,7 +31,7 @@ CLASS="--class gnu-linux --class gnu --c
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux OS=GNU/Linux
@ -11,7 +11,7 @@ Index: grub-2.00/util/grub.d/10_linux.in
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
fi fi
@@ -135,7 +135,7 @@ linux_entry () @@ -129,7 +129,7 @@ linux_entry ()
message="$(gettext_printf "Loading Linux %s ..." ${version})" message="$(gettext_printf "Loading Linux %s ..." ${version})"
sed "s/^/$submenu_indentation/" << EOF sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)' echo '$(echo "$message" | grub_quote)'
@ -20,3 +20,25 @@ Index: grub-2.00/util/grub.d/10_linux.in
EOF EOF
if test -n "${initrd}" ; then if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated. # TRANSLATORS: ramdisk isn't identifier. Should be translated.
Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
===================================================================
--- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in
+++ grub-2.02~beta2/util/grub.d/20_linux_xen.in
@@ -31,7 +31,7 @@ CLASS="--class gnu-linux --class gnu --c
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
- OS="${GRUB_DISTRIBUTOR} GNU/Linux"
+ OS="${GRUB_DISTRIBUTOR}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
fi
@@ -122,7 +122,7 @@ linux_entry ()
fi
multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
echo '$(echo "$lmessage" | grub_quote)'
- module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
+ module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ${args}
EOF
if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated.

View File

@ -4,14 +4,11 @@ Index: grub-2.02~beta2/util/grub.d/10_linux.in
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/util/grub.d/10_linux.in --- grub-2.02~beta2.orig/util/grub.d/10_linux.in
+++ grub-2.02~beta2/util/grub.d/10_linux.in +++ grub-2.02~beta2/util/grub.d/10_linux.in
@@ -168,6 +168,10 @@ case "x$machine" in @@ -190,6 +190,7 @@ EOF
list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do machine=`uname -m`
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi case "$machine" in
done` ;; i?86 | x86_64) klist="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*" ;;
+ xaarch64) + xaarch64) klist="/boot/Image-* /Image-* /boot/kernel-*" ;;
+ list=`for i in /boot/Image-* /Image-* /boot/kernel-* ; do s390 | s390x) klist="/boot/image-* /boot/kernel-*" ;;
+ if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi *) klist="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* \
+ done` ;; /boot/kernel-*" ;;
*)
list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi

13
grub2-netboot-hang.patch Normal file
View File

@ -0,0 +1,13 @@
Index: grub-2.02~beta2/grub-core/net/net.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/net/net.c
+++ grub-2.02~beta2/grub-core/net/net.c
@@ -1453,7 +1453,7 @@ receive_packets (struct grub_net_card *c
}
card->opened = 1;
}
- while (1)
+ while (received < 100)
{
/* Maybe should be better have a fixed number of packets for each card
and just mark them as used and not used. */

View File

@ -32,6 +32,18 @@ sub parse_menuentry {
} }
} }
# Enable restore grubenv service (bnc#892358)
# Restore grubenv settings for booting default entry to workaround the grub2-once cannot
# work and function properly on lvm, md and s390.
sub enable_restore_grubenv_service {
my $systemctl="/usr/bin/systemctl";
if (-x $systemctl) {
system "$systemctl --no-reload enable grub2-once >/dev/null 2>&1";
}
}
$id_name = ""; $id_name = "";
if (@ARGV == 2 && ($ARGV[0] eq "--show-mapped")) { if (@ARGV == 2 && ($ARGV[0] eq "--show-mapped")) {
$show_mapped = 1; $show_mapped = 1;
@ -127,5 +139,6 @@ if ($show_mapped > 0) {
print $ret; print $ret;
} else { } else {
system "$grub2_reboot \"$name\""; system "$grub2_reboot \"$name\"";
enable_restore_grubenv_service;
} }

16
grub2-once.service Normal file
View File

@ -0,0 +1,16 @@
[Unit]
Description=Restore grubenv
DefaultDependencies=no
After=local-fs.target
Before=sysinit.target shutdown.target
Conflicts=shutdown.target
ConditionPathIsReadWrite=/boot/grub2/grubenv
[Service]
Type=oneshot
ExecStart=-/usr/bin/grub2-editenv /boot/grub2/grubenv unset next_entry
ExecStartPost=-/usr/bin/systemctl disable grub2-once.service
StandardOutput=syslog
[Install]
WantedBy=sysinit.target

View File

@ -19,7 +19,7 @@ Index: grub-2.02~beta2/util/grub-mkconfig.in
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/util/grub-mkconfig.in --- grub-2.02~beta2.orig/util/grub-mkconfig.in
+++ grub-2.02~beta2/util/grub-mkconfig.in +++ grub-2.02~beta2/util/grub-mkconfig.in
@@ -128,22 +128,42 @@ else @@ -128,22 +128,47 @@ else
exit 1 exit 1
fi fi
@ -28,26 +28,34 @@ Index: grub-2.02~beta2/util/grub-mkconfig.in
-GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true -GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
+probe_nfsroot_device () { +probe_nfsroot_device () {
+ while read line ; do + while read line ; do
+ set -- $line + part1=`echo $line | sed -e 's! - .*$!!'`
+ path=$5 + part2=`echo $line | sed -n -e 's! - \(.*\)$!\n\1!p' | sed 1d`
+ fstype=$8
+ device=$9
-# Device containing our /boot partition. Usually the same as GRUB_DEVICE. -# Device containing our /boot partition. Usually the same as GRUB_DEVICE.
-GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" -GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
-GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true -GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
+ set -- $part1
+ path=$5
+
+ set -- $part2
+ fstype=$1
+ device=$2
+
+ if [ "x${path}" = "x/" ] && + if [ "x${path}" = "x/" ] &&
+ [ "x${fstype}" = "xnfs" -o "x${fstype}" = "xnfs4" ] ; then + [ "x${fstype}" = "xnfs" -o "x${fstype}" = "xnfs4" ] ; then
+ echo "$device" + echo "${fstype}:$device"
+ return + return
+ fi + fi
+ done + done
+} </proc/self/mountinfo +} </proc/self/mountinfo
+ +
+NFSROOT_DEVICE="`probe_nfsroot_device`" +NFSROOT_DEVICE="`probe_nfsroot_device`"
+
-# Filesystem for the device containing our userland. Used for stuff like
-# choosing Hurd filesystem module.
-GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
+if [ "x${NFSROOT_DEVICE}" != "x" ]; then +if [ "x${NFSROOT_DEVICE}" != "x" ]; then
+ GRUB_DEVICE="$NFSROOT_DEVICE" + GRUB_DEVICE=""
+ GRUB_DEVICE_UUID="" + GRUB_DEVICE_UUID=""
+ GRUB_FS="unknown" + GRUB_FS="unknown"
+else +else
@ -55,12 +63,9 @@ Index: grub-2.02~beta2/util/grub-mkconfig.in
+ GRUB_DEVICE="`${grub_probe} --target=device /`" + GRUB_DEVICE="`${grub_probe} --target=device /`"
+ GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true + GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
-# Filesystem for the device containing our userland. Used for stuff like
-# choosing Hurd filesystem module.
-GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
-if [ x"$GRUB_FS" = xunknown ]; then -if [ x"$GRUB_FS" = xunknown ]; then
- GRUB_FS="$(stat -f --printf=%T / || echo unknown)" - GRUB_FS="$(stat -f --printf=%T / || echo unknown)"
+
+ if [ x"$GRUB_FS" = x ] || [ x"$GRUB_FS" = xunknown ]; then + if [ x"$GRUB_FS" = x ] || [ x"$GRUB_FS" = xunknown ]; then
+ GRUB_FS="$(stat -f --printf=%T / || echo unknown)" + GRUB_FS="$(stat -f --printf=%T / || echo unknown)"
+ fi + fi
@ -73,3 +78,54 @@ Index: grub-2.02~beta2/util/grub-mkconfig.in
if test -f ${sysconfdir}/default/grub ; then if test -f ${sysconfdir}/default/grub ; then
. ${sysconfdir}/default/grub . ${sysconfdir}/default/grub
fi fi
Index: grub-2.02~beta2/util/grub.d/10_linux.in
===================================================================
--- grub-2.02~beta2.orig/util/grub.d/10_linux.in
+++ grub-2.02~beta2/util/grub.d/10_linux.in
@@ -74,6 +74,12 @@ linux_entry ()
type="$3"
args="$4"
+ if [ -n "${linux_root_device_thisversion}" ]; then
+ root_device="root=${linux_root_device_thisversion}"
+ else
+ root_device=""
+ fi
+
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
@@ -129,7 +135,7 @@ linux_entry ()
message="$(gettext_printf "Loading Linux %s ..." ${version})"
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ${args}
+ linux ${rel_dirname}/${basename} ${root_device} ${args}
EOF
if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
===================================================================
--- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in
+++ grub-2.02~beta2/util/grub.d/20_linux_xen.in
@@ -89,6 +89,11 @@ linux_entry ()
type="$4"
args="$5"
xen_args="$6"
+ if [ -n "${linux_root_device_thisversion}" ]; then
+ root_device="root=${linux_root_device_thisversion}"
+ else
+ root_device=""
+ fi
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
@@ -128,7 +133,7 @@ linux_entry ()
fi
multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
echo '$(echo "$lmessage" | grub_quote)'
- module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ${args}
+ module ${rel_dirname}/${basename} placeholder ${root_device} ${args}
EOF
if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated.

View File

@ -0,0 +1,49 @@
Index: grub-2.02~beta2/grub-core/kern/ieee1275/cmain.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/kern/ieee1275/cmain.c
+++ grub-2.02~beta2/grub-core/kern/ieee1275/cmain.c
@@ -90,7 +90,10 @@ grub_ieee1275_find_options (void)
}
if (rc >= 0 && grub_strncmp (tmp, "IBM", 3) == 0)
- grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS);
+ {
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT);
+ }
/* Old Macs have no key repeat, newer ones have fully working one.
The ones inbetween when repeated key generates an escaoe sequence
Index: grub-2.02~beta2/grub-core/video/ieee1275.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/video/ieee1275.c
+++ grub-2.02~beta2/grub-core/video/ieee1275.c
@@ -351,9 +351,12 @@ static struct grub_video_adapter grub_vi
GRUB_MOD_INIT(ieee1275_fb)
{
- find_display ();
- if (display)
- grub_video_register (&grub_video_ieee1275_adapter);
+ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT))
+ {
+ find_display ();
+ if (display)
+ grub_video_register (&grub_video_ieee1275_adapter);
+ }
}
GRUB_MOD_FINI(ieee1275_fb)
Index: grub-2.02~beta2/include/grub/ieee1275/ieee1275.h
===================================================================
--- grub-2.02~beta2.orig/include/grub/ieee1275/ieee1275.h
+++ grub-2.02~beta2/include/grub/ieee1275/ieee1275.h
@@ -147,6 +147,8 @@ enum grub_ieee1275_flag
GRUB_IEEE1275_FLAG_BROKEN_REPEAT,
GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN,
+
+ GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT
};
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);

View File

@ -0,0 +1,84 @@
Index: grub-2.02~beta2/grub-core/kern/ieee1275/openfw.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/kern/ieee1275/openfw.c
+++ grub-2.02~beta2/grub-core/kern/ieee1275/openfw.c
@@ -302,6 +302,34 @@ grub_ieee1275_map (grub_addr_t phys, gru
return IEEE1275_VALUE(args.catch_result);
}
+/* Preallocate IEEE1275_MAX_MAP_RESOURCE map tracks to track the
+ * map regions allocated to us by the firmware. Cannot
+ * dynamically allocate them, since the heap is not set
+ * yet.
+ */
+struct grub_map_track grub_map_track[IEEE1275_MAX_MAP_RESOURCE];
+int grub_map_track_index=0;
+
+void
+grub_releasemap ()
+{
+ int i=0;
+ for (i=grub_map_track_index-1; i >= 0; i--)
+ grub_ieee1275_release(grub_map_track[i].addr, grub_map_track[i].size);
+ grub_map_track_index = 0;
+ return;
+}
+
+static void
+grub_track_map (grub_addr_t addr, grub_size_t size)
+{
+ if (grub_map_track_index >= IEEE1275_MAX_MAP_RESOURCE)
+ return;
+ grub_map_track[grub_map_track_index].addr = addr;
+ grub_map_track[grub_map_track_index++].size = size;
+ return;
+}
+
grub_err_t
grub_claimmap (grub_addr_t addr, grub_size_t size)
{
@@ -317,6 +345,7 @@ grub_claimmap (grub_addr_t addr, grub_si
return grub_errno;
}
+ grub_track_map (addr, size);
return GRUB_ERR_NONE;
}
Index: grub-2.02~beta2/include/grub/ieee1275/ieee1275.h
===================================================================
--- grub-2.02~beta2.orig/include/grub/ieee1275/ieee1275.h
+++ grub-2.02~beta2/include/grub/ieee1275/ieee1275.h
@@ -30,6 +30,12 @@ struct grub_ieee1275_mem_region
unsigned int size;
};
+#define IEEE1275_MAX_MAP_RESOURCE 10
+struct grub_map_track {
+ grub_addr_t addr;
+ grub_size_t size;
+};
+
#define IEEE1275_MAX_PROP_LEN 8192
#define IEEE1275_MAX_PATH_LEN 256
@@ -216,6 +222,7 @@ int EXPORT_FUNC(grub_ieee1275_millisecon
grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
+void EXPORT_FUNC(grub_releasemap) (void);
int
EXPORT_FUNC(grub_ieee1275_map) (grub_addr_t phys, grub_addr_t virt,
Index: grub-2.02~beta2/grub-core/kern/ieee1275/init.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/kern/ieee1275/init.c
+++ grub-2.02~beta2/grub-core/kern/ieee1275/init.c
@@ -62,6 +62,7 @@ grub_addr_t grub_ieee1275_original_stack
void
grub_exit (void)
{
+ grub_releasemap();
grub_ieee1275_exit ();
}

View File

@ -0,0 +1,326 @@
---
grub-core/Makefile.am | 1
grub-core/Makefile.core.def | 2
grub-core/kern/emu/main.c | 4
grub-core/kern/emu/misc.c | 18 ++++
grub-core/loader/emu/linux.c | 173 +++++++++++++++++++++++++++++++++++++++++++
include/grub/emu/exec.h | 4
include/grub/emu/hostfile.h | 3
include/grub/emu/misc.h | 3
8 files changed, 204 insertions(+), 4 deletions(-)
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1674,9 +1674,9 @@ module = {
arm = loader/arm/linux.c;
arm64 = loader/arm64/linux.c;
fdt = lib/fdt.c;
+ emu = loader/emu/linux.c;
common = loader/linux.c;
common = lib/cmdline.c;
- enable = noemu;
};
module = {
--- /dev/null
+++ b/grub-core/loader/emu/linux.c
@@ -0,0 +1,173 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/time.h>
+
+#include <grub/emu/exec.h>
+#include <grub/emu/hostfile.h>
+#include <grub/emu/misc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+
+static char *kernel_path;
+static char *initrd_path;
+static char *boot_cmdline;
+
+static grub_err_t
+grub_linux_boot (void)
+{
+ grub_err_t rc = GRUB_ERR_NONE;
+ char *initrd_param;
+ const char *kexec[] = { "kexec", "-l", kernel_path, boot_cmdline, NULL, NULL };
+ const char *systemctl[] = { "systemctl", "kexec", NULL };
+ int kexecute = grub_util_get_kexecute();
+
+ if (initrd_path) {
+ initrd_param = grub_xasprintf("--initrd=%s", initrd_path);
+ kexec[3] = initrd_param;
+ kexec[4] = boot_cmdline;
+ } else {
+ initrd_param = grub_xasprintf("%s", "");
+ //return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("initrd required!"));
+ }
+
+ grub_printf("%serforming 'kexec -l %s %s %s'\n",
+ (kexecute) ? "P" : "Not p",
+ kernel_path, initrd_param, boot_cmdline);
+
+ if (kexecute)
+ rc = grub_util_exec(kexec);
+
+ grub_free(initrd_param);
+
+ if (rc != GRUB_ERR_NONE) {
+ grub_error (rc, N_("Error trying to perform kexec load operation."));
+ grub_sleep (3);
+ return rc;
+ }
+ if (kexecute < 1)
+ grub_fatal (N_("Use '"PACKAGE"-emu --kexec' to force a system restart."));
+
+ grub_printf("Performing 'systemctl kexec' (%s) ",
+ (kexecute==1) ? "do-or-die" : "just-in-case");
+ rc = grub_util_exec (systemctl);
+
+ if (kexecute == 1)
+ grub_fatal (N_("Error trying to perform 'systemctl kexec'"));
+
+ /* need to check read-only root before resetting hard!? */
+ grub_printf("Performing 'kexec -e'");
+ kexec[1] = "-e";
+ kexec[2] = NULL;
+ rc = grub_util_exec(kexec);
+ if ( rc != GRUB_ERR_NONE )
+ grub_fatal (N_("Error trying to directly perform 'kexec -e'."));
+
+ return rc;
+}
+
+static grub_err_t
+grub_linux_unload (void)
+{
+ grub_dl_unref (my_mod);
+ if ( boot_cmdline != NULL )
+ grub_free (boot_cmdline);
+ boot_cmdline = NULL;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[])
+{
+ int i;
+ char *tempstr;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if ( !grub_util_is_regular(argv[0]) )
+ return grub_error(GRUB_ERR_FILE_NOT_FOUND, N_("Cannot find kernel file %s"), argv[0]);
+
+ if ( kernel_path != NULL )
+ grub_free(kernel_path);
+
+ kernel_path = grub_xasprintf("%s", argv[0]);
+
+ if ( boot_cmdline != NULL ) {
+ grub_free(boot_cmdline);
+ boot_cmdline = NULL;
+ }
+
+ if ( argc > 1 )
+ {
+ boot_cmdline = grub_xasprintf("--command-line=%s", argv[1]);
+ for ( i = 2; i < argc; i++ ) {
+ tempstr = grub_xasprintf("%s %s", boot_cmdline, argv[i]);
+ grub_free(boot_cmdline);
+ boot_cmdline = tempstr;
+ }
+ }
+
+ grub_loader_set (grub_linux_boot, grub_linux_unload, 0);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[])
+{
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if ( !grub_util_is_regular(argv[0]) )
+ return grub_error(GRUB_ERR_FILE_NOT_FOUND, N_("Cannot find initrd file %s"), argv[0]);
+
+ if ( initrd_path != NULL )
+ grub_free(initrd_path);
+
+ initrd_path = grub_xasprintf("%s", argv[0]);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd_linux, cmd_initrd;
+
+GRUB_MOD_INIT(linux)
+{
+ cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, N_("Load Linux."));
+ cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0, N_("Load initrd."));
+ my_mod = mod;
+ kernel_path = NULL;
+ initrd_path = NULL;
+ boot_cmdline = NULL;
+}
+
+GRUB_MOD_FINI(linux)
+{
+ grub_unregister_command (cmd_linux);
+ grub_unregister_command (cmd_initrd);
+}
--- a/include/grub/emu/hostfile.h
+++ b/include/grub/emu/hostfile.h
@@ -22,6 +22,7 @@
#include <grub/disk.h>
#include <grub/partition.h>
#include <sys/types.h>
+#include <grub/symbol.h>
#include <grub/osdep/hostfile.h>
int
@@ -29,7 +30,7 @@ grub_util_is_directory (const char *path
int
grub_util_is_special_file (const char *path);
int
-grub_util_is_regular (const char *path);
+EXPORT_FUNC(grub_util_is_regular) (const char *path);
char *
grub_util_path_concat (size_t n, ...);
--- a/include/grub/emu/exec.h
+++ b/include/grub/emu/exec.h
@@ -23,6 +23,8 @@
#include <stdarg.h>
#include <sys/types.h>
+#include <grub/symbol.h>
+
pid_t
grub_util_exec_pipe (const char *const *argv, int *fd);
pid_t
@@ -32,7 +34,7 @@ int
grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file,
const char *stdout_file, const char *stderr_file);
int
-grub_util_exec (const char *const *argv);
+EXPORT_FUNC(grub_util_exec) (const char *const *argv);
int
grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
const char *stdout_file);
--- a/grub-core/Makefile.am
+++ b/grub-core/Makefile.am
@@ -243,6 +243,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/inc
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostdisk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostfile.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/exec.h
if COND_GRUB_EMU_SDL
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h
endif
--- a/grub-core/kern/emu/main.c
+++ b/grub-core/kern/emu/main.c
@@ -95,6 +95,7 @@ static struct argp_option options[] = {
N_("use GRUB files in the directory DIR [default=%s]"), 0},
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
{"hold", 'H', N_("SECS"), OPTION_ARG_OPTIONAL, N_("wait until a debugger will attach"), 0},
+ {"kexec", 'X', 0, 0, N_("try the untryable."), 0},
{ 0, 0, 0, 0, 0, 0 }
};
@@ -148,6 +149,9 @@ argp_parser (int key, char *arg, struct
case 'v':
verbosity++;
break;
+ case 'X':
+ grub_util_set_kexecute();
+ break;
case ARGP_KEY_ARG:
{
--- a/grub-core/kern/emu/misc.c
+++ b/grub-core/kern/emu/misc.c
@@ -38,6 +38,7 @@
#include <grub/emu/misc.h>
int verbosity;
+int kexecute;
void
grub_util_warn (const char *fmt, ...)
@@ -81,7 +82,7 @@ grub_util_error (const char *fmt, ...)
vfprintf (stderr, fmt, ap);
va_end (ap);
fprintf (stderr, ".\n");
- exit (1);
+ grub_exit ();
}
void *
@@ -138,6 +139,9 @@ xasprintf (const char *fmt, ...)
void
grub_exit (void)
{
+#if defined (GRUB_KERNEL)
+ grub_reboot();
+#endif
exit (1);
}
@@ -150,3 +154,15 @@ grub_get_time_ms (void)
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
}
+
+void
+grub_util_set_kexecute(void)
+{
+ kexecute++;
+}
+
+int
+grub_util_get_kexecute(void)
+{
+ return kexecute;
+}
--- a/include/grub/emu/misc.h
+++ b/include/grub/emu/misc.h
@@ -59,6 +59,9 @@ void EXPORT_FUNC(grub_util_warn) (const
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2), noreturn));
+void EXPORT_FUNC(grub_util_set_kexecute) (void);
+int EXPORT_FUNC(grub_util_get_kexecute) (void) WARN_UNUSED_RESULT;
+
grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void);
extern char * canonicalize_file_name (const char *path);

View File

@ -0,0 +1,530 @@
Vn:
* recognize 'dev/sclp_line0' as 3215-look-alike. [bnc#876743]
Vn+1:
* revamp readkey_dumb().
Vn+2:
* support hotkeys on all line-mode terminals, not only 3215. [bnc#885668]
---
grub-core/kern/emu/main.c | 8 +
grub-core/normal/menu_text.c | 54 +++++++-
grub-core/normal/term.c | 2
grub-core/osdep/unix/emuconsole.c | 238 +++++++++++++++++++++++++++++++++++++-
include/grub/term.h | 4
5 files changed, 294 insertions(+), 12 deletions(-)
--- a/grub-core/osdep/unix/emuconsole.c
+++ b/grub-core/osdep/unix/emuconsole.c
@@ -39,17 +39,61 @@
#include <grub/emu/console.h>
+#include <stdio.h>
+#include <errno.h>
+
extern struct grub_terminfo_output_state grub_console_terminfo_output;
static int original_fl;
static int saved_orig;
static struct termios orig_tty;
static struct termios new_tty;
+static int console_mode = 0;
+
+#define MAX_LEN 1023
+#if defined(__s390x__)
+static int
+dummy (void)
+{
+ return 0;
+}
+#endif
+#if 0
+static char msg[MAX_LEN+1];
+static void
+dprint (int len)
+{
+ if (len < 0)
+ return;
+ if (len > MAX_LEN)
+ len = MAX_LEN;
+ write (2, msg, len);
+}
+#define dprintf(fmt, vargs...) dprint(snprintf(msg, MAX_LEN, fmt, ## vargs))
+#else
+#define dprintf(fmt, vargs...) {}
+#endif
static void
-put (struct grub_term_output *term __attribute__ ((unused)), const int c)
+put (struct grub_term_output *term, const int c)
{
char chr = c;
ssize_t actual;
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ if (term->flags & GRUB_TERM_DUMB) {
+ if (c == '\n') {
+ data->pos.y++;
+ data->pos.x = 0;
+ } else {
+ data->pos.x++;
+ }
+ if (0) {
+ if (c == ' ') chr = '_';
+ if (c == GRUB_TERM_BACKSPACE) chr = '{';
+ if (c == '\b') chr = '<';
+ }
+ }
actual = write (STDOUT_FILENO, &chr, 1);
if (actual < 1)
@@ -60,17 +104,152 @@ put (struct grub_term_output *term __att
}
static int
-readkey (struct grub_term_input *term __attribute__ ((unused)))
+readkey (struct grub_term_input *term)
{
grub_uint8_t c;
ssize_t actual;
+ fd_set readfds;
+ struct timeval timeout;
+ int sel;
+ FD_SET (0, &readfds);
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 500000;
+ if ((sel=select (1, &readfds, (fd_set *)0, (fd_set *)0, &timeout)) <= 0)
+ {
+ if (sel < 0 && errno == EINTR)
+ return 0x03; /* '^C' */
+ return -1;
+ }
+
actual = read (STDIN_FILENO, &c, 1);
if (actual > 0)
return c;
return -1;
}
+#define NO_KEY ((grub_uint8_t)-1)
+static int
+readkey_dumb (struct grub_term_input *term)
+{
+ grub_uint8_t c;
+ static grub_uint8_t p = NO_KEY;
+
+ c = readkey (term);
+ if (c == NO_KEY)
+ return -1;
+ if ((p == '^' || p == '\n') && c == '\n') /* solitary '^' or '\n'? */
+ {
+ c = p; /* use immediately! */
+ p = '\n';
+ }
+ else if ((c == '\n' || c == '^') && p != c) /* non-duplicate specials? */
+ {
+ p = c; /* remember! */
+ c = NO_KEY;
+ }
+ else if (p == '^')
+ {
+ if (c != '^')
+ c &= 0x1F;
+ p = NO_KEY;
+ }
+ else
+ p = c;
+ return c;
+}
+
+static void
+grub_dumb_putchar (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c)
+{
+ unsigned i;
+
+ /* For now, do not try to use a surrogate pair. */
+ if (c->base > 0xffff)
+ put (term, '?');
+ else
+ put (term, (c->base & 0xffff));
+
+ if (0) {
+ for (i = 0; i < c->ncomb; i++)
+ if (c->base < 0xffff)
+ put (term, grub_unicode_get_comb (c)[i].code);
+ }
+}
+
+static struct grub_term_coordinate
+grub_dumb_getxy (struct grub_term_output *term)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ dprintf ("<%d,%d>", data->pos.x, data->pos.y);
+ return data->pos;
+}
+
+static struct grub_term_coordinate
+grub_dumb_getwh (struct grub_term_output *term)
+{
+ static int once = 0;
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ if (!once++)
+ dprintf ("dumb_getwh: w=%d h=%d\n", data->size.x, data->size.y);
+ return data->size;
+}
+
+static void
+grub_dumb_gotoxy (struct grub_term_output *term,
+ struct grub_term_coordinate pos)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ if (pos.x > grub_term_width (term) || pos.y > grub_term_height (term))
+ {
+ grub_error (GRUB_ERR_BUG, "invalid point (%u,%u)", pos.x, pos.y);
+ return;
+ }
+
+ dprintf("goto(%d,%d)", pos.x, pos.y);
+ if (pos.x > (grub_term_width (term) - 4)) {
+ dprintf (" really?");
+ //return;
+ }
+
+ if (data->gotoxy)
+ {
+ int i;
+ dprintf ("data-gotoxy");
+ if (data->pos.y != pos.y) {
+ put (term, '\n');
+
+ for (i = 1; i < pos.x; i++ )
+ put (term, ' ');
+ }
+ }
+ else
+ {
+ int i = 0;
+ if (data->pos.y != pos.y || data->pos.x > pos.x) {
+ if (data->pos.y >= pos.y) data->pos.y = pos.y - 1;
+ if (pos.y - data->pos.y > 3) data->pos.y = pos.y - 2;
+ dprintf (" <%dnl>+%d", (pos.y - data->pos.y), pos.x);
+ for (i = data->pos.y; i < pos.y; i++ )
+ put (term, '\n');
+ }
+ for (i = data->pos.x; i < pos.x; i++ )
+ put (term, ' ');
+ dprintf ("#%d", i);
+ grub_dumb_getxy (term);
+ }
+
+ dprintf ("\n");
+ data->pos = pos;
+}
+
static grub_err_t
grub_console_init_input (struct grub_term_input *term)
{
@@ -105,7 +284,8 @@ static grub_err_t
grub_console_init_output (struct grub_term_output *term)
{
struct winsize size;
- if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &size) >= 0)
+ if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &size) >= 0 &&
+ size.ws_col > 0 && size.ws_row > 0)
{
grub_console_terminfo_output.size.x = size.ws_col;
grub_console_terminfo_output.size.y = size.ws_row;
@@ -115,6 +295,8 @@ grub_console_init_output (struct grub_te
grub_console_terminfo_output.size.x = 80;
grub_console_terminfo_output.size.y = 24;
}
+ if (console_mode == 3215)
+ grub_console_terminfo_output.size.x -= 1;
grub_terminfo_output_init (term);
@@ -161,24 +343,72 @@ static struct grub_term_output grub_cons
void
grub_console_init (void)
{
+#if ! defined(__s390x__)
const char *cs = nl_langinfo (CODESET);
if (cs && grub_strcasecmp (cs, "UTF-8"))
grub_console_term_output.flags = GRUB_TERM_CODE_TYPE_UTF8_LOGICAL;
else
grub_console_term_output.flags = GRUB_TERM_CODE_TYPE_ASCII;
+#else
+ char link[MAX_LEN+1];
+ ssize_t len = readlink ("/proc/self/fd/0", link, MAX_LEN);
+
+ if (len > 0)
+ link[len] = 0;
+ else
+ link[0] = 0;
+ if (grub_strncmp ("/dev/ttyS", link, 9) == 0 )
+ console_mode = 3215;
+ else if (grub_strncmp ("/dev/3270/tty", link, 13) == 0 )
+ console_mode = 3270;
+ else if (grub_strncmp ("/dev/sclp_line", link, 14) == 0 )
+ console_mode = 3215;
+ grub_console_term_output.flags = GRUB_TERM_CODE_TYPE_ASCII;
+ switch (console_mode)
+ {
+ case 3215:
+ grub_console_term_output.flags |= GRUB_TERM_DUMB;
+ /* FALLTHROUGH */
+ case 3270:
+ grub_console_term_output.flags |= GRUB_TERM_LINE;
+ grub_console_term_output.flags |= GRUB_TERM_NO_ECHO;
+ grub_console_terminfo_input.readkey = readkey_dumb;
+ break;
+ default:
+ break;
+ }
+#endif
+ if (grub_console_term_output.flags & GRUB_TERM_DUMB)
+ {
+ grub_console_term_output.putchar = grub_dumb_putchar,
+ grub_console_term_output.getxy = grub_dumb_getxy;
+ grub_console_term_output.getwh = grub_dumb_getwh;
+ grub_console_term_output.gotoxy = grub_dumb_gotoxy;
+ grub_console_term_output.cls = (void *) dummy;
+ grub_console_term_output.setcolorstate = (void *) dummy;
+ grub_console_term_output.setcursor = (void *) dummy;
+ grub_console_term_output.progress_update_divisor = GRUB_PROGRESS_NO_UPDATE;
+ }
grub_term_register_input ("console", &grub_console_term_input);
grub_term_register_output ("console", &grub_console_term_output);
grub_terminfo_init ();
- grub_terminfo_output_register (&grub_console_term_output, "vt100-color");
+ grub_terminfo_output_register (&grub_console_term_output,
+ (grub_console_term_output.flags & GRUB_TERM_DUMB) ? "dumb":"vt100-color");
}
void
grub_console_fini (void)
{
+ dprintf( "grub_console_fini: %d\n", grub_console_term_output.flags & GRUB_TERM_DUMB);
if (saved_orig)
{
fcntl (STDIN_FILENO, F_SETFL, original_fl);
tcsetattr(STDIN_FILENO, TCSANOW, &orig_tty);
}
+ if (!(grub_console_term_output.flags & GRUB_TERM_DUMB))
+ {
+ const char clear[] = { 0x1b, 'c', 0 };
+ write (STDOUT_FILENO, clear, 2);
+ }
saved_orig = 0;
}
--- a/grub-core/normal/menu_text.c
+++ b/grub-core/normal/menu_text.c
@@ -113,6 +113,7 @@ draw_border (struct grub_term_output *te
{
int i;
+ if (! (term->flags & GRUB_TERM_DUMB)) {
grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1,
@@ -142,7 +143,7 @@ draw_border (struct grub_term_output *te
grub_putcode (GRUB_UNICODE_CORNER_LR, term);
grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
-
+ }
grub_term_gotoxy (term,
(struct grub_term_coordinate) { geo->first_entry_x - 1,
(geo->first_entry_y - 1 + geo->num_entries
@@ -155,6 +156,15 @@ print_message (int nested, int edit, str
int ret = 0;
grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
+ if (edit && (term->flags & GRUB_TERM_LINE))
+ {
+ ret += grub_print_message_indented_real
+ (_("Minimum Emacs-like screen editing is supported. '^i' lists "
+ "completions. Type '^x' to boot, '^c' for a command-line "
+ "or '^[' to discard edits and return to the GRUB menu."),
+ STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
+ }
+ else
if (edit)
{
ret += grub_print_message_indented_real (_("Minimum Emacs-like screen editing is \
@@ -165,10 +175,15 @@ command-line or ESC to discard edits and
}
else
{
+#if defined(__s390x__hotkey)
+ ret += grub_print_message_indented_real
+ (_("Select a menu option by pressing the hotkey specified. "),
+ STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
+#else
char *msg_translated;
msg_translated = grub_xasprintf (_("Use the %C and %C keys to select which "
- "entry is highlighted."),
+ "entry is highlighted. "),
GRUB_UNICODE_UPARROW,
GRUB_UNICODE_DOWNARROW);
if (!msg_translated)
@@ -177,6 +192,7 @@ command-line or ESC to discard edits and
STANDARD_MARGIN, term, dry_run);
grub_free (msg_translated);
+#endif
if (nested)
{
@@ -211,6 +227,10 @@ print_entry (int y, int highlight, grub_
title = entry ? entry->title : "";
title_len = grub_strlen (title);
+
+ if ((data->term->flags & GRUB_TERM_DUMB) && title[0] == '\0')
+ return;
+
unicode_title = grub_malloc (title_len * sizeof (*unicode_title));
if (! unicode_title)
/* XXX How to show this error? */
@@ -244,6 +264,14 @@ print_entry (int y, int highlight, grub_
if (data->geo.num_entries > 1)
grub_putcode (highlight ? '*' : ' ', data->term);
+ if ((data->term->flags & GRUB_TERM_LINE) && title[0] != '\0') {
+ grub_putcode('(', data->term);
+ grub_putcode((entry && entry->hotkey >= '0' && entry->hotkey <= 'z') ?
+ entry->hotkey : ' ', data->term);
+ grub_putcode(')', data->term);
+ grub_putcode(' ', data->term);
+ }
+
grub_print_ucs4_menu (unicode_title,
unicode_title + len,
0,
@@ -413,6 +441,8 @@ grub_menu_init_page (int nested, int edi
grub_term_highlight_color = old_color_highlight;
geo->timeout_y = geo->first_entry_y + geo->num_entries
+ geo->border + empty_lines;
+ if (term->flags & GRUB_TERM_DUMB)
+ geo->timeout_y = 1;
if (bottom_message)
{
grub_term_gotoxy (term,
@@ -422,6 +452,8 @@ grub_menu_init_page (int nested, int edi
print_message (nested, edit, term, 0);
geo->timeout_y += msg_num_lines;
}
+ if (term->flags & GRUB_TERM_DUMB)
+ geo->timeout_y = 1;
geo->right_margin = grub_term_width (term)
- geo->first_entry_x
- geo->entry_width - 1;
@@ -433,12 +465,19 @@ menu_text_print_timeout (int timeout, vo
struct menu_viewer_data *data = dataptr;
char *msg_translated = 0;
- grub_term_gotoxy (data->term,
+ if (data->geo.timeout_y)
+ grub_term_gotoxy (data->term,
(struct grub_term_coordinate) { 0, data->geo.timeout_y });
+ if (data->term->flags & GRUB_TERM_DUMB)
+ {
+ if (! data->geo.timeout_y)
+ data->timeout_msg = TIMEOUT_TERSE;
+ data->geo.timeout_y = 0;
+ }
if (data->timeout_msg == TIMEOUT_TERSE
|| data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN)
- msg_translated = grub_xasprintf (_("%ds"), timeout);
+ msg_translated = grub_xasprintf (_(" %ds"), timeout);
else
msg_translated = grub_xasprintf (_("The highlighted entry will be executed automatically in %ds."), timeout);
if (!msg_translated)
@@ -468,6 +507,8 @@ menu_text_print_timeout (int timeout, vo
data->term);
grub_free (msg_translated);
+ if (data->term->flags & GRUB_TERM_DUMB)
+ return;
grub_term_gotoxy (data->term,
(struct grub_term_coordinate) {
grub_term_cursor_x (&data->geo),
@@ -495,7 +536,7 @@ menu_text_set_chosen_entry (int entry, v
data->first = entry;
complete_redraw = 1;
}
- if (complete_redraw)
+ if (complete_redraw || (data->term->flags & GRUB_TERM_DUMB))
print_entries (data->menu, data);
else
{
@@ -525,6 +566,9 @@ menu_text_clear_timeout (void *dataptr)
struct menu_viewer_data *data = dataptr;
int i;
+ if ((data->term->flags & GRUB_TERM_DUMB))
+ return;
+
for (i = 0; i < data->geo.timeout_lines;i++)
{
grub_term_gotoxy (data->term, (struct grub_term_coordinate) {
--- a/grub-core/normal/term.c
+++ b/grub-core/normal/term.c
@@ -981,7 +981,7 @@ grub_print_ucs4_menu (const grub_uint32_
{
print_ucs4_real (str, last_position, margin_left, margin_right,
term, 0, 0, 1, skip_lines, max_lines,
- contchar, 1, pos);
+ contchar, (term->flags & GRUB_TERM_DUMB)? 0 : 1, pos);
}
void
--- a/grub-core/kern/emu/main.c
+++ b/grub-core/kern/emu/main.c
@@ -174,6 +174,12 @@ static struct argp argp = {
NULL, help_filter, NULL
};
+void
+ignore (int num __attribute__ ((unused)))
+{
+ return;
+}
+
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
@@ -212,7 +218,7 @@ main (int argc, char *argv[])
sleep (1);
}
- signal (SIGINT, SIG_IGN);
+ signal (SIGINT, (sighandler_t) &ignore);
grub_console_init ();
grub_host_init ();
--- a/include/grub/term.h
+++ b/include/grub/term.h
@@ -99,8 +99,10 @@ grub_term_color_state;
#define GRUB_TERM_NO_EDIT (1 << 1)
/* Set when the terminal cannot do fancy things. */
#define GRUB_TERM_DUMB (1 << 2)
+/* Set when the terminal is line oriented. */
+#define GRUB_TERM_LINE (1 << 3)
/* Which encoding does terminal expect stream to be. */
-#define GRUB_TERM_CODE_TYPE_SHIFT 3
+#define GRUB_TERM_CODE_TYPE_SHIFT 4
#define GRUB_TERM_CODE_TYPE_MASK (7 << GRUB_TERM_CODE_TYPE_SHIFT)
/* Only ASCII characters accepted. */
#define GRUB_TERM_CODE_TYPE_ASCII (0 << GRUB_TERM_CODE_TYPE_SHIFT)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,146 @@
From: Raymund Will <rw@suse.com>
Subject: Enable grub2-mkconfig for s390x-emu
References: fate#314213, bnc#868909
Patch-Mainline: no
V2:
* omit subvolume-prefix for platform "emu"
V3:
* add 'conmode=' to command-line if GRUB_CONMODE exists. [bnc#868909]
V4:
* remove 's' from possible hot-keys for "bootable snapshots". [bnc#885668]
---
util/grub.d/10_linux.in | 63 ++++++++++++++++++++++++++++++++++++++----------
1 file changed, 51 insertions(+), 12 deletions(-)
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -51,6 +51,10 @@ else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
+if [ "x$GRUB_CONMODE" != "x" ]; then
+ GRUB_CMDLINE_LINUX="conmode=${GRUB_CONMODE} ${GRUB_CMDLINE_LINUX}"
+fi
+
case x"$GRUB_FS" in
xbtrfs)
rootsubvol="`make_system_path_relative_to_its_root /`"
@@ -67,6 +71,21 @@ esac
title_correction_code=
+hotkey=1
+incr_hotkey()
+{
+ [ -z "$hotkey" ] && return
+ expr $hotkey + 1
+}
+print_hotkey()
+{
+ keys="123456789abdfgijklmnoprtuvwyz"
+ if [ -z "$hotkey" ]||[ $hotkey -eq 0 ]||[ $hotkey -gt 30 ]; then
+ return
+ fi
+ echo "--hotkey=$(expr substr $keys $hotkey 1)"
+}
+
linux_entry ()
{
os="$1"
@@ -90,9 +109,11 @@ linux_entry ()
title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
fi
- echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
+ echo "menuentry '$(echo "$title" | grub_quote)' $(print_hotkey) ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
+ hotkey=$(incr_hotkey)
else
- echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
+ echo "menuentry '$(echo "$os" | grub_quote)' $(print_hotkey) ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
+ hotkey=$(incr_hotkey)
fi
if [ x$type != xrecovery ] ; then
save_default_entry | grub_add_tab
@@ -115,6 +136,7 @@ linux_entry ()
echo " insmod gzio" | sed "s/^/$submenu_indentation/"
+ if [ $PLATFORM != emu ]; then # 'search' does not work for now
if [ x$dirname = x/ ]; then
if [ -z "${prepare_root_cache}" ]; then
prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"
@@ -126,6 +148,7 @@ linux_entry ()
fi
printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
fi
+ fi
message="$(gettext_printf "Loading Linux %s ..." ${version})"
if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
sed "s/^/$submenu_indentation/" << EOF
@@ -159,16 +182,17 @@ EOF
}
machine=`uname -m`
-case "x$machine" in
- xi?86 | xx86_64)
- list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
- if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
- done` ;;
- *)
- list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
- if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
- done` ;;
+case "$machine" in
+ i?86 | x86_64) klist="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*" ;;
+ s390 | s390x) klist="/boot/image-* /boot/kernel-*" ;;
+ *) klist="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* \
+ /boot/kernel-*" ;;
esac
+list=`for i in $klist; do
+ if grub_file_is_not_garbage "$i" ; then
+ echo -n "$i " ;
+ fi
+ done`
case "$machine" in
i?86) GENKERNEL_ARCH="x86" ;;
@@ -178,6 +202,15 @@ case "$machine" in
*) GENKERNEL_ARCH="$machine" ;;
esac
+PLATFORM="native"
+if [ -d /sys/firmware/efi ]&&[ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
+ PLATFORM="efi"
+else
+ case "$machine" in
+ s390*) PLATFORM="emu" ;;
+ esac
+fi
+
prepare_boot_cache=
prepare_root_cache=
boot_device_id=
@@ -194,6 +227,11 @@ while [ "x$list" != "x" ] ; do
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
+ if [ $PLATFORM != "emu" ]; then
+ hotkey=0
+ else
+ rel_dirname=$dirname
+ fi
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
alt_version=`echo $version | sed -e "s,\.old$,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
@@ -278,7 +316,8 @@ while [ "x$list" != "x" ] ; do
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
# TRANSLATORS: %s is replaced with an OS name
- echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
+ echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' $(print_hotkey) \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
+ hotkey=$(incr_hotkey)
is_top_level=false
fi

View File

@ -25,11 +25,11 @@ has shim exported protocols available.
util/grub.d/10_linux.in | 4 ++-- util/grub.d/10_linux.in | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-) 2 files changed, 4 insertions(+), 3 deletions(-)
Index: grub-2.00/util/grub-mkconfig.in Index: grub-2.02~beta2/util/grub-mkconfig.in
=================================================================== ===================================================================
--- grub-2.00.orig/util/grub-mkconfig.in --- grub-2.02~beta2.orig/util/grub-mkconfig.in
+++ grub-2.00/util/grub-mkconfig.in +++ grub-2.02~beta2/util/grub-mkconfig.in
@@ -245,7 +245,8 @@ export GRUB_DEFAULT \ @@ -254,7 +254,8 @@ export GRUB_DEFAULT \
GRUB_BADRAM \ GRUB_BADRAM \
GRUB_OS_PROBER_SKIP_LIST \ GRUB_OS_PROBER_SKIP_LIST \
GRUB_DISABLE_SUBMENU \ GRUB_DISABLE_SUBMENU \
@ -39,10 +39,10 @@ Index: grub-2.00/util/grub-mkconfig.in
if test "x${grub_cfg}" != "x"; then if test "x${grub_cfg}" != "x"; then
rm -f "${grub_cfg}.new" rm -f "${grub_cfg}.new"
Index: grub-2.00/util/grub.d/10_linux.in Index: grub-2.02~beta2/util/grub.d/10_linux.in
=================================================================== ===================================================================
--- grub-2.00.orig/util/grub.d/10_linux.in --- grub-2.02~beta2.orig/util/grub.d/10_linux.in
+++ grub-2.00/util/grub.d/10_linux.in +++ grub-2.02~beta2/util/grub.d/10_linux.in
@@ -133,7 +133,7 @@ linux_entry () @@ -133,7 +133,7 @@ linux_entry ()
printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
fi fi
@ -51,7 +51,7 @@ Index: grub-2.00/util/grub.d/10_linux.in
+ if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then + if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
sed "s/^/$submenu_indentation/" << EOF sed "s/^/$submenu_indentation/" << EOF
echo '$message' echo '$message'
linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} linuxefi ${rel_dirname}/${basename} ${root_device} ro ${args}
@@ -147,7 +147,7 @@ EOF @@ -147,7 +147,7 @@ EOF
if test -n "${initrd}" ; then if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated. # TRANSLATORS: ramdisk isn't identifier. Should be translated.

View File

@ -11,10 +11,10 @@ Signed-off-by: Michael Chang <mchang@suse.com>
util/grub.d/10_linux.in | 18 ++++++++++++++++-- util/grub.d/10_linux.in | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-) 1 files changed, 16 insertions(+), 2 deletions(-)
Index: grub-2.00/util/grub.d/10_linux.in Index: grub-2.02~beta2/util/grub.d/10_linux.in
=================================================================== ===================================================================
--- grub-2.00.orig/util/grub.d/10_linux.in --- grub-2.02~beta2.orig/util/grub.d/10_linux.in
+++ grub-2.00/util/grub.d/10_linux.in +++ grub-2.02~beta2/util/grub.d/10_linux.in
@@ -133,17 +133,31 @@ linux_entry () @@ -133,17 +133,31 @@ linux_entry ()
printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
fi fi
@ -23,12 +23,12 @@ Index: grub-2.00/util/grub.d/10_linux.in
+ if [ -d /sys/firmware/efi ]; then + if [ -d /sys/firmware/efi ]; then
+ sed "s/^/$submenu_indentation/" << EOF + sed "s/^/$submenu_indentation/" << EOF
+ echo '$message' + echo '$message'
+ linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} + linuxefi ${rel_dirname}/${basename} ${root_device} ro ${args}
+EOF +EOF
+ else + else
+ sed "s/^/$submenu_indentation/" << EOF + sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)' echo '$(echo "$message" | grub_quote)'
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ${args} linux ${rel_dirname}/${basename} ${root_device} ${args}
EOF EOF
+ fi + fi
if test -n "${initrd}" ; then if test -n "${initrd}" ; then

View File

@ -2,7 +2,7 @@ Index: grub-2.02~beta2/util/setup.c
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/util/setup.c --- grub-2.02~beta2.orig/util/setup.c
+++ grub-2.02~beta2/util/setup.c +++ grub-2.02~beta2/util/setup.c
@@ -501,8 +501,44 @@ SETUP (const char *dir, @@ -501,8 +501,42 @@ SETUP (const char *dir,
err = grub_util_ldm_embed (dest_dev->disk, &nsec, maxsec, err = grub_util_ldm_embed (dest_dev->disk, &nsec, maxsec,
GRUB_EMBED_PCBIOS, &sectors); GRUB_EMBED_PCBIOS, &sectors);
else if (ctx.dest_partmap) else if (ctx.dest_partmap)
@ -13,7 +13,6 @@ Index: grub-2.02~beta2/util/setup.c
+ GRUB_EMBED_PCBIOS, &sectors); + GRUB_EMBED_PCBIOS, &sectors);
+#ifdef GRUB_SETUP_BIOS +#ifdef GRUB_SETUP_BIOS
+ if (err == GRUB_ERR_OUT_OF_RANGE + if (err == GRUB_ERR_OUT_OF_RANGE
+ && strcmp (ctx.dest_partmap->name, "msdos") == 0
+ && dest_dev->disk->id == root_dev->disk->id + && dest_dev->disk->id == root_dev->disk->id
+ && dest_dev->disk->dev->id == root_dev->disk->dev->id) + && dest_dev->disk->dev->id == root_dev->disk->dev->id)
+ { + {
@ -31,7 +30,6 @@ Index: grub-2.02~beta2/util/setup.c
+ GRUB_EMBED_PCBIOS, &fs_sectors); + GRUB_EMBED_PCBIOS, &fs_sectors);
+ if (!err && fs_nsec >= core_sectors) + if (!err && fs_nsec >= core_sectors)
+ { + {
+ grub_util_info ("Your msdos embedding area is too small, will use file system embedding area instead");
+ sectors = fs_sectors; + sectors = fs_sectors;
+ nsec = fs_nsec; + nsec = fs_nsec;
+ ctx.container = root_dev->disk->partition; + ctx.container = root_dev->disk->partition;
@ -49,7 +47,7 @@ Index: grub-2.02~beta2/util/setup.c
else else
err = fs->embed (dest_dev, &nsec, maxsec, err = fs->embed (dest_dev, &nsec, maxsec,
GRUB_EMBED_PCBIOS, &sectors); GRUB_EMBED_PCBIOS, &sectors);
@@ -584,7 +620,7 @@ SETUP (const char *dir, @@ -584,7 +618,7 @@ SETUP (const char *dir,
/* Write the core image onto the disk. */ /* Write the core image onto the disk. */
for (i = 0; i < nsec; i++) for (i = 0; i < nsec; i++)

31
grub2-xen-linux16.patch Normal file
View File

@ -0,0 +1,31 @@
Index: grub-2.02~beta2/grub-core/loader/i386/xen.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/loader/i386/xen.c
+++ grub-2.02~beta2/grub-core/loader/i386/xen.c
@@ -688,7 +688,7 @@ fail:
return grub_errno;
}
-static grub_command_t cmd_xen, cmd_initrd, cmd_module, cmd_multiboot;
+static grub_command_t cmd_xen, cmd_initrd, cmd_module, cmd_multiboot, cmd_xen16, cmd_initrd16;
GRUB_MOD_INIT (xen)
{
@@ -700,6 +700,10 @@ GRUB_MOD_INIT (xen)
0, N_("Load initrd."));
cmd_module = grub_register_command ("module", grub_cmd_module,
0, N_("Load module."));
+ cmd_xen16 = grub_register_command ("linux16", grub_cmd_xen,
+ 0, N_("Load Linux."));
+ cmd_initrd16 = grub_register_command ("initrd16", grub_cmd_initrd,
+ 0, N_("Load initrd."));
my_mod = mod;
}
@@ -709,4 +713,6 @@ GRUB_MOD_FINI (xen)
grub_unregister_command (cmd_initrd);
grub_unregister_command (cmd_multiboot);
grub_unregister_command (cmd_module);
+ grub_unregister_command (cmd_xen16);
+ grub_unregister_command (cmd_initrd16);
}

View File

@ -1,3 +1,53 @@
-------------------------------------------------------------------
Thu Apr 2 04:25:52 UTC 2015 - mchang@suse.com
- Merge changes from SLE12
- Do not pass root= when root is on nfs (bnc#894374)
* modified grub2-pass-corret-root-for-nfsroot.patch
* modified grub2-secureboot-provide-linuxefi-config.patch
* modified grub2-secureboot-use-linuxefi-on-uefi.patch
- Fix xen pvops kernel not appear on menu (bnc#895286)
* modified grub2-fix-menu-in-xen-host-server.patch
- Workaround grub2-once (bnc#892358)
* added grub2-btrfs-workaround-grub2-once.patch
* added grub2-once.service
* modified grub2-once
- Fix busy-loop and hang while network booting (bnc#870613)
* added grub2-netboot-hang.patch
- Add warning in grubenv file about editing it directly (bnc#887008)
* added grub2-editenv-add-warning-message.patch
- Fix broken graphics with efifb on QEMU/KVM and nomodeset (bnc#884558)
* added grub2-efi-disable-video-cirrus-and-bochus.patch
- Disable video support on Power (bnc#877142)
* added grub2-ppc64le-disable-video.patch
- Track occupied memory so it can be released on exit (bnc#885026)
* added grub2-ppc64le-memory-map.patch
- Fix grub.xen config searching path on boot partition (bnc#884828)
- Add linux16 and initrd16 to grub.xen (bnc#884830)
* added grub2-xen-linux16.patch
- VLAN tag support (fate#315753)
* added 0001-Add-bootargs-parser-for-open-firmware.patch
* added 0002-Add-Virtual-LAN-support.patch
- Use chainloader to boot xen.efi under UEFI (bnc#871857)
* added grub2-efi-xen-chainload.patch
- Use device part of chainloader target, if present (bnc#871857)
* added grub2-efi-chainloader-root.patch
- Create only hypervisor pointed by /boot/xen.gz symlink (bnc#877040)
* modified grub2-fix-Grub2-with-SUSE-Xen-package-install.patch
- Fix xen and native entries differ in grub.cfg (bnc#872014)
* modified grub2-linux.patch
- Fix install error on ddf md device (bnc#872360)
* added grub2-getroot-treat-mdadm-ddf-as-simple-device.patch
- Fix booting from NVMe device (bnc#873132)
* added grub2-getroot-support-NVMe-device-names.patch
- Document peculiarities of s390 terminals
* added README.ibm3215
- Grub2 for System z (fate#314213)
* added grub2-s390x-02-kexec-module-added-to-emu.patch
* added grub2-s390x-03-output-7-bit-ascii.patch
* added grub2-s390x-04-grub2-install.patch
* added grub2-s390x-05-grub2-mkconfig.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Mar 16 08:08:32 UTC 2015 - schwab@suse.de Mon Mar 16 08:08:32 UTC 2015 - schwab@suse.de

View File

@ -1,10 +1,10 @@
addFilter("zero-length /boot/grub2/grub.cfg") addFilter("zero-length /boot/grub2/grub.cfg")
addFilter("zero-length /boot/grub2-efi/grub.cfg")
addFilter("non-etc-or-var-file-marked-as-conffile /boot/grub2/grub.cfg") addFilter("non-etc-or-var-file-marked-as-conffile /boot/grub2/grub.cfg")
addFilter("non-etc-or-var-file-marked-as-conffile /boot/grub2-efi/grub.cfg")
addFilter("non-conffile-in-etc /etc/bash_completion.d/grub") addFilter("non-conffile-in-etc /etc/bash_completion.d/grub")
addFilter("non-conffile-in-etc /etc/grub.d/README") addFilter("non-conffile-in-etc /etc/grub.d/README")
addFilter("statically-linked-binary .*/grub2/i386-pc/kernel.img") addFilter("statically-linked-binary .*/grub2/*/kernel.img")
addFilter("patch-not-applied")
# We need to supply unstripped files for grub # We need to supply unstripped files for grub
addFilter("unstripped-binary-or-object .*/grub2/i386-pc/.*.mod") addFilter("unstripped-binary-or-object .*/grub2/*/.*.mod")
addFilter("unstripped-binary-or-object .*/grub2-efi/.*/.*.mod") # TODO: s390 Experts: is this sensible?!
addFilter("s390x: W: executable-stack")

View File

@ -26,9 +26,6 @@ BuildRequires: glibc-devel-32bit
%else %else
BuildRequires: gcc BuildRequires: gcc
BuildRequires: glibc-devel BuildRequires: glibc-devel
%ifarch s390x
BuildRequires: glibc-static
%endif
%endif %endif
BuildRequires: automake BuildRequires: automake
BuildRequires: bison BuildRequires: bison
@ -59,6 +56,11 @@ BuildRequires: pesign-obs-integration
%ifarch %{ix86} x86_64 %ifarch %{ix86} x86_64
BuildRequires: xen-devel BuildRequires: xen-devel
%endif %endif
%if 0%{?suse_version} >= 1210
# Package systemd services files grub2-once.service
BuildRequires: systemd-rpm-macros
%define has_systemd 1
%endif
# Modules code is dynamically loaded and collected from a _fixed_ path. # Modules code is dynamically loaded and collected from a _fixed_ path.
%define _libdir %{_exec_prefix}/lib %define _libdir %{_exec_prefix}/lib
@ -138,10 +140,12 @@ Source4: grub2.rpmlintrc
Source5: translations-20140921.tar.xz Source5: translations-20140921.tar.xz
Source6: grub2-once Source6: grub2-once
Source7: 20_memtest86+ Source7: 20_memtest86+
Source8: README.ibm3215
Source10: openSUSE-UEFI-CA-Certificate.crt Source10: openSUSE-UEFI-CA-Certificate.crt
Source11: SLES-UEFI-CA-Certificate.crt Source11: SLES-UEFI-CA-Certificate.crt
Source12: grub2-snapper-plugin.sh Source12: grub2-snapper-plugin.sh
Source14: 80_suse_btrfs_snapshot Source14: 80_suse_btrfs_snapshot
Source15: grub2-once.service
Source1000: PATCH_POLICY Source1000: PATCH_POLICY
Patch1: rename-grub-info-file-to-grub2.patch Patch1: rename-grub-info-file-to-grub2.patch
Patch2: grub2-linux.patch Patch2: grub2-linux.patch
@ -156,6 +160,7 @@ Patch15: not-display-menu-when-boot-once.patch
Patch16: grub2-fix-Grub2-with-SUSE-Xen-package-install.patch Patch16: grub2-fix-Grub2-with-SUSE-Xen-package-install.patch
Patch17: grub2-pass-corret-root-for-nfsroot.patch Patch17: grub2-pass-corret-root-for-nfsroot.patch
Patch18: grub2-fix-locale-en.mo.gz-not-found-error-message.patch Patch18: grub2-fix-locale-en.mo.gz-not-found-error-message.patch
Patch19: grub2-efi-HP-workaround.patch
Patch21: grub2-secureboot-add-linuxefi.patch Patch21: grub2-secureboot-add-linuxefi.patch
Patch22: grub2-secureboot-use-linuxefi-on-uefi.patch Patch22: grub2-secureboot-use-linuxefi-on-uefi.patch
Patch23: grub2-secureboot-no-insmod-on-sb.patch Patch23: grub2-secureboot-no-insmod-on-sb.patch
@ -166,19 +171,31 @@ Patch35: grub2-linguas.sh-no-rsync.patch
Patch36: 0001-look-for-DejaVu-also-in-usr-share-fonts-truetype.patch Patch36: 0001-look-for-DejaVu-also-in-usr-share-fonts-truetype.patch
Patch37: grub2-use-Unifont-for-starfield-theme-terminal.patch Patch37: grub2-use-Unifont-for-starfield-theme-terminal.patch
Patch38: grub2-s390x-01-Changes-made-and-files-added-in-order-to-allow-s390x.patch Patch38: grub2-s390x-01-Changes-made-and-files-added-in-order-to-allow-s390x.patch
Patch39: grub2-use-rpmsort-for-version-sorting.patch Patch39: grub2-s390x-02-kexec-module-added-to-emu.patch
Patch40: aarch64-reloc.patch Patch40: grub2-s390x-03-output-7-bit-ascii.patch
Patch41: grub2-vbe-blacklist-preferred-1440x900x32.patch Patch41: grub2-s390x-04-grub2-install.patch
Patch42: grub2-btrfs-fix-incorrect-address-reference.patch Patch42: grub2-s390x-05-grub2-mkconfig.patch
Patch43: grub2-mkconfig-aarch64.patch Patch43: grub2-use-rpmsort-for-version-sorting.patch
Patch50: grub2-efinet-reopen-SNP-protocol-for-exclusive-use-by-grub.patch
Patch51: grub2-xen-legacy-config-device-name.patch
Patch52: grub2-getroot-support-NVMe-device-names.patch
Patch53: grub2-getroot-treat-mdadm-ddf-as-simple-device.patch
Patch54: grub2-efi-xen-chainload.patch
Patch55: grub2-efi-chainloader-root.patch
Patch56: grub2-setup-try-fs-embed-if-mbr-gap-too-small.patch
Patch57: grub2-netboot-hang.patch
Patch58: grub2-xen-linux16.patch
Patch59: grub2-efi-disable-video-cirrus-and-bochus.patch
Patch60: grub2-editenv-add-warning-message.patch
Patch61: grub2-vbe-blacklist-preferred-1440x900x32.patch
Patch62: grub2-btrfs-fix-incorrect-address-reference.patch
Patch63: aarch64-reloc.patch
Patch64: grub2-btrfs-workaround-grub2-once.patch
Patch65: grub2-mkconfig-aarch64.patch
# Fix build with glibc 2.20+ # Fix build with glibc 2.20+
Patch44: grub2-glibc-2.20.patch Patch66: grub2-glibc-2.20.patch
Patch45: grub2-efinet-reopen-SNP-protocol-for-exclusive-use-by-grub.patch Patch67: grub2-Initialized-initrd_ctx-so-we-don-t-free-a-random-poi.patch
Patch46: grub2-xen-legacy-config-device-name.patch Patch68: grub2-btrfs-fix-get_root-key-comparison-failures-due-to-en.patch
Patch47: grub2-Initialized-initrd_ctx-so-we-don-t-free-a-random-poi.patch
Patch48: grub2-btrfs-fix-get_root-key-comparison-failures-due-to-en.patch
Patch49: grub2-setup-try-fs-embed-if-mbr-gap-too-small.patch
Patch50: grub2-efi-HP-workaround.patch
# Btrfs snapshot booting related patches # Btrfs snapshot booting related patches
Patch101: grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch Patch101: grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
Patch102: grub2-btrfs-02-export-subvolume-envvars.patch Patch102: grub2-btrfs-02-export-subvolume-envvars.patch
@ -211,20 +228,28 @@ Patch222: grub2-ppc64le-22-all-parameter-to-firmware-calls-should-to-be-Bi
Patch224: grub2-ppc64-build-ppc64-32bit.patch Patch224: grub2-ppc64-build-ppc64-32bit.patch
Patch225: grub2-ppc64-qemu.patch Patch225: grub2-ppc64-qemu.patch
Patch226: grub2-ppc64le-timeout.patch Patch226: grub2-ppc64le-timeout.patch
Patch227: grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch Patch227: grub2-ppc64le-disable-video.patch
Patch228: grub2-xfs-Add-helper-for-inode-size.patch Patch228: grub2-ppc64le-memory-map.patch
Patch229: grub2-xfs-Fix-termination-loop-for-directory-iteration.patch Patch229: grub2-xfs-Add-helper-for-inode-size.patch
Patch230: grub2-xfs-Convert-inode-numbers-to-cpu-endianity-immediate.patch Patch230: grub2-xfs-Fix-termination-loop-for-directory-iteration.patch
Patch231: grub2-xfs-V5-filesystem-format-support.patch Patch231: grub2-xfs-Convert-inode-numbers-to-cpu-endianity-immediate.patch
Patch232: grub2-efi_gop-avoid-low-resolution.patch Patch232: grub2-xfs-V5-filesystem-format-support.patch
Patch233: grub2-ppc64le-fix-64bit-trampoline-in-dyn-linker.patch Patch233: grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch
Patch234: grub2-arm64-Reduce-timer-event-frequency-by-10.patch Patch234: 0001-Add-bootargs-parser-for-open-firmware.patch
Patch235: grub2-arm64-set-correct-length.patch Patch235: 0002-Add-Virtual-LAN-support.patch
Patch236: grub2-efi_gop-avoid-low-resolution.patch
Patch237: grub2-ppc64le-fix-64bit-trampoline-in-dyn-linker.patch
Patch238: grub2-arm64-Reduce-timer-event-frequency-by-10.patch
Patch239: grub2-arm64-set-correct-length.patch
Requires: gettext-runtime Requires: gettext-runtime
%if 0%{?suse_version} >= 1140 %if 0%{?suse_version} >= 1140
%ifnarch s390x
Recommends: os-prober Recommends: os-prober
%endif %endif
# xorriso not available using grub2-mkrescue (bnc#812681)
Recommends: libburnia-tools
%endif
Requires(post): /sbin/install-info Requires(post): /sbin/install-info
Requires(preun):/sbin/install-info Requires(preun):/sbin/install-info
%if ! 0%{?only_efi:1} %if ! 0%{?only_efi:1}
@ -275,6 +300,13 @@ Requires: %{name} = %{version}-%{release}
Requires(post): %{name} = %{version}-%{release} Requires(post): %{name} = %{version}-%{release}
Requires: perl-Bootloader Requires: perl-Bootloader
Requires(post): perl-Bootloader Requires(post): perl-Bootloader
%ifarch s390x
# required utilities by grub2-s390x-04-grub2-install.patch
# use 'showconsole' to determine console device. (bnc#876743)
Requires: /sbin/showconsole
# for /sbin/zipl used by grub2-zipl-setup
Requires: s390-tools
%endif
%ifarch ppc64 ppc64le %ifarch ppc64 ppc64le
Requires: powerpc-utils Requires: powerpc-utils
%endif %endif
@ -369,11 +401,12 @@ mv po/grub.pot po/%{name}.pot
# we could enable it when # we could enable it when
# 1 we have background with better contrast to the font's color # 1 we have background with better contrast to the font's color
# 2 we confirm it's eligible to set the terminal background this way # 2 we confirm it's eligible to set the terminal background this way
#%patch13 -p1 #patch13 -p1
%patch15 -p1 %patch15 -p1
%patch16 -p1 %patch16 -p1
%patch17 -p1 %patch17 -p1
%patch18 -p1 %patch18 -p1
%patch19 -p1
%patch21 -p1 %patch21 -p1
%patch22 -p1 %patch22 -p1
%patch23 -p1 %patch23 -p1
@ -389,13 +422,25 @@ mv po/grub.pot po/%{name}.pot
%patch41 -p1 %patch41 -p1
%patch42 -p1 %patch42 -p1
%patch43 -p1 %patch43 -p1
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1 %patch50 -p1
%patch51 -p1
%patch52 -p1
%patch53 -p1
%patch54 -p1
%patch55 -p1
%patch56 -p1
%patch57 -p1
%patch58 -p1
%patch59 -p1
%patch60 -p1
%patch61 -p1
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch68 -p1
%patch101 -p1 %patch101 -p1
%patch102 -p1 %patch102 -p1
%patch103 -p1 %patch103 -p1
@ -435,6 +480,10 @@ mv po/grub.pot po/%{name}.pot
%patch233 -p1 %patch233 -p1
%patch234 -p1 %patch234 -p1
%patch235 -p1 %patch235 -p1
%patch236 -p1
%patch237 -p1
%patch238 -p1
%patch239 -p1
# Generate po/LINGUAS for message catalogs ... # Generate po/LINGUAS for message catalogs ...
./linguas.sh ./linguas.sh
@ -443,6 +492,7 @@ rm -f po/stamp-po
# README.openSUSE # README.openSUSE
cp %{SOURCE3} . cp %{SOURCE3} .
cp %{SOURCE8} .
mkdir build mkdir build
%ifarch %{efi} %ifarch %{efi}
mkdir build-efi mkdir build-efi
@ -464,7 +514,6 @@ CFLAGS="-fno-strict-aliasing -fno-inline-functions-called-once "
CXXFLAGS=" " CXXFLAGS=" "
FFLAGS=" " FFLAGS=" "
export CFLAGS CXXFLAGS FFLAGS export CFLAGS CXXFLAGS FFLAGS
export HOST_CFLAGS=$RPM_OPT_FLAGS
%ifarch %{ix86} x86_64 %ifarch %{ix86} x86_64
cd build-xen cd build-xen
@ -490,6 +539,10 @@ elif search -s root -f /@/boot/grub2/grub.cfg ; then
configfile /@/boot/grub2/grub.cfg configfile /@/boot/grub2/grub.cfg
elif search -s root -f /boot/grub/menu.lst ; then elif search -s root -f /boot/grub/menu.lst ; then
legacy_configfile /boot/grub/menu.lst legacy_configfile /boot/grub/menu.lst
elif search -s root -f /grub2/grub.cfg ; then
configfile /grub2/grub.cfg
elif search -s root -f /grub/menu.lst ; then
legacy_configfile /grub/menu.lst
fi fi
EOF EOF
./grub-mkstandalone --grub-mkimage=./grub-mkimage -o grub.xen -O %{grubxenarch} -d grub-core/ "/boot/grub/grub.cfg=./grub.cfg" ./grub-mkstandalone --grub-mkimage=./grub-mkimage -o grub.xen -O %{grubxenarch} -d grub-core/ "/boot/grub/grub.cfg=./grub.cfg"
@ -572,19 +625,21 @@ cd build
%endif %endif
%ifarch s390x %ifarch s390x
%define _devmapper --disable-device-mapper %define arch_specific --enable-device-mapper --disable-grub-mount
TFLAGS="-fPIC"
%else %else
%define _devmapper --enable-device-mapper %define arch_specific --enable-device-mapper
TFLAGS="-static"
%endif %endif
# -static is needed so that autoconf script is able to link # -static is needed so that autoconf script is able to link
# test that looks for _start symbol on 64 bit platforms # test that looks for _start symbol on 64 bit platforms
../configure TARGET_LDFLAGS=-static \ ../configure TARGET_LDFLAGS=$TFLAGS \
--prefix=%{_prefix} \ --prefix=%{_prefix} \
--sysconfdir=%{_sysconfdir} \ --sysconfdir=%{_sysconfdir} \
--target=%{_target_platform} \ --target=%{_target_platform} \
--with-platform=%{platform} \ --with-platform=%{platform} \
%{_devmapper} \ %{arch_specific} \
--program-transform-name=s,grub,%{name}, --program-transform-name=s,grub,%{name},
make %{?_smp_mflags} make %{?_smp_mflags}
%endif %endif
@ -658,13 +713,8 @@ install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/default/grub
install -m 755 -D %{SOURCE6} $RPM_BUILD_ROOT%{_sbindir}/grub2-once install -m 755 -D %{SOURCE6} $RPM_BUILD_ROOT%{_sbindir}/grub2-once
install -m 755 -D %{SOURCE12} $RPM_BUILD_ROOT%{_libdir}/snapper/plugins/grub install -m 755 -D %{SOURCE12} $RPM_BUILD_ROOT%{_libdir}/snapper/plugins/grub
install -m 755 -D %{SOURCE14} $RPM_BUILD_ROOT%{_sysconfdir}/grub.d/80_suse_btrfs_snapshot install -m 755 -D %{SOURCE14} $RPM_BUILD_ROOT%{_sysconfdir}/grub.d/80_suse_btrfs_snapshot
%if 0%{?has_systemd:1}
%ifnarch %{ix86} x86_64 install -m 644 -D %{SOURCE15} $RPM_BUILD_ROOT%{_unitdir}/grub2-once.service
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/grub.d/20_memtest86+
%endif
%ifnarch ppc ppc64 ppc64le
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/grub.d/20_ppc_terminfo
%endif %endif
%ifarch ppc ppc64 ppc64le %ifarch ppc ppc64 ppc64le
@ -673,8 +723,54 @@ mv $RPM_BUILD_ROOT%{_libdir}/%{name}/%{grubarch}/%{name}.chrp \
$RPM_BUILD_ROOT%{_libdir}/%{name}/%{grubarch}/grub.chrp $RPM_BUILD_ROOT%{_libdir}/%{name}/%{grubarch}/grub.chrp
%endif %endif
R=$RPM_BUILD_ROOT
%ifarch %{ix86} x86_64
%else
rm -f $R%{_sysconfdir}/grub.d/20_memtest86+
%endif
%ifarch ppc ppc64 ppc64le
%else
rm -f $R%{_sysconfdir}/grub.d/20_ppc_terminfo
%endif
%ifarch s390x
mv $R%{_sysconfdir}/{grub.d,default}/zipl2grub.conf.in
chmod 600 $R%{_sysconfdir}/default/zipl2grub.conf.in
%define dracutlibdir %{_prefix}/lib/dracut
%define dracutgrubmoddir %{dracutlibdir}/modules.d/99grub2
install -m 755 -d $R%{dracutgrubmoddir}
for f in module-setup.sh grub2.sh; do
mv $R%{_libdir}/%{name}/%{grubarch}/dracut-$f $R%{dracutgrubmoddir}/$f
done
rm -f $R%{_sysconfdir}/grub.d/30_os-prober
perl -ni -e '
sub END() {
print "\n# on s390x always:\nGRUB_DISABLE_OS_PROBER=true\n";
}
if ( s{^#(GRUB_DISABLE_LINUX_RECOVERY)=\"?(true)\"?}{$1=$2} ) {
$_ .= "GRUB_DISABLE_RECOVERY=true\n";
}
if ( s{^#?(GRUB_TERMINAL)=(console|gfxterm)}{$1=console} ) {
$_ .= "GRUB_GFXPAYLOAD_LINUX=text\n";
}
if ( m{^# The resolution used on graphical} ||
m{^# # note that you can use only modes} ||
m{^# you can see them in real GRUB} ||
m{^#?GRUB_GFXMODE=} ) {
next;
}
s{openSUSE}{SUSE Linux Enterprise Server} if (m{^GRUB_DISTRIBUTOR});
print;
' $RPM_BUILD_ROOT%{_sysconfdir}/default/grub
%else
%endif
%find_lang %{name} %find_lang %{name}
%fdupes %buildroot%{_bindir} %fdupes %buildroot%{_bindir}
%fdupes %buildroot%{_libdir}
%post %post
/sbin/install-info %{_infodir}/grub-dev.info %{_infodir}/dir || : /sbin/install-info %{_infodir}/grub-dev.info %{_infodir}/dir || :
@ -807,6 +903,9 @@ fi
%doc THANKS TODO ChangeLog %doc THANKS TODO ChangeLog
%doc README.openSUSE %doc README.openSUSE
%doc docs/autoiso.cfg docs/osdetect.cfg %doc docs/autoiso.cfg docs/osdetect.cfg
%ifarch s390x
%doc README.ibm3215
%endif
%dir /boot/%{name} %dir /boot/%{name}
%ghost /boot/%{name}/grub.cfg %ghost /boot/%{name}/grub.cfg
%{_sysconfdir}/bash_completion.d/grub %{_sysconfdir}/bash_completion.d/grub
@ -816,23 +915,18 @@ fi
%config %{_sysconfdir}/grub.d/00_header %config %{_sysconfdir}/grub.d/00_header
%config %{_sysconfdir}/grub.d/10_linux %config %{_sysconfdir}/grub.d/10_linux
%config %{_sysconfdir}/grub.d/20_linux_xen %config %{_sysconfdir}/grub.d/20_linux_xen
%config %{_sysconfdir}/grub.d/30_os-prober
%config %{_sysconfdir}/grub.d/40_custom %config %{_sysconfdir}/grub.d/40_custom
%config %{_sysconfdir}/grub.d/41_custom %config %{_sysconfdir}/grub.d/41_custom
%config %{_sysconfdir}/grub.d/90_persistent %config %{_sysconfdir}/grub.d/90_persistent
%{_sbindir}/%{name}-bios-setup %{_sbindir}/%{name}-install
%{_sbindir}/%{name}-macbless
%{_sbindir}/%{name}-mkconfig %{_sbindir}/%{name}-mkconfig
%{_sbindir}/%{name}-once %{_sbindir}/%{name}-once
%{_sbindir}/%{name}-ofpathname
%{_sbindir}/%{name}-probe %{_sbindir}/%{name}-probe
%{_sbindir}/%{name}-reboot %{_sbindir}/%{name}-reboot
%{_sbindir}/%{name}-set-default %{_sbindir}/%{name}-set-default
%{_sbindir}/%{name}-sparc64-setup
%{_bindir}/%{name}-editenv %{_bindir}/%{name}-editenv
%{_bindir}/%{name}-file %{_bindir}/%{name}-file
%{_bindir}/%{name}-fstest %{_bindir}/%{name}-fstest
%{_bindir}/%{name}-glue-efi
%{_bindir}/%{name}-kbdcomp %{_bindir}/%{name}-kbdcomp
%{_bindir}/%{name}-menulst2cfg %{_bindir}/%{name}-menulst2cfg
%{_bindir}/%{name}-mkfont %{_bindir}/%{name}-mkfont
@ -843,15 +937,11 @@ fi
%{_bindir}/%{name}-mkrelpath %{_bindir}/%{name}-mkrelpath
%{_bindir}/%{name}-mkrescue %{_bindir}/%{name}-mkrescue
%{_bindir}/%{name}-mkstandalone %{_bindir}/%{name}-mkstandalone
%{_bindir}/%{name}-mount
%{_bindir}/%{name}-render-label %{_bindir}/%{name}-render-label
%{_bindir}/%{name}-script-check %{_bindir}/%{name}-script-check
%{_bindir}/%{name}-syslinux2cfg %{_bindir}/%{name}-syslinux2cfg
%ifarch s390x %if 0%{?has_systemd:1}
%{_bindir}/%{name}-emu %{_unitdir}/grub2-once.service
%{_bindir}/%{name}-emu-lite
%else
%{_sbindir}/%{name}-install
%endif %endif
%dir %{_libdir}/%{name} %dir %{_libdir}/%{name}
%dir %{_datadir}/%{name} %dir %{_datadir}/%{name}
@ -865,9 +955,7 @@ fi
%{_mandir}/man1/%{name}-editenv.1.* %{_mandir}/man1/%{name}-editenv.1.*
%{_mandir}/man1/%{name}-file.1.* %{_mandir}/man1/%{name}-file.1.*
%{_mandir}/man1/%{name}-fstest.1.* %{_mandir}/man1/%{name}-fstest.1.*
%{_mandir}/man1/%{name}-glue-efi.1.*
%{_mandir}/man1/%{name}-kbdcomp.1.* %{_mandir}/man1/%{name}-kbdcomp.1.*
%{_mandir}/man1/%{name}-macbless.1.*
%{_mandir}/man1/%{name}-menulst2cfg.1.* %{_mandir}/man1/%{name}-menulst2cfg.1.*
%{_mandir}/man1/%{name}-mkfont.1.* %{_mandir}/man1/%{name}-mkfont.1.*
%{_mandir}/man1/%{name}-mkimage.1.* %{_mandir}/man1/%{name}-mkimage.1.*
@ -877,24 +965,36 @@ fi
%{_mandir}/man1/%{name}-mkrelpath.1.* %{_mandir}/man1/%{name}-mkrelpath.1.*
%{_mandir}/man1/%{name}-mkrescue.1.* %{_mandir}/man1/%{name}-mkrescue.1.*
%{_mandir}/man1/%{name}-mkstandalone.1.* %{_mandir}/man1/%{name}-mkstandalone.1.*
%{_mandir}/man1/%{name}-mount.1.*
%{_mandir}/man1/%{name}-render-label.1.* %{_mandir}/man1/%{name}-render-label.1.*
%{_mandir}/man1/%{name}-script-check.1.* %{_mandir}/man1/%{name}-script-check.1.*
%{_mandir}/man1/%{name}-syslinux2cfg.1.* %{_mandir}/man1/%{name}-syslinux2cfg.1.*
%{_mandir}/man8/%{name}-bios-setup.8.* %{_mandir}/man8/%{name}-install.8.*
%{_mandir}/man8/%{name}-mkconfig.8.* %{_mandir}/man8/%{name}-mkconfig.8.*
%{_mandir}/man8/%{name}-ofpathname.8.*
%{_mandir}/man8/%{name}-probe.8.* %{_mandir}/man8/%{name}-probe.8.*
%{_mandir}/man8/%{name}-reboot.8.* %{_mandir}/man8/%{name}-reboot.8.*
%{_mandir}/man8/%{name}-set-default.8.* %{_mandir}/man8/%{name}-set-default.8.*
%{_mandir}/man8/%{name}-sparc64-setup.8.*
%ifarch s390x %ifarch s390x
%{_bindir}/%{name}-emu
%{_bindir}/%{name}-emu-lite
%{_mandir}/man1/%{name}-emu.1.* %{_mandir}/man1/%{name}-emu.1.*
%else %else
%{_mandir}/man8/%{name}-install.8.* %config %{_sysconfdir}/grub.d/30_os-prober
%{_bindir}/%{name}-glue-efi
%{_bindir}/%{name}-mount
%{_sbindir}/%{name}-bios-setup
%{_sbindir}/%{name}-macbless
%{_sbindir}/%{name}-ofpathname
%{_sbindir}/%{name}-sparc64-setup
%{_mandir}/man1/%{name}-glue-efi.1.*
%{_mandir}/man1/%{name}-macbless.1.*
%{_mandir}/man1/%{name}-mount.1.*
%{_mandir}/man8/%{name}-bios-setup.8.*
%{_mandir}/man8/%{name}-ofpathname.8.*
%{_mandir}/man8/%{name}-sparc64-setup.8.*
%endif %endif
%files branding-upstream %files branding-upstream
%defattr(-,root,root,-)
%{_datadir}/%{name}/themes/starfield %{_datadir}/%{name}/themes/starfield
%if ! 0%{?only_efi:1} %if ! 0%{?only_efi:1}
@ -926,6 +1026,11 @@ fi
%{_libdir}/%{name}/%{grubarch}/kernel.exec %{_libdir}/%{name}/%{grubarch}/kernel.exec
%{_libdir}/%{name}/%{grubarch}/modinfo.sh %{_libdir}/%{name}/%{grubarch}/modinfo.sh
%endif %endif
%ifarch s390x
%{_sbindir}/%{name}-zipl-setup
%config(noreplace) %{_sysconfdir}/default/zipl2grub.conf.in
%{dracutlibdir}
%endif
%ifarch %{efi} %ifarch %{efi}