userspace: mmap test read and write

This commit is contained in:
Mathieu Maret 2024-02-07 23:17:55 +01:00 committed by Mathieu Maret
parent 62a1c1cefb
commit ccfafe4a04
1 changed files with 6 additions and 4 deletions

View File

@ -56,11 +56,13 @@ int func_alloc()
return 0;
}
int func_mmap()
{
int func_mmap() {
char *path ="/dev/zero";
mmap(0, 4096, 0, 0, path);
char *path = "/dev/zero";
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;
}