1 diff -urN grub-2.02-beta3.orig/grub-core/commands/blscfg.c grub-2.02-beta3/grub-core/commands/blscfg.c
2 --- grub-2.02-beta3.orig/grub-core/commands/blscfg.c 1970-01-01 00:00:00.000000000 +0000
3 +++ grub-2.02-beta3/grub-core/commands/blscfg.c 2016-03-21 08:22:41.774768000 +0000
5 +/*-*- Mode: C; c-basic-offset: 2; indent-tabs-mode: t -*-*/
7 +/* bls.c - implementation of the boot loader spec */
10 + * GRUB -- GRand Unified Bootloader
12 + * GRUB is free software: you can redistribute it and/or modify
13 + * it under the terms of the GNU General Public License as published by
14 + * the Free Software Foundation, either version 3 of the License, or
15 + * (at your option) any later version.
17 + * GRUB is distributed in the hope that it will be useful,
18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 + * GNU General Public License for more details.
22 + * You should have received a copy of the GNU General Public License
23 + * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
26 +#include <grub/types.h>
27 +#include <grub/misc.h>
29 +#include <grub/err.h>
31 +#include <grub/extcmd.h>
32 +#include <grub/i18n.h>
34 +#include <grub/env.h>
35 +#include <grub/file.h>
36 +#include <grub/normal.h>
38 +GRUB_MOD_LICENSE ("GPLv3+");
40 +#ifdef GRUB_MACHINE_EFI
41 +#define GRUB_LINUX_CMD "linuxefi"
42 +#define GRUB_INITRD_CMD "initrdefi"
43 +#define GRUB_BLS_CONFIG_PATH "/EFI/fedora/loader/entries/"
44 +#define GRUB_BOOT_DEVICE "($boot)"
46 +#define GRUB_LINUX_CMD "linux"
47 +#define GRUB_INITRD_CMD "initrd"
48 +#define GRUB_BLS_CONFIG_PATH "/loader/entries/"
49 +#define GRUB_BOOT_DEVICE "($root)"
52 +static int parse_entry (
53 + const char *filename,
54 + const struct grub_dirhook_info *info __attribute__ ((unused)),
55 + void *data __attribute__ ((unused)))
59 + grub_file_t f = NULL;
61 + char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL;
62 + const char *args[2] = { NULL, NULL };
64 + if (filename[0] == '.')
67 + n = grub_strlen (filename);
71 + if (grub_strcmp (filename + n - 5, ".conf") != 0)
74 + p = grub_xasprintf (GRUB_BLS_CONFIG_PATH "%s", filename);
76 + f = grub_file_open (p);
80 + sz = grub_file_size (f);
81 + if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024)
88 + buf = grub_file_getline (f);
92 + if (grub_strncmp (buf, "title ", 6) == 0)
95 + title = grub_strdup (buf + 6);
99 + else if (grub_strncmp (buf, "options ", 8) == 0)
101 + grub_free (options);
102 + options = grub_strdup (buf + 8);
106 + else if (grub_strncmp (buf, "linux ", 6) == 0)
108 + grub_free (clinux);
109 + clinux = grub_strdup (buf + 6);
113 + else if (grub_strncmp (buf, "initrd ", 7) == 0)
115 + grub_free (initrd);
116 + initrd = grub_strdup (buf + 7);
126 + grub_printf ("Skipping file %s with no 'linux' key.", p);
130 + args[0] = title ? title : filename;
132 + src = grub_xasprintf ("load_video\n"
133 + "set gfx_payload=keep\n"
135 + GRUB_LINUX_CMD " %s%s%s%s\n"
137 + GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "",
138 + initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : "");
140 + grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0);
145 + grub_free (options);
146 + grub_free (clinux);
147 + grub_free (initrd);
151 + grub_file_close (f);
157 +grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)),
158 + int argc __attribute__ ((unused)),
159 + char **args __attribute__ ((unused)))
163 + static grub_err_t r;
166 + devid = grub_env_get ("root");
168 + return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "root");
170 + dev = grub_device_open (devid);
174 + fs = grub_fs_probe (dev);
181 + r = fs->dir (dev, GRUB_BLS_CONFIG_PATH, parse_entry, NULL);
185 + grub_device_close (dev);
190 +static grub_extcmd_t cmd;
194 + cmd = grub_register_extcmd ("bls_import",
195 + grub_cmd_bls_import,
198 + N_("Import Boot Loader Specification snippets."),
204 + grub_unregister_extcmd (cmd);
206 diff -urN grub-2.02-beta3.orig/grub-core/Makefile.core.def grub-2.02-beta3/grub-core/Makefile.core.def
207 --- grub-2.02-beta3.orig/grub-core/Makefile.core.def 2016-02-28 02:07:41.000000000 +0000
208 +++ grub-2.02-beta3/grub-core/Makefile.core.def 2016-03-21 08:22:41.774768000 +0000
214 + common = commands/blscfg.c;
216 + enable = x86_64_efi;
222 common = commands/boot.c;
223 i386_pc = lib/i386/pc/biosnum.c;