mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: start plumbing mounts into namespaces
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
#include "sysprof-document-frame-private.h"
|
||||
#include "sysprof-document-mmap.h"
|
||||
#include "sysprof-document-symbols-private.h"
|
||||
#include "sysprof-mount-private.h"
|
||||
#include "sysprof-mount-device-private.h"
|
||||
#include "sysprof-mount-namespace-private.h"
|
||||
#include "sysprof-symbolizer-private.h"
|
||||
@ -327,30 +328,12 @@ sysprof_document_load_mounts (SysprofDocument *self)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_load_mountinfo_line (SysprofDocument *self,
|
||||
int pid,
|
||||
const char *line)
|
||||
{
|
||||
g_auto(GStrv) parts = NULL;
|
||||
gsize n_parts;
|
||||
|
||||
g_assert (SYSPROF_IS_DOCUMENT (self));
|
||||
g_assert (line != NULL);
|
||||
|
||||
parts = g_strsplit (line, " ", 0);
|
||||
n_parts = g_strv_length (parts);
|
||||
|
||||
if (n_parts < 10)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_load_mountinfo (SysprofDocument *self,
|
||||
int pid,
|
||||
GBytes *bytes)
|
||||
{
|
||||
g_autoptr(SysprofMountNamespace) mount_namespace = NULL;
|
||||
const char *contents;
|
||||
LineReader reader;
|
||||
gsize contents_len;
|
||||
@ -365,11 +348,17 @@ sysprof_document_load_mountinfo (SysprofDocument *self,
|
||||
g_assert (contents != NULL);
|
||||
g_assert (contents[contents_len] == 0);
|
||||
|
||||
mount_namespace = sysprof_mount_namespace_copy (self->mount_namespace);
|
||||
|
||||
line_reader_init (&reader, (char *)contents, contents_len);
|
||||
while ((line = line_reader_next (&reader, &line_len)))
|
||||
{
|
||||
g_autoptr(SysprofMount) mount = NULL;
|
||||
|
||||
line[line_len] = 0;
|
||||
sysprof_document_load_mountinfo_line (self, pid, line);
|
||||
|
||||
if ((mount = sysprof_mount_new_for_mountinfo (line)))
|
||||
sysprof_mount_namespace_add_mount (mount_namespace, g_steal_pointer (&mount));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "sysprof-mount-private.h"
|
||||
#include "sysprof-mount-device-private.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -35,9 +36,7 @@ SysprofMountNamespace *sysprof_mount_namespace_copy (SysprofMountNamespa
|
||||
void sysprof_mount_namespace_add_device (SysprofMountNamespace *self,
|
||||
SysprofMountDevice *mount);
|
||||
void sysprof_mount_namespace_add_mount (SysprofMountNamespace *self,
|
||||
const char *path,
|
||||
const char *host_path,
|
||||
int layer);
|
||||
SysprofMount *mount);
|
||||
char **sysprof_mount_namespace_translate (SysprofMountNamespace *self,
|
||||
const char *path);
|
||||
GMappedFile *sysprof_mount_namespace_open (SysprofMountNamespace *self,
|
||||
|
||||
@ -26,6 +26,7 @@ struct _SysprofMountNamespace
|
||||
{
|
||||
GObject parent_instance;
|
||||
GPtrArray *devices;
|
||||
GPtrArray *mounts;
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofMountNamespace, sysprof_mount_namespace, G_TYPE_OBJECT)
|
||||
@ -36,6 +37,7 @@ sysprof_mount_namespace_finalize (GObject *object)
|
||||
SysprofMountNamespace *self = (SysprofMountNamespace *)object;
|
||||
|
||||
g_clear_pointer (&self->devices, g_ptr_array_unref);
|
||||
g_clear_pointer (&self->mounts, g_ptr_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_mount_namespace_parent_class)->finalize (object);
|
||||
}
|
||||
@ -92,3 +94,19 @@ sysprof_mount_namespace_add_device (SysprofMountNamespace *self,
|
||||
|
||||
g_ptr_array_add (self->devices, device);
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_mount_namespace_add_mount:
|
||||
* @self: a #SysprofMountNamespace
|
||||
* @mount: (transfer full): a #SysprofMount
|
||||
*
|
||||
*/
|
||||
void
|
||||
sysprof_mount_namespace_add_mount (SysprofMountNamespace *self,
|
||||
SysprofMount *mount)
|
||||
{
|
||||
g_return_if_fail (SYSPROF_IS_MOUNT_NAMESPACE (self));
|
||||
g_return_if_fail (SYSPROF_IS_MOUNT (mount));
|
||||
|
||||
g_ptr_array_add (self->mounts, mount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user