- uintptr_t pa = pmm_alloc_page(__current->pid, 0);
- *pte = *pte | pa | PG_PRESENT;
+ *pte = (*pte & 0xFFF) | pa | PG_PRESENT;
+
+ ptr = ptr & ~(PG_SIZE - 1);
+ memset(ptr, 0, PG_SIZE);
+
+ int errno = file->ops->read_page(file->inode, ptr, PG_SIZE, offset);
+ if (errno < 0) {
+ kprintf(KERROR "fail to read page (%d)\n", errno);
+ goto segv_term;
+ }
+