From f3b4e1ca927ff5cdcac2e88388d6e36f9405f23f Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 28 Aug 2023 21:56:56 -0700 Subject: [PATCH] libsysprof: propagate devices to processinfo We need access to this from the process info but can share the instance. It sucks to walk the hashtable here, but the alternative is to make these recursive so that we can check a parent mount namespace. Until then, take the hit and iterate all the pids to populate them with the additional device. Related GNOME/gnome-builder#2090 --- src/libsysprof/sysprof-document.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libsysprof/sysprof-document.c b/src/libsysprof/sysprof-document.c index 5e57a2fb..9f1d845b 100644 --- a/src/libsysprof/sysprof-document.c +++ b/src/libsysprof/sysprof-document.c @@ -580,6 +580,7 @@ sysprof_document_load_mounts (SysprofDocument *self) g_autoptr(SysprofDocumentFile) file = NULL; g_autoptr(GBytes) bytes = NULL; LineReader reader; + GHashTableIter iter; const char *contents; gsize contents_len; gsize line_len; @@ -599,6 +600,8 @@ sysprof_document_load_mounts (SysprofDocument *self) line_reader_init (&reader, (char *)contents, contents_len); while ((line = line_reader_next (&reader, &line_len))) { + g_autoptr(SysprofMountDevice) mount_device = NULL; + SysprofProcessInfo *process_info = NULL; g_autofree char *subvol = NULL; g_auto(GStrv) parts = NULL; const char *filesystem; @@ -641,10 +644,17 @@ sysprof_document_load_mounts (SysprofDocument *self) } } - sysprof_mount_namespace_add_device (self->mount_namespace, - sysprof_mount_device_new (sysprof_strings_get (self->strings, device), - sysprof_strings_get (self->strings, mountpoint), - sysprof_strings_get (self->strings, subvol))); + mount_device = + sysprof_mount_device_new (sysprof_strings_get (self->strings, device), + sysprof_strings_get (self->strings, mountpoint), + sysprof_strings_get (self->strings, subvol)); + + g_hash_table_iter_init (&iter, self->pid_to_process_info); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&process_info)) + sysprof_mount_namespace_add_device (process_info->mount_namespace, + g_object_ref (mount_device)); + + sysprof_mount_namespace_add_device (self->mount_namespace, g_object_ref (mount_device)); } }