]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
Store the process pid to the maps structure
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 3 Jul 2010 12:17:25 +0000 (15:17 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 3 Jul 2010 12:17:25 +0000 (15:17 +0300)
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
pagemap.h
parse.c

index c2a78d9d8e5fd9d37de40d708b591fb6dda0c3d1..b38a1e4278803f125d3ddbef234365ffae794165 100644 (file)
--- a/pagemap.h
+++ b/pagemap.h
@@ -32,10 +32,9 @@ struct maps {
        unsigned long end;
        unsigned long size;
 
-       /*
-        * Name of the mapping, such as library name or something else
-        */
+       /* Name of the mapping, such as library name or something else */
        char name[128];
+       int pid; /* Process which address space the mapping belongs to */
 };
 
 #define list_to_maps(list_head)                                \
diff --git a/parse.c b/parse.c
index a9c3f8f2a09393c93c97c04907adfd4e9aeb3641..2cef4ea58a44d1a4e09a448f0dd58e82640950f8 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -20,7 +20,7 @@ err:
        return map;
 }
 
-static struct maps *parse_maps(FILE *file)
+static struct maps *parse_maps(FILE *file, int pid)
 {
        struct maps *the_map = NULL;
        char line[1024];
@@ -51,6 +51,7 @@ static struct maps *parse_maps(FILE *file)
                map->start = start;
                map->end = end;
                map->size = end - start;
+               map->pid = pid;
 
                if (ret >= 3)
                        strncpy(map->name, name, sizeof(map->name));
@@ -186,7 +187,7 @@ struct pageframe *read_pageframe(int pid, struct pageframe *pageframe)
        if (!file)
                goto err_out;
 
-       maps = parse_maps(file);
+       maps = parse_maps(file, pid);
 
        snprintf(path, sizeof(path), "/proc/%d/pagemap", pid);
        file = fopen(path, "rb");