|
|
f96e0b |
From 3ac82fb82508c811ded4ff43c023c0b571b24fed Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
Date: Sun, 3 Mar 2013 01:34:27 +0100
|
|
|
f96e0b |
Subject: [PATCH 191/482] * grub-core/kern/env.c, include/grub/env.h:
|
|
|
f96e0b |
Change iterator through all vars to a macro. All users updated.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 5 ++++
|
|
|
f96e0b |
grub-core/efiemu/pnvram.c | 64 ++++++++++++++++++++-------------------------
|
|
|
f96e0b |
grub-core/kern/corecmd.c | 12 +++------
|
|
|
f96e0b |
grub-core/kern/env.c | 39 +++++++--------------------
|
|
|
f96e0b |
grub-core/loader/i386/bsd.c | 46 ++++++++++++--------------------
|
|
|
f96e0b |
grub-core/loader/xnu.c | 16 +++++-------
|
|
|
f96e0b |
include/grub/env.h | 6 ++++-
|
|
|
f96e0b |
7 files changed, 74 insertions(+), 114 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index f117127..5f9cde5 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,5 +1,10 @@
|
|
|
f96e0b |
2013-03-03 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
+ * grub-core/kern/env.c, include/grub/env.h: Change iterator through
|
|
|
f96e0b |
+ all vars to a macro. All users updated.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+2013-03-03 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
* grub-core/disk/ieee1275/nand.c: Fix compilation on
|
|
|
f96e0b |
i386-ieee1275.
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/efiemu/pnvram.c b/grub-core/efiemu/pnvram.c
|
|
|
f96e0b |
index 28d0050..c5c3d4b 100644
|
|
|
f96e0b |
--- a/grub-core/efiemu/pnvram.c
|
|
|
f96e0b |
+++ b/grub-core/efiemu/pnvram.c
|
|
|
f96e0b |
@@ -102,9 +102,23 @@ nvram_set (void * data __attribute__ ((unused)))
|
|
|
f96e0b |
grub_uint32_t *accuracy
|
|
|
f96e0b |
= grub_efiemu_mm_obtain_request (accuracy_handle);
|
|
|
f96e0b |
char *nvramptr;
|
|
|
f96e0b |
+ struct grub_env_var *var;
|
|
|
f96e0b |
|
|
|
f96e0b |
- auto int iterate_env (struct grub_env_var *var);
|
|
|
f96e0b |
- int iterate_env (struct grub_env_var *var)
|
|
|
f96e0b |
+ /* Copy to definitive loaction */
|
|
|
f96e0b |
+ grub_dprintf ("efiemu", "preparing pnvram\n");
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ env = grub_env_get ("EfiEmu.pnvram.high_monotonic_count");
|
|
|
f96e0b |
+ *high_monotonic_count = env ? grub_strtoul (env, 0, 0) : 1;
|
|
|
f96e0b |
+ env = grub_env_get ("EfiEmu.pnvram.timezone");
|
|
|
f96e0b |
+ *timezone = env ? grub_strtosl (env, 0, 0) : GRUB_EFI_UNSPECIFIED_TIMEZONE;
|
|
|
f96e0b |
+ env = grub_env_get ("EfiEmu.pnvram.accuracy");
|
|
|
f96e0b |
+ *accuracy = env ? grub_strtoul (env, 0, 0) : 50000000;
|
|
|
f96e0b |
+ env = grub_env_get ("EfiEmu.pnvram.daylight");
|
|
|
f96e0b |
+ *daylight = env ? grub_strtoul (env, 0, 0) : 0;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ nvramptr = nvram;
|
|
|
f96e0b |
+ grub_memset (nvram, 0, nvramsize);
|
|
|
f96e0b |
+ FOR_SORTED_ENV (var)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
char *guid, *attr, *name, *varname;
|
|
|
f96e0b |
struct efi_variable *efivar;
|
|
|
f96e0b |
@@ -114,44 +128,41 @@ nvram_set (void * data __attribute__ ((unused)))
|
|
|
f96e0b |
|
|
|
f96e0b |
if (grub_memcmp (var->name, "EfiEmu.pnvram.",
|
|
|
f96e0b |
sizeof ("EfiEmu.pnvram.") - 1) != 0)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
|
|
|
f96e0b |
guid = var->name + sizeof ("EfiEmu.pnvram.") - 1;
|
|
|
f96e0b |
|
|
|
f96e0b |
attr = grub_strchr (guid, '.');
|
|
|
f96e0b |
if (!attr)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
attr++;
|
|
|
f96e0b |
|
|
|
f96e0b |
name = grub_strchr (attr, '.');
|
|
|
f96e0b |
if (!name)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
name++;
|
|
|
f96e0b |
|
|
|
f96e0b |
efivar = (struct efi_variable *) nvramptr;
|
|
|
f96e0b |
if (nvramptr - nvram + sizeof (struct efi_variable) > nvramsize)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
|
|
f96e0b |
- "too many NVRAM variables for reserved variable space."
|
|
|
f96e0b |
- " Try increasing EfiEmu.pnvram.size");
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
|
|
f96e0b |
+ "too many NVRAM variables for reserved variable space."
|
|
|
f96e0b |
+ " Try increasing EfiEmu.pnvram.size");
|
|
|
f96e0b |
|
|
|
f96e0b |
nvramptr += sizeof (struct efi_variable);
|
|
|
f96e0b |
|
|
|
f96e0b |
efivar->guid.data1 = grub_cpu_to_le32 (grub_strtoul (guid, &guid, 16));
|
|
|
f96e0b |
if (*guid != '-')
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
guid++;
|
|
|
f96e0b |
|
|
|
f96e0b |
efivar->guid.data2 = grub_cpu_to_le16 (grub_strtoul (guid, &guid, 16));
|
|
|
f96e0b |
if (*guid != '-')
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
guid++;
|
|
|
f96e0b |
|
|
|
f96e0b |
efivar->guid.data3 = grub_cpu_to_le16 (grub_strtoul (guid, &guid, 16));
|
|
|
f96e0b |
if (*guid != '-')
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
guid++;
|
|
|
f96e0b |
|
|
|
f96e0b |
guidcomp = grub_strtoull (guid, 0, 16);
|
|
|
f96e0b |
@@ -162,10 +173,10 @@ nvram_set (void * data __attribute__ ((unused)))
|
|
|
f96e0b |
|
|
|
f96e0b |
varname = grub_malloc (grub_strlen (name) + 1);
|
|
|
f96e0b |
if (! varname)
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
+ return grub_errno;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (unescape (name, varname, varname + grub_strlen (name) + 1, &len))
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
|
|
|
f96e0b |
len = grub_utf8_to_utf16 ((grub_uint16_t *) nvramptr,
|
|
|
f96e0b |
(nvramsize - (nvramptr - nvram)) / 2,
|
|
|
f96e0b |
@@ -179,33 +190,16 @@ nvram_set (void * data __attribute__ ((unused)))
|
|
|
f96e0b |
if (unescape (var->value, nvramptr, nvram + nvramsize, &len))
|
|
|
f96e0b |
{
|
|
|
f96e0b |
efivar->namelen = 0;
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
nvramptr += len;
|
|
|
f96e0b |
|
|
|
f96e0b |
efivar->size = len;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- /* Copy to definitive loaction */
|
|
|
f96e0b |
- grub_dprintf ("efiemu", "preparing pnvram\n");
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- env = grub_env_get ("EfiEmu.pnvram.high_monotonic_count");
|
|
|
f96e0b |
- *high_monotonic_count = env ? grub_strtoul (env, 0, 0) : 1;
|
|
|
f96e0b |
- env = grub_env_get ("EfiEmu.pnvram.timezone");
|
|
|
f96e0b |
- *timezone = env ? grub_strtosl (env, 0, 0) : GRUB_EFI_UNSPECIFIED_TIMEZONE;
|
|
|
f96e0b |
- env = grub_env_get ("EfiEmu.pnvram.accuracy");
|
|
|
f96e0b |
- *accuracy = env ? grub_strtoul (env, 0, 0) : 50000000;
|
|
|
f96e0b |
- env = grub_env_get ("EfiEmu.pnvram.daylight");
|
|
|
f96e0b |
- *daylight = env ? grub_strtoul (env, 0, 0) : 0;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- nvramptr = nvram;
|
|
|
f96e0b |
- grub_memset (nvram, 0, nvramsize);
|
|
|
f96e0b |
- grub_env_iterate (iterate_env);
|
|
|
f96e0b |
if (grub_errno)
|
|
|
f96e0b |
return grub_errno;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
*nvramsize_def = nvramsize;
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Register symbols */
|
|
|
f96e0b |
diff --git a/grub-core/kern/corecmd.c b/grub-core/kern/corecmd.c
|
|
|
f96e0b |
index 0dc4d00..cfab676 100644
|
|
|
f96e0b |
--- a/grub-core/kern/corecmd.c
|
|
|
f96e0b |
+++ b/grub-core/kern/corecmd.c
|
|
|
f96e0b |
@@ -28,14 +28,6 @@
|
|
|
f96e0b |
#include <grub/command.h>
|
|
|
f96e0b |
#include <grub/i18n.h>
|
|
|
f96e0b |
|
|
|
f96e0b |
-/* Helper for grub_core_cmd_set. */
|
|
|
f96e0b |
-static int
|
|
|
f96e0b |
-print_env (struct grub_env_var *env)
|
|
|
f96e0b |
-{
|
|
|
f96e0b |
- grub_printf ("%s=%s\n", env->name, env->value);
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
-}
|
|
|
f96e0b |
-
|
|
|
f96e0b |
/* set ENVVAR=VALUE */
|
|
|
f96e0b |
static grub_err_t
|
|
|
f96e0b |
grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
|
|
|
f96e0b |
@@ -46,7 +38,9 @@ grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
|
|
|
f96e0b |
|
|
|
f96e0b |
if (argc < 1)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_env_iterate (print_env);
|
|
|
f96e0b |
+ struct grub_env_var *env;
|
|
|
f96e0b |
+ FOR_SORTED_ENV (env)
|
|
|
f96e0b |
+ grub_printf ("%s=%s\n", env->name, env->value);
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/kern/env.c b/grub-core/kern/env.c
|
|
|
f96e0b |
index 7bfa238..c408626 100644
|
|
|
f96e0b |
--- a/grub-core/kern/env.c
|
|
|
f96e0b |
+++ b/grub-core/kern/env.c
|
|
|
f96e0b |
@@ -166,11 +166,10 @@ grub_env_unset (const char *name)
|
|
|
f96e0b |
grub_free (var);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
-void
|
|
|
f96e0b |
-grub_env_iterate (int (*func) (struct grub_env_var *var))
|
|
|
f96e0b |
+struct grub_env_var *
|
|
|
f96e0b |
+grub_env_update_get_sorted (void)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- struct grub_env_sorted_var *sorted_list = 0;
|
|
|
f96e0b |
- struct grub_env_sorted_var *sorted_var;
|
|
|
f96e0b |
+ struct grub_env_var *sorted_list = 0;
|
|
|
f96e0b |
int i;
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Add variables associated with this context into a sorted list. */
|
|
|
f96e0b |
@@ -180,40 +179,20 @@ grub_env_iterate (int (*func) (struct grub_env_var *var))
|
|
|
f96e0b |
|
|
|
f96e0b |
for (var = grub_current_context->vars[i]; var; var = var->next)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- struct grub_env_sorted_var *p, **q;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- sorted_var = grub_malloc (sizeof (*sorted_var));
|
|
|
f96e0b |
- if (! sorted_var)
|
|
|
f96e0b |
- goto fail;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- sorted_var->var = var;
|
|
|
f96e0b |
+ struct grub_env_var *p, **q;
|
|
|
f96e0b |
|
|
|
f96e0b |
- for (q = &sorted_list, p = *q; p; q = &((*q)->next), p = *q)
|
|
|
f96e0b |
+ for (q = &sorted_list, p = *q; p; q = &((*q)->sorted_next), p = *q)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- if (grub_strcmp (p->var->name, var->name) > 0)
|
|
|
f96e0b |
+ if (grub_strcmp (p->name, var->name) > 0)
|
|
|
f96e0b |
break;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- sorted_var->next = *q;
|
|
|
f96e0b |
- *q = sorted_var;
|
|
|
f96e0b |
+ var->sorted_next = *q;
|
|
|
f96e0b |
+ *q = var;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- /* Iterate FUNC on the sorted list. */
|
|
|
f96e0b |
- for (sorted_var = sorted_list; sorted_var; sorted_var = sorted_var->next)
|
|
|
f96e0b |
- if (func (sorted_var->var))
|
|
|
f96e0b |
- break;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- fail:
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- /* Free the sorted list. */
|
|
|
f96e0b |
- for (sorted_var = sorted_list; sorted_var; )
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- struct grub_env_sorted_var *tmp = sorted_var->next;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- grub_free (sorted_var);
|
|
|
f96e0b |
- sorted_var = tmp;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ return sorted_list;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_err_t
|
|
|
f96e0b |
diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
|
|
|
f96e0b |
index 6199609..e89ec26 100644
|
|
|
f96e0b |
--- a/grub-core/loader/i386/bsd.c
|
|
|
f96e0b |
+++ b/grub-core/loader/i386/bsd.c
|
|
|
f96e0b |
@@ -589,33 +589,7 @@ grub_freebsd_boot (void)
|
|
|
f96e0b |
grub_err_t err;
|
|
|
f96e0b |
grub_size_t tag_buf_len = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- auto int iterate_env (struct grub_env_var *var);
|
|
|
f96e0b |
- int iterate_env (struct grub_env_var *var)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if ((!grub_memcmp (var->name, "kFreeBSD.", sizeof("kFreeBSD.") - 1)) && (var->name[sizeof("kFreeBSD.") - 1]))
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_strcpy ((char *) p, &var->name[sizeof("kFreeBSD.") - 1]);
|
|
|
f96e0b |
- p += grub_strlen ((char *) p);
|
|
|
f96e0b |
- *(p++) = '=';
|
|
|
f96e0b |
- grub_strcpy ((char *) p, var->value);
|
|
|
f96e0b |
- p += grub_strlen ((char *) p) + 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- auto int iterate_env_count (struct grub_env_var *var);
|
|
|
f96e0b |
- int iterate_env_count (struct grub_env_var *var)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if ((!grub_memcmp (var->name, "kFreeBSD.", sizeof("kFreeBSD.") - 1)) && (var->name[sizeof("kFreeBSD.") - 1]))
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- p_size += grub_strlen (&var->name[sizeof("kFreeBSD.") - 1]);
|
|
|
f96e0b |
- p_size++;
|
|
|
f96e0b |
- p_size += grub_strlen (var->value) + 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ struct grub_env_var *var;
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_memset (&bi, 0, sizeof (bi));
|
|
|
f96e0b |
bi.version = FREEBSD_BOOTINFO_VERSION;
|
|
|
f96e0b |
@@ -624,7 +598,13 @@ grub_freebsd_boot (void)
|
|
|
f96e0b |
bi.boot_device = freebsd_biosdev;
|
|
|
f96e0b |
|
|
|
f96e0b |
p_size = 0;
|
|
|
f96e0b |
- grub_env_iterate (iterate_env_count);
|
|
|
f96e0b |
+ FOR_SORTED_ENV (var)
|
|
|
f96e0b |
+ if ((grub_memcmp (var->name, "kFreeBSD.", sizeof("kFreeBSD.") - 1) == 0) && (var->name[sizeof("kFreeBSD.") - 1]))
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ p_size += grub_strlen (&var->name[sizeof("kFreeBSD.") - 1]);
|
|
|
f96e0b |
+ p_size++;
|
|
|
f96e0b |
+ p_size += grub_strlen (var->value) + 1;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
if (p_size)
|
|
|
f96e0b |
p_size = ALIGN_PAGE (kern_end + p_size + 1) - kern_end;
|
|
|
f96e0b |
@@ -664,7 +644,15 @@ grub_freebsd_boot (void)
|
|
|
f96e0b |
p0 = p;
|
|
|
f96e0b |
kern_end += p_size;
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_env_iterate (iterate_env);
|
|
|
f96e0b |
+ FOR_SORTED_ENV (var)
|
|
|
f96e0b |
+ if ((grub_memcmp (var->name, "kFreeBSD.", sizeof("kFreeBSD.") - 1) == 0) && (var->name[sizeof("kFreeBSD.") - 1]))
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_strcpy ((char *) p, &var->name[sizeof("kFreeBSD.") - 1]);
|
|
|
f96e0b |
+ p += grub_strlen ((char *) p);
|
|
|
f96e0b |
+ *(p++) = '=';
|
|
|
f96e0b |
+ grub_strcpy ((char *) p, var->value);
|
|
|
f96e0b |
+ p += grub_strlen ((char *) p) + 1;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
if (p != p0)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
|
|
|
f96e0b |
index 8c522f5..cdd9715 100644
|
|
|
f96e0b |
--- a/grub-core/loader/xnu.c
|
|
|
f96e0b |
+++ b/grub-core/loader/xnu.c
|
|
|
f96e0b |
@@ -1332,8 +1332,8 @@ unescape (char *name, char *curdot, char *nextdot, int *len)
|
|
|
f96e0b |
grub_err_t
|
|
|
f96e0b |
grub_xnu_fill_devicetree (void)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- auto int iterate_env (struct grub_env_var *var);
|
|
|
f96e0b |
- int iterate_env (struct grub_env_var *var)
|
|
|
f96e0b |
+ struct grub_env_var *var;
|
|
|
f96e0b |
+ FOR_SORTED_ENV (var)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
char *nextdot = 0, *curdot;
|
|
|
f96e0b |
struct grub_xnu_devtree_key **curkey = &grub_xnu_devtree_root;
|
|
|
f96e0b |
@@ -1343,7 +1343,7 @@ grub_xnu_fill_devicetree (void)
|
|
|
f96e0b |
|
|
|
f96e0b |
if (grub_memcmp (var->name, "XNU.DeviceTree.",
|
|
|
f96e0b |
sizeof ("XNU.DeviceTree.") - 1) != 0)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
|
|
|
f96e0b |
curdot = var->name + sizeof ("XNU.DeviceTree.") - 1;
|
|
|
f96e0b |
nextdot = grub_strchr (curdot, '.');
|
|
|
f96e0b |
@@ -1354,7 +1354,7 @@ grub_xnu_fill_devicetree (void)
|
|
|
f96e0b |
name = grub_realloc (name, nextdot - curdot + 1);
|
|
|
f96e0b |
|
|
|
f96e0b |
if (!name)
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
+ return grub_errno;
|
|
|
f96e0b |
|
|
|
f96e0b |
unescape (name, curdot, nextdot, &len;;
|
|
|
f96e0b |
name[len - 1] = 0;
|
|
|
f96e0b |
@@ -1372,7 +1372,7 @@ grub_xnu_fill_devicetree (void)
|
|
|
f96e0b |
name = grub_realloc (name, nextdot - curdot + 1);
|
|
|
f96e0b |
|
|
|
f96e0b |
if (!name)
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
+ return grub_errno;
|
|
|
f96e0b |
|
|
|
f96e0b |
unescape (name, curdot, nextdot, &len;;
|
|
|
f96e0b |
name[len] = 0;
|
|
|
f96e0b |
@@ -1382,18 +1382,14 @@ grub_xnu_fill_devicetree (void)
|
|
|
f96e0b |
|
|
|
f96e0b |
data = grub_malloc (grub_strlen (var->value) + 1);
|
|
|
f96e0b |
if (!data)
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
+ return grub_errno;
|
|
|
f96e0b |
|
|
|
f96e0b |
unescape (data, var->value, var->value + grub_strlen (var->value),
|
|
|
f96e0b |
&len;;
|
|
|
f96e0b |
curvalue->datasize = len;
|
|
|
f96e0b |
curvalue->data = data;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_env_iterate (iterate_env);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
return grub_errno;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/include/grub/env.h b/include/grub/env.h
|
|
|
f96e0b |
index ef42582..76f832e 100644
|
|
|
f96e0b |
--- a/include/grub/env.h
|
|
|
f96e0b |
+++ b/include/grub/env.h
|
|
|
f96e0b |
@@ -39,13 +39,17 @@ struct grub_env_var
|
|
|
f96e0b |
grub_env_write_hook_t write_hook;
|
|
|
f96e0b |
struct grub_env_var *next;
|
|
|
f96e0b |
struct grub_env_var **prevp;
|
|
|
f96e0b |
+ struct grub_env_var *sorted_next;
|
|
|
f96e0b |
int global;
|
|
|
f96e0b |
};
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
|
|
|
f96e0b |
const char *EXPORT_FUNC(grub_env_get) (const char *name);
|
|
|
f96e0b |
void EXPORT_FUNC(grub_env_unset) (const char *name);
|
|
|
f96e0b |
-void EXPORT_FUNC(grub_env_iterate) (int (*func) (struct grub_env_var *var));
|
|
|
f96e0b |
+struct grub_env_var *EXPORT_FUNC(grub_env_update_get_sorted) (void);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+#define FOR_SORTED_ENV(var) for (var = grub_env_update_get_sorted (); var; var = var->sorted_next)
|
|
|
f96e0b |
+
|
|
|
f96e0b |
grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
|
|
|
f96e0b |
grub_env_read_hook_t read_hook,
|
|
|
f96e0b |
grub_env_write_hook_t write_hook);
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|