|
|
f96e0b |
From 5605655af5a8fbb1d26ad567082c00606b425ae4 Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
Date: Mon, 29 Apr 2013 11:59:18 +0200
|
|
|
f96e0b |
Subject: [PATCH 384/482] * grub-core/kern/mips/arc/init.c: Fix prefix
|
|
|
f96e0b |
detection.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 4 +++
|
|
|
f96e0b |
grub-core/kern/mips/arc/init.c | 64 ++++++++++++++++++++++++++++++++++++++----
|
|
|
f96e0b |
2 files changed, 62 insertions(+), 6 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index 41a941c..f444ea9 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,5 +1,9 @@
|
|
|
f96e0b |
2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
+ * grub-core/kern/mips/arc/init.c: Fix prefix detection.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
* grub-core/lib/arg.c (grub_arg_show_help): Fix a NULL pointer
|
|
|
f96e0b |
dereference.
|
|
|
f96e0b |
Reported by: qwertial.
|
|
|
f96e0b |
diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c
|
|
|
f96e0b |
index d279ada..fdcc2bd 100644
|
|
|
f96e0b |
--- a/grub-core/kern/mips/arc/init.c
|
|
|
f96e0b |
+++ b/grub-core/kern/mips/arc/init.c
|
|
|
f96e0b |
@@ -179,19 +179,26 @@ norm_name_to_alt (const char *name)
|
|
|
f96e0b |
optr = grub_stpcpy (ret, "arc/");
|
|
|
f96e0b |
for (iptr = name; *iptr; iptr++)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- if (state == 1)
|
|
|
f96e0b |
+ if (state == 3)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
*optr++ = '/';
|
|
|
f96e0b |
state = 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
if (*iptr == '(')
|
|
|
f96e0b |
- continue;
|
|
|
f96e0b |
- if (*iptr == ')')
|
|
|
f96e0b |
{
|
|
|
f96e0b |
state = 1;
|
|
|
f96e0b |
continue;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
+ if (*iptr == ')')
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ if (state == 1)
|
|
|
f96e0b |
+ *optr++ = '0';
|
|
|
f96e0b |
+ state = 3;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
*optr++ = *iptr;
|
|
|
f96e0b |
+ if (state == 1)
|
|
|
f96e0b |
+ state = 2;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
*optr = '\0';
|
|
|
f96e0b |
return ret;
|
|
|
f96e0b |
@@ -353,13 +360,48 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
|
|
f96e0b |
grub_disk_addr_t poff = -1, pend;
|
|
|
f96e0b |
struct get_device_name_ctx ctx;
|
|
|
f96e0b |
grub_disk_t parent = 0;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- pptr = grub_strchr (loaddev, '/');
|
|
|
f96e0b |
- if (pptr)
|
|
|
f96e0b |
+ unsigned i;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ for (i = 0; i < ARRAY_SIZE (type_names); i++)
|
|
|
f96e0b |
+ if (type_names[i]
|
|
|
f96e0b |
+ && grub_memcmp (loaddev, type_names[i], grub_strlen (type_names[i])) == 0
|
|
|
f96e0b |
+ && loaddev[grub_strlen (type_names[i])] == '(')
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ if (i == ARRAY_SIZE (type_names))
|
|
|
f96e0b |
+ pptr = loaddev;
|
|
|
f96e0b |
+ else
|
|
|
f96e0b |
+ for (pptr = loaddev; *pptr && *pptr != '/' && *pptr != '\\'; pptr++);
|
|
|
f96e0b |
+ if (*pptr)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
+ char *iptr, *optr;
|
|
|
f96e0b |
+ char sep = *pptr;
|
|
|
f96e0b |
+ *path = grub_malloc (grub_strlen (pptr) + 1);
|
|
|
f96e0b |
+ if (!*path)
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ for (iptr = pptr, optr = *path; *iptr; iptr++, optr++)
|
|
|
f96e0b |
+ if (*iptr == sep)
|
|
|
f96e0b |
+ *optr = '/';
|
|
|
f96e0b |
+ else
|
|
|
f96e0b |
+ *optr = *iptr;
|
|
|
f96e0b |
+ *optr = '\0';
|
|
|
f96e0b |
*path = grub_strdup (pptr);
|
|
|
f96e0b |
*pptr = '\0';
|
|
|
f96e0b |
}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (*loaddev == '\0')
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ const char *syspart = 0;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
|
|
|
f96e0b |
+ >= ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable + 1)
|
|
|
f96e0b |
+ - (char *) GRUB_ARC_FIRMWARE_VECTOR)
|
|
|
f96e0b |
+ && GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable)
|
|
|
f96e0b |
+ syspart = GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable ("SystemPartition");
|
|
|
f96e0b |
+ if (!syspart)
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ loaddev = grub_strdup (syspart);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
partptr = get_part (loaddev);
|
|
|
f96e0b |
if (partptr)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
@@ -370,6 +412,8 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
|
|
f96e0b |
if (poff == (grub_addr_t) -1)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
*device = dname;
|
|
|
f96e0b |
+ if (loaddev != boot_location)
|
|
|
f96e0b |
+ grub_free (loaddev);
|
|
|
f96e0b |
return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -377,6 +421,8 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
|
|
f96e0b |
if (!parent)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
*device = dname;
|
|
|
f96e0b |
+ if (loaddev != boot_location)
|
|
|
f96e0b |
+ grub_free (loaddev);
|
|
|
f96e0b |
return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -385,6 +431,8 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_disk_close (parent);
|
|
|
f96e0b |
*device = dname;
|
|
|
f96e0b |
+ if (loaddev != boot_location)
|
|
|
f96e0b |
+ grub_free (loaddev);
|
|
|
f96e0b |
return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -398,6 +446,8 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
|
|
f96e0b |
if (! ctx.partition_name)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
*device = dname;
|
|
|
f96e0b |
+ if (loaddev != boot_location)
|
|
|
f96e0b |
+ grub_free (loaddev);
|
|
|
f96e0b |
return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -405,4 +455,6 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
|
|
f96e0b |
ctx.partition_name);
|
|
|
f96e0b |
grub_free (ctx.partition_name);
|
|
|
f96e0b |
grub_free (dname);
|
|
|
f96e0b |
+ if (loaddev != boot_location)
|
|
|
f96e0b |
+ grub_free (loaddev);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|