diff mbox series

[RFC,v2,7/8] ppc/spapr: strip OF path argument suffix in path_offset

Message ID 20261002052605.605858-8-uverma@linux.ibm.com
State New
Headers show
Series ppc/spapr: VOF disk image (qcow2) boot support | expand

Commit Message

Utkarsh Verma Oct. 2, 2026, 5:25 a.m. UTC
From: Utkarsh Verma <uverma@linux.ibm.com>

OF paths can include a ":argument" suffix on the last component (e.g.
"disk@8000000000000000:0"), which is an OF path argument such as a
partition number.  This is not part of the FDT node name and causes
fdt_path_offset() to fail.

Strip any ":<suffix>" from the last path component only, leaving
intermediate components untouched.

AI-used-for: code
Signed-off-by: Utkarsh Verma <uverma@linux.ibm.com>
---
 hw/ppc/vof.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c
index d4b57b3b46..75b2398ae7 100644
--- a/hw/ppc/vof.c
+++ b/hw/ppc/vof.c
@@ -146,6 +146,7 @@  static int path_offset(const void *fdt, const char *path)
     g_autofree char *p = NULL;
     char *at;
     char *last_slash;
+    char *colon;
     int offset;
 
     /*
@@ -156,6 +157,20 @@  static int path_offset(const void *fdt, const char *path)
      * suppressing leading zeros".
      */
     p = g_strdup(path);
+
+    /*
+     * Strip any ":argument" suffix from the last path component (e.g.
+     * "disk@8000000000000000:0") — it is an OF path argument, not part of
+     * the FDT node name.
+     */
+    last_slash = strrchr(p, '/');
+    if (last_slash) {
+        colon = strchr(last_slash, ':');
+        if (colon) {
+            *colon = '\0';
+        }
+    }
+
     for (at = strchr(p, '@'); at && *at; ) {
             if (*at == '/') {
                 at = strchr(at, '@');