All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hurd: Support device entries with @/dev/disk: qualifier
@ 2022-02-22 23:27 Samuel Thibault
  2022-02-23 23:34 ` [PATCHv2] " Samuel Thibault
  0 siblings, 1 reply; 6+ messages in thread
From: Samuel Thibault @ 2022-02-22 23:27 UTC (permalink / raw)
  To: grub-devel; +Cc: bug-hurd

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>

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);
@@ -166,12 +178,27 @@ grub_util_part_to_disk (const char *os_d
 		    || strncmp ("/dev/hd", os_dev, 7) == 0)))
     {
       *is_part = !is_fulldisk (path, os_dev);
+
+      if (path[0] == '@')
+        {
+          /* non-bootstrap disk driver, the /dev/ entry is normally set up with
+             the same @.  */
+          char *next_path = strchr (path, ':');
+          if (next_path)
+            {
+              char *n = strdup (next_path + 1);
+              free (path);
+              path = n;
+            }
+        }
+
       if (path[0] != '/')
 	{
 	  char *n = xasprintf ("/dev/%s", path);
 	  free (path);
 	  path = n;
 	}
+
       return path;
     }
   free (path);


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-17 14:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 23:27 [PATCH] hurd: Support device entries with @/dev/disk: qualifier Samuel Thibault
2022-02-23 23:34 ` [PATCHv2] " Samuel Thibault
2022-04-27 15:04   ` Daniel Kiper
2022-04-27 21:00     ` [PATCHv3] " Samuel Thibault
2022-05-17 14:22       ` Daniel Kiper
2022-05-17 14:42         ` Samuel Thibault

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.