1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| static ssize_t write(struct file *file, char *buf, size_t count, loff_t *ppos)
{
int ecrits = 0;
int i = 0;
s_driver *p = (s_driver*)file->private_data;
printk(KERN_DEBUG "write: demande ecriture de %d octets\n", count);
/* Check for overflow */
if (count <= buf_size - (int)*ppos)
ecrits = count;
else ecrits = buf_size - (int)*ppos;
if(ecrits)
copy_from_user((int *)p->buffer + (int)*ppos, buf, ecrits);
*ppos += ecrits;
printk(KERN_DEBUG "write: %d octets reellement ecrits\n", ecrits);
printk(KERN_DEBUG "write: position=%d\n", (int)*ppos);
printk(KERN_DEBUG "write: contenu du buffer\n");
for(i=0;i<buf_size;i++)
printk(KERN_DEBUG " %d", p->buffer[i]);
printk(KERN_DEBUG "\n");
return ecrits;
} |
Partager