diff options
author | bryan newbold <bnewbold@leaflabs.com> | 2013-12-19 11:58:46 -0500 |
---|---|---|
committer | bryan newbold <bnewbold@leaflabs.com> | 2013-12-19 11:58:46 -0500 |
commit | c9a8172990b981515fb495bee38f0ec17664639a (patch) | |
tree | aeb224d9446a4eb90fba0afb6c73882d60710454 | |
parent | 250d52b9e2fbae7c6f63fe7a27775273e6d76b2f (diff) | |
download | uioctl-c9a8172990b981515fb495bee38f0ec17664639a.tar.gz uioctl-c9a8172990b981515fb495bee38f0ec17664639a.zip |
fix mmap size and check return val
-rw-r--r-- | uioctl.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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--) { |