]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/mips/arc/init.c: Fix prefix detection.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 29 Apr 2013 09:59:18 +0000 (11:59 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 29 Apr 2013 09:59:18 +0000 (11:59 +0200)
ChangeLog
grub-core/kern/mips/arc/init.c

index 41a941cb75b422372888104b60580f8d7abf69a1..f444ea922ec3f3a1e67506c8fc5053ba699ec1a1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-04-29  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/mips/arc/init.c: Fix prefix detection.
+
 2013-04-29  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/lib/arg.c (grub_arg_show_help): Fix a NULL pointer
index d279ada7c8a58105ddc73cc6fc60cc41394b40a3..fdcc2bd22a1f2fb990a42c07d3ed274caa072629 100644 (file)
@@ -179,19 +179,26 @@ norm_name_to_alt (const char *name)
   optr = grub_stpcpy (ret, "arc/");
   for (iptr = name; *iptr; iptr++)
     {
-      if (state == 1)
+      if (state == 3)
        {
          *optr++ = '/';
          state = 0;
        }
       if (*iptr == '(')
-       continue;
-      if (*iptr == ')')
        {
          state = 1;
          continue;
        }
+      if (*iptr == ')')
+       {
+         if (state == 1)
+           *optr++ = '0';
+         state = 3;
+         continue;
+       }
       *optr++ = *iptr;
+      if (state == 1)
+       state = 2;
     }
   *optr = '\0';
   return ret;
@@ -353,13 +360,48 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
   grub_disk_addr_t poff = -1, pend;
   struct get_device_name_ctx ctx;
   grub_disk_t parent = 0;
-
-  pptr = grub_strchr (loaddev, '/');
-  if (pptr)
+  unsigned i;
+
+  for (i = 0; i < ARRAY_SIZE (type_names); i++)
+    if (type_names[i]
+       && grub_memcmp (loaddev, type_names[i], grub_strlen (type_names[i])) == 0
+       && loaddev[grub_strlen (type_names[i])] == '(')
+      break;
+  if (i == ARRAY_SIZE (type_names))
+    pptr = loaddev;
+  else
+    for (pptr = loaddev; *pptr && *pptr != '/' && *pptr != '\\'; pptr++);
+  if (*pptr)
     {
+      char *iptr, *optr;
+      char sep = *pptr;
+      *path = grub_malloc (grub_strlen (pptr) + 1);
+      if (!*path)
+       return;
+      for (iptr = pptr, optr = *path; *iptr; iptr++, optr++)
+       if (*iptr == sep)
+         *optr = '/';
+       else
+         *optr = *iptr;
+      *optr = '\0';
       *path = grub_strdup (pptr);
       *pptr = '\0';
     }
+
+  if (*loaddev == '\0')
+    {
+      const char *syspart = 0;
+
+      if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
+         >= ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable + 1)
+             - (char *) GRUB_ARC_FIRMWARE_VECTOR)
+         && GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable)
+       syspart = GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable ("SystemPartition");
+      if (!syspart)
+       return;
+      loaddev = grub_strdup (syspart);
+    }
+
   partptr = get_part (loaddev);
   if (partptr)
     {
@@ -370,6 +412,8 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
   if (poff == (grub_addr_t) -1)
     {
       *device = dname;
+      if (loaddev != boot_location)
+       grub_free (loaddev);
       return;
     }
 
@@ -377,6 +421,8 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
   if (!parent)
     {
       *device = dname;
+      if (loaddev != boot_location)
+       grub_free (loaddev);
       return;
     }
 
@@ -385,6 +431,8 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
     {
       grub_disk_close (parent);
       *device = dname;
+      if (loaddev != boot_location)
+       grub_free (loaddev);
       return;
     }
 
@@ -398,6 +446,8 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
   if (! ctx.partition_name)
     {
       *device = dname;
+      if (loaddev != boot_location)
+       grub_free (loaddev);
       return;
     }
 
@@ -405,4 +455,6 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
                            ctx.partition_name);
   grub_free (ctx.partition_name);
   grub_free (dname);
+  if (loaddev != boot_location)
+    grub_free (loaddev);
 }