int mm_protect(MM *mm, int mode) {
int pmode = 0;
if (mode & MM_PROT_NONE) {
pmode |= PROT_NONE;
}
if (mode & MM_PROT_READ) {
pmode |= PROT_READ;
}
if (mode & MM_PROT_WRITE) {
pmode |= PROT_WRITE;
}
if (mode & MM_PROT_EXEC) {
pmode |= PROT_EXEC;
}
return (mprotect(mm, mm->size, pmode) == 0);
}