[sysprof: 1/2] elfparser: Try original filename too




commit 3b180b313be859abf36522e245e36c8e267198f2
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Fri Oct 8 11:27:37 2021 +0300

    elfparser: Try original filename too
    
    Fixes Sysprof running under Flatpak (e.g. from Builder) being unable to
    resolve any paths on Silverblue.

 src/libsysprof/elfparser.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/libsysprof/elfparser.c b/src/libsysprof/elfparser.c
index ec427ae0..8816a716 100644
--- a/src/libsysprof/elfparser.c
+++ b/src/libsysprof/elfparser.c
@@ -278,13 +278,21 @@ static GMappedFile *
 open_mapped_file (const char  *filename,
                   GError     **error)
 {
-    GMappedFile *file;
+    GMappedFile *file = NULL;
     char *alternate = NULL;
 
     if (in_container () && !g_str_has_prefix (filename, g_get_home_dir ()))
-        filename = alternate = g_build_filename ("/var/run/host", filename, NULL);
-    file = g_mapped_file_new (filename, FALSE, error);
-    g_free (alternate);
+      {
+        alternate = g_build_filename ("/var/run/host", filename, NULL);
+        file = g_mapped_file_new (alternate, FALSE, NULL);
+        g_free (alternate);
+      }
+
+    /* Flatpaks with filesystem=host don't have Silverblue's /sysroot in /var/run/host,
+     * yet they have it in /, which means the original path might work.
+     */
+    if (!file)
+      file = g_mapped_file_new (filename, FALSE, error);
 
     return file;
 }


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