Tag: linux kernel

cat函数调用read()无限次

我正在研究简单的字符设备驱动程序。 我在模块中实现了读写function,问题是当我尝试使用cat /dev/devicefile读取设备文件时,它会进入无限循环,即重复读取相同的数据。 有人可以建议我解决这个问题吗? 以下是我的驱动程序代码。 #include #include #include #include #include MODULE_LICENSE(“GPL”); MODULE_DESCRIPTION(“character device driver”); MODULE_AUTHOR(“Srinivas”); static char msg[100]={0}; static int t; static int dev_open(struct inode *, struct file *); static int dev_rls(struct inode *, struct file *); static ssize_t dev_read(struct file *, char *,size_t, loff_t *); static ssize_t dev_write(struct file *, const char *, size_t,loff_t […]