From 5bf178e07bdbda0102cbb1a95f514d5de98c015d Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 23 May 2023 15:39:27 -0700 Subject: [PATCH] libsysprof-analyze: include mount root when translating Additionally, if we're on a subvolume, and that subvolume matches the prefix of the root, then skip past that. I have no idea if this is the right thing to do, but it's what we were doing before and seems to be able to help us get proper path resolving on Silverblue. --- .../sysprof-mount-namespace.c | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/libsysprof-analyze/sysprof-mount-namespace.c b/src/libsysprof-analyze/sysprof-mount-namespace.c index 7e146471..52bff189 100644 --- a/src/libsysprof-analyze/sysprof-mount-namespace.c +++ b/src/libsysprof-analyze/sysprof-mount-namespace.c @@ -266,17 +266,31 @@ sysprof_mount_namespace_translate (SysprofMountNamespace *self, if (!(relative = _sysprof_mount_get_relative_path (mount, file))) continue; - if (!mount->is_overlay) + if (mount->is_overlay) { + translated = g_build_filename (mount->mount_source, relative, NULL); + } + else + { + const char *root; + const char *subvolume; + if (!(device = sysprof_mount_namespace_find_device (self, mount, relative))) continue; device_mount_point = sysprof_mount_device_get_mount_point (device); - translated = g_build_filename (device_mount_point, relative, NULL); - } - else - { - translated = g_build_filename (mount->mount_source, relative, NULL); + root = sysprof_mount_get_root (mount); + subvolume = sysprof_mount_device_get_subvolume (device); + + if (root != NULL && subvolume != NULL) + { + if (g_strcmp0 (root, subvolume) == 0) + root = "/"; + else if (g_str_has_prefix (root, subvolume) && root[strlen (subvolume)] == '/') + root += strlen (subvolume); + } + + translated = g_build_filename (device_mount_point, root, relative, NULL); } g_array_append_val (strv, translated);