OSDN Git Service

Handle EOF when reading /proc/<pid>/pagemap
authorColin Cross <ccross@android.com>
Wed, 13 Jul 2011 20:35:20 +0000 (13:35 -0700)
committerColin Cross <ccross@android.com>
Wed, 13 Jul 2011 20:35:20 +0000 (13:35 -0700)
Instead of handling maps with the name "[vectors]" specially,
silently ignore EOF when reading from /proc/<pid>/pagemap, which
occurs any time a a mapping is outside of the userspace range.

Change-Id: I674ade1eab6fd7732c6d9e120d0750cca5415b25

libpagemap/pm_process.c

index 0f54b48..b3c077e 100644 (file)
@@ -116,7 +116,13 @@ int pm_process_pagemap_range(pm_process_t *proc,
         return error;
     }
     error = read(proc->pagemap_fd, (char*)range, numpages * sizeof(uint64_t));
-    if (error < numpages * sizeof(uint64_t)) {
+    if (error == 0) {
+        /* EOF, mapping is not in userspace mapping range (probably vectors) */
+        *len = 0;
+        free(range);
+        *range_out = NULL;
+        return 0;
+    } else if (error < 0 || (error > 0 && error < numpages * sizeof(uint64_t))) {
         error = (error < 0) ? errno : -1;
         free(range);
         return error;
@@ -258,9 +264,6 @@ static int read_maps(pm_process_t *proc) {
         sscanf(line, "%lx-%lx %s %lx %*s %*d %" S(MAX_LINE) "s",
                &map->start, &map->end, perms, &map->offset, name);
 
-        if (!strcmp(name, "[vectors]"))
-            continue;
-
         map->name = malloc(strlen(name) + 1);
         if (!map->name) {
             error = errno;