03. copy_from_user 寫入記憶體

03. copy_from_user 寫入記憶體

char *memory_buffer;

ssize_t memory_write( struct file *filp, char *buf,
                      size_t count, loff_t *f_pos) {

  char *tmp;
 if(memory_buffer==null){
      memory_buffer = kmalloc(1, GFP_KERNEL);
  }else{
    tmp=buf+count-1;
    copy_from_user(memory_buffer,tmp,1);
  }
  return 1;
}
Linux Driver
CH01 簡介CH02 註冊CH03 記憶體CH04 硬體函數CH05 USB