aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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--) {