about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-05-09 21:42:24 -0700
committerEric Wong <normalperson@yhbt.net>2009-05-09 21:42:24 -0700
commitbcf7eb013fc3e8719229256f40c33ced212dd815 (patch)
tree3654a72b9bb8e670f8993da39875d284d8ca01d5
parent246b02f9e3a7703384f5acf7af7724410bf2ae9b (diff)
downloadpcu-bcf7eb013fc3e8719229256f40c33ced212dd815.tar.gz
mincore: fix offset calculations
-rw-r--r--mincore.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mincore.c b/mincore.c
index ff0edc3..0379481 100644
--- a/mincore.c
+++ b/mincore.c
@@ -25,7 +25,7 @@ static void mincore_stats(const char *path, off_t offset, off_t len)
                                 path, fd, strerror(errno));
                         goto err_close;
                 }
-                len = sb.st_size;
+                len = sb.st_size - offset;
         }
 
         vec_len = (len + page_size() - 1) / page_size();
@@ -36,7 +36,7 @@ static void mincore_stats(const char *path, off_t offset, off_t len)
         }
 
         map_len = PAGE_ALIGN(len);
-        map_offset = PAGE_ALIGN_DOWN(offset);
+        map_offset = PAGE_ALIGN_DOWN(offset + 1);
 
         map = mmap(NULL, map_len, PROT_READ, MAP_SHARED, fd, map_offset);
         if (!map) {