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

View File

@ -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;
} }