Skip to content

Instantly share code, notes, and snippets.

@kerie
Created November 19, 2010 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kerie/706795 to your computer and use it in GitHub Desktop.
Save kerie/706795 to your computer and use it in GitHub Desktop.
static ssize_t rwbuf_write(struct file *filep, const char *buf, size_t count, loff_t *ppos)
{
if(count<=1024)
{
writenum++;
//printk(KERN_ALERT "write1\n");
copy_from_user(rwbuf,buf,count);
//printk(KERN_ALERT "write2\n");
rwlen = count;
//printk(KERN_ALERT "write ok\n");
return rwlen;
}
else
{
writenum++;
copy_from_user(rwbuf,buf,1024);
rwlen = 1024;
printk(KERN_ALERT "write overflow\n");
return rwlen;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment