From a175bb9be830984b6ac54bbc87551dffa3354190 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 9 May 2009 20:52:55 -0700 Subject: mincore: show byte offset instead of page offset The page offset is architecture and kernel-dependent, whereas the byte offset is universally understood. --- mincore.c | 6 +++--- 1 file 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: -- cgit v1.2.3-24-ge0c7