userspace: mmap test read and write
This commit is contained in:
parent
62a1c1cefb
commit
ccfafe4a04
@ -56,11 +56,13 @@ int func_alloc()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int func_mmap()
|
int func_mmap() {
|
||||||
{
|
|
||||||
|
|
||||||
char *path = "/dev/zero";
|
char *path = "/dev/zero";
|
||||||
mmap(0, 4096, 0, 0, path);
|
void *mapAddr = mmap((void *)4096, 4096, PROT_READ | PROT_WRITE, 0, path);
|
||||||
|
printf("Zero mmaped at %p\n", mapAddr);
|
||||||
|
int data = *(int *)mapAddr;
|
||||||
|
*(int *)mapAddr = data;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user