- read and write data to device
- return values:
- = count: the requested amount of bytes were read/written
- < count: count bytes were read/written (no error!)
- = 0: read: EOF, write: unspecified (old: equals EAGAIN)
- < 0: error
-
stdio
library handles partial reads/writes
- carefull with userspace pointers!
- could be unmapped in kernel space
- could be swapped out
- could be invalid!
API
read and write file operations:
ssize_t read(struct file *filp, char __user *buff, size_t count, loff_t *f_pos);
ssize_t write(struct file *filp, const char __user *buff, size_t count, loff_t *f_pos);
userspace access:
unsigned long copy_to_user(void __user *to, const void *from, unsigned long count);
unsigned long copy_from_user(void *to, const void __user *from, unsigned long count);