aboutsummaryrefslogtreecommitdiffstats
path: root/uioctl.c
diff options
context:
space:
mode:
authorbryan newbold <bnewbold@leaflabs.com>2013-12-19 11:58:46 -0500
committerbryan newbold <bnewbold@leaflabs.com>2013-12-19 11:58:46 -0500
commitc9a8172990b981515fb495bee38f0ec17664639a (patch)
treeaeb224d9446a4eb90fba0afb6c73882d60710454 /uioctl.c
parent250d52b9e2fbae7c6f63fe7a27775273e6d76b2f (diff)
downloaduioctl-c9a8172990b981515fb495bee38f0ec17664639a.tar.gz
uioctl-c9a8172990b981515fb495bee38f0ec17664639a.zip
fix mmap size and check return val
Diffstat (limited to 'uioctl.c')
-rw-r--r--uioctl.c11
1 files changed, 10 insertions, 1 deletions
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--) {