October 2017
Intermediate to advanced
586 pages
14h 8m
English
if (*pos >= filesize) return 0; /* 0 means EOF */
if (*pos + count > filesize)
count = filesize - (*pos);
void *from = pos_to_address (*pos); /* convert pos into valid address */
sent = copy_to_user(buf, from, count);
if (sent)
return -EFAULT;
*pos += count; return count;
The following is an example of a driver read() file operation, ...