96) || (count>4096)) return 0; /* 判断是否已经到设备尾,或写的长度超过设备大小 */
pos += count;
if (pos > 4096) {
count -= (pos - 4096);
pos = 4096;
}
if (copy_to_user(buf, asdf_body+*f_pos, count)) return -EFAULT; /* 把数据写到应用程序空间 */
*f_pos = pos; /* 改变文件的读写位置 */
return count; /* 返回读到的字节数 */
}
static ssize_t
asdf_write /* write回调,和read一一对应 */
(
struct file *filp,
const char *buf,
size_t count,
loff页码:[1] [2] [3] [4] [5] 第2页、共5页 |