static ssize_t mtest_proc_write(struct file *file, 
				const char __user * buffer,  
                                size_t count, loff_t * data)  
{        
    char buf[128];  
    unsigned long val, val2;  
    if (count > sizeof(buf))  
        return -EINVAL;  
      
    if (copy_from_user(buf, buffer, count))  
        return -EINVAL;  
      
    if (memcmp(buf, "listvma", 7) == 0)   
        mtest_list_vma();  

    else if (memcmp(buf, "findpage", 8) == 0){
        if (sscanf(buf + 8, "%lx", &val) == 1) 
            mtest_find_page(val);  
    }
  
    else  if (memcmp(buf, "writeval", 8) == 0){   
        if (sscanf(buf + 8, "%lx %lx", &val, &val2) == 2)  
            mtest_write_val(val, val2);   
    }
    else
        printk("No such command. Nothing to be done.\n");
    return count;  
}  
Beispiel #2
0
static ssize_t   
mtest_write(struct file *file, const char __user * buffer,  
	    size_t count, loff_t * data)  
{  
  
  
  printk("mtest_write  ...........  \n");       
  char buf[128];  
  unsigned long val, val2;  
  if (count > sizeof(buf))  
    return -EINVAL;  
      
  if (copy_from_user(buf, buffer, count))  
    return -EINVAL;  
      
  if (memcmp(buf, "listvma", 7) == 0)   
    mtest_dump_vma_list();  
      
  else if (memcmp(buf, "findvma", 7) == 0) {  
    if (sscanf(buf + 7, "%lx", &val) == 1) {  
      mtest_find_vma(val);  
    }  
  }  
  
  else if (memcmp(buf, "findpage", 8) == 0) {  
    if (sscanf(buf + 8, "%lx", &val) == 1) {  
      mtest_find_page(val);  
              
      //my_follow_page(vma, addr);  
              
              
    }  
  }  
  
  else  if (memcmp(buf, "writeval", 8) == 0) {  
    if (sscanf(buf + 8, "%lx %lx", &val, &val2) == 2) {  
      mtest_write_val(val, val2);  
    }  
  }  
  return count;  
}