Linux - 以编程方式写入 proc 文件
我在网上找到了几个示例,我们可以在其中创建 proc 文件,分配每次打开 proc 文件进行读取或写入时调用的读取和写入方法。
但是,我似乎找不到任何有关如何以编程方式写入 proc 文件的文档。理想情况下,我想在每次打开 proc 文件进行读取或写入时添加带有其他用户详细信息的时间戳。同样,我找到了可以添加打开 proc 文件时触发的读取和写入函数的位置,但我找不到有关如何以编程方式实际写入 proc 文件的文档。这与常规 IO 读/写不同,对吗?
I have found several examples online where we can create a proc file, assign read and write methods that are called every time the proc file is opened for read or written to.
However, I can't seem to find any documentation on how to programatically write to a proc file. Ideally, I would like to add a timestamp with other user details every time the proc file is opened for read or for write. Again, I've found where I can add the read and write functions that are triggered when the proc file is opened, but I can't find documentation on how to actually write to a proc file programatically. This would be different from a regular IO read/write, correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了这个问题——我没有完全理解 proc 文件,但现在了解它们是如何工作的,并且实际上没有任何文件可写入——只是变量。成功了。谢谢!
Fixed the issue -- I didn't fully understand proc files but now understand how they work and that there isn't really any file to write to -- just variables. Got it working. Thanks!