Beispiel #1
0
int
munprotect(void *addr, int len)
{
   int ret = -1;
	uint addrint = (uint)addr;
    //Checks if page-aligned
   if (addrint % PGSIZE != 0) 
   {
    return ret;
   }
  
   //Check if addr is not too large
   /*
   int procint = *proc;
   if ( (*addrint +len) > (procint + proc->sz) ) 
   {
    return -1;
   }
   */

   //cprintf("%s%d\n", "lengthoutside = ", len);
   if(len <= 0)	
   {
		//cprintf("%s%d\n", "lengthinside = ", len);
		//cprintf("-1 on 1\n");
	  	return ret;
   }

   if(addrint + (len * PGSIZE) > proc->sz)
   {
	  //cprintf("-1 on 2\n");
	  return ret;
   }

   if(addrint  > proc->sz || addrint <= 0)
   {
      //cprintf("-1 on 3\n");
	  return ret;
   }


	//NOT SURE IF WE NEED ALL THIS CODE -CONOR
   //int pid = proc->pid:
   //int *addrint = addr;
   //acquire(&ptable.lock);
   //if (pid < 0 || pid >= NPROC) {
    //   release(&ptable.lock); 
	//   return ret;
  // }

  
   ret = 0;
   do_munprotect(proc, addr);

   return ret;
}
Beispiel #2
0
int kern_munprotect(void * addr, int len) {
	if ((int)addr % PGSIZE != 0)
		return -1;
	//  another check needed: addr too large
	if  ((uint)addr <= 0 || (uint)addr > proc->sz)
		return -1;
	if  (len <= 0 || (len*PGSIZE)+(int)addr > proc->sz)
		return -1;
	
	
	acquire(&ptable.lock);
    do_munprotect(proc, (int)addr, len);
    release(&ptable.lock);
    return 0;
}
Beispiel #3
0
int
kern_munprotect(void *addr, int len){
    if((int)addr % PGSIZE != 0)
        return -1;
    if((int)addr >= proc->sz || (int)addr + 4 > proc->sz)
        return -1;
    if(len <= 0)
        return -1;
    if((int)addr + (len * PGSIZE) > proc->sz)
       return -1;
    if(addr == 0)
       return -1;
    do_munprotect((void*)addr,len);
    return 0;
}
Beispiel #4
0
int kern_munprotect(struct proc* process,void* addr, int len) {
	unsigned int start = (unsigned int) addr;

	//bounds checking
	if (addr == 0) return -1; // fail on null address

	if (start % PGSIZE != 0) return -1;
	if (start > process->sz) return -1;
	if (len <= 0) return -1;
	if ((start + PGSIZE*len) > process->sz) return -1;

	int i;
	for (i = start; i < start + (len * PGSIZE); i+= PGSIZE) {
		if (do_munprotect(process, (void*) i) == -1)
			return -1; // propagate -1 to user process
	}

	lcr3(v2p(process->pgdir));
	return 0;
}