Why the operator >> doesn't work with my char device?

本小妞迷上赌 提交于 2019-12-06 08:07:12

You need to handle O_APPEND in your write routine. The >> operator opens the file with the O_APPEND flag, which requests your driver to seek to the end before each write operation. In your case your mad_write routine should check the file flags, and seek to the end before writing if O_APPEND is set.

See the manual definition here. I had a look around the Linux kernel source for examples, but very few character drivers actually handle O_APPEND. The best example I could find was in the generic file code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!