From c9a8172990b981515fb495bee38f0ec17664639a Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Thu, 19 Dec 2013 11:58:46 -0500 Subject: fix mmap size and check return val --- uioctl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/uioctl.c b/uioctl.c index f9be716..2f0f5df 100644 --- a/uioctl.c +++ b/uioctl.c @@ -210,7 +210,16 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Couldn't open UIO device file: %s\n", fpath); return EXIT_FAILURE; } - ptr = mmap(NULL, map_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + /* NOTE: with UIO the offset is not a normal offset; it's a region + * selector. + */ + ptr = mmap(NULL, map_size + addr, PROT_READ|PROT_WRITE, + MAP_SHARED, fd, 0); + if (ptr == MAP_FAILED) { + perror("mmap"); + fprintf(stderr, "Couldn't mmap.\n"); + return EXIT_FAILURE; + } if (mode == MODE_READ) { for (; count > 0; count--) { -- cgit v1.2.3