grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCHv2] hurd: Support device entries with @/dev/disk: qualifier


From: Samuel Thibault
Subject: [PATCHv2] hurd: Support device entries with @/dev/disk: qualifier
Date: Thu, 24 Feb 2022 00:34:13 +0100
User-agent: NeoMutt/20170609 (1.8.3)

Those are used with non-bootstrap disk drivers, for which libstore has to
open /dev/disk before calling device_open on it instead of on the device
master port.  Normally in that case all /dev/ entries also have the @/dev/disk:
qualifier, so we can just drop it.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
Difference with v1: better drop the @/dev/disk: qualifier right from
grub_util_hurd_get_disk_info so it benefits alls the callees and not
only grub_util_part_to_disk.

Index: grub2-2.06/grub-core/osdep/hurd/getroot.c
===================================================================
--- grub2-2.06.orig/grub-core/osdep/hurd/getroot.c
+++ grub2-2.06/grub-core/osdep/hurd/getroot.c
@@ -112,11 +112,23 @@ grub_util_find_hurd_root_device (const c
   if (strncmp (name, "device:", sizeof ("device:") - 1) == 0)
     {
       char *dev_name = name + sizeof ("device:") - 1;
-      size_t size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1;
-      char *next;
-      ret = malloc (size);
-      next = stpncpy (ret, "/dev/", size);
-      stpncpy (next, dev_name, size - (next - ret));
+
+      if (dev_name[0] == '@')
+        {
+          /* non-bootstrap disk driver, the /dev/ entry is normally set up with
+             the same @.  */
+          char *next_name = strchr (dev_name, ':');
+          if (next_name)
+            dev_name = next_name + 1;
+        }
+
+      {
+        size_t size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1;
+        char *next;
+        ret = malloc (size);
+        next = stpncpy (ret, "/dev/", size);
+        stpncpy (next, dev_name, size - (next - ret));
+      }
     }
   else if (!strncmp (name, "file:", sizeof ("file:") - 1))
     ret = strdup (name + sizeof ("file:") - 1);
Index: grub2-2.06/grub-core/osdep/hurd/hostdisk.c
===================================================================
--- grub2-2.06.orig/grub-core/osdep/hurd/hostdisk.c
+++ grub2-2.06/grub-core/osdep/hurd/hostdisk.c
@@ -87,6 +87,19 @@ grub_util_hurd_get_disk_info (const char
          *parent = xmalloc (len+1);
          memcpy (*parent, data, len);
          (*parent)[len] = '\0';
+
+         if ((*parent)[0] == '@')
+           {
+             /* non-bootstrap disk driver, the /dev/ entry is normally set up 
with
+                the same @.  */
+             char *next_path = strchr (*parent, ':');
+             if (next_path)
+               {
+                 char *n = strdup (next_path + 1);
+                 free (*parent);
+                 *parent = n;
+               }
+           }
        }
     }
   if (offset)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]