about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-05-09 20:52:55 -0700
committerEric Wong <normalperson@yhbt.net>2009-05-09 20:52:55 -0700
commita175bb9be830984b6ac54bbc87551dffa3354190 (patch)
treee79a8ee85508ccd1eb2ffb081a58eec4e958304d
parentac8967f99c74b6725e5e39a9010d8a3b0ee8d1cb (diff)
downloadpcu-a175bb9be830984b6ac54bbc87551dffa3354190.tar.gz
mincore: show byte offset instead of page offset
The page offset is architecture and kernel-dependent, whereas
the byte offset is universally understood.
-rw-r--r--mincore.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mincore.c b/mincore.c
index c6915f1..6b8b0e2 100644
--- a/mincore.c
+++ b/mincore.c
@@ -9,6 +9,8 @@ static void mincore_stats(const char *path)
         size_t map_len;
         int fd;
         size_t i;
+        static const char *fmt = sizeof(void *) == 8 ?
+                                 "%s: %016lu %x\n": "%s: %08lu %x\n";
 
         if ((fd = open(path, O_RDONLY|O_NOATIME)) < 0) {
                 fprintf(stderr, "%s: open(): %s\n", path, strerror(errno));
@@ -42,9 +44,7 @@ static void mincore_stats(const char *path)
         }
 
         for (i = 0; i < vec_len; ++i)
-                printf("%s: [%08lu] %x\n",
-                       path, (unsigned long)i,
-                       (vec[i]));
+                printf(fmt, path, (unsigned long)(page_size() * i), vec[i]);
 err_munmap:
         munmap(map, map_len);
 err_free: