Linux Kernel C code to simulate userland writing / setting a value to /proc filesystem file [closed]

流过昼夜 提交于 2020-08-10 22:53:45

问题


What's the best way to simulate the same thing as a user doing an "echo a > /proc/file" But doing it from the KERNEL (2.6 in my case) even when the ROOT partition is unreachable.

As far as I know the /proc file system is created by the kernel and resides in memory so it should be writable to it even if the root file system is not reachable at the moment.

So I'd like to know how can I from within C kernel code trigger / simulate such a value setting in the same way as a user would have done an "echo a > /proc/existingfile"

I don't want to create the file but just how to write/send a character to the proc file.

Basically example method how to simulate get_user(character, buffer) when there's nothing happening on the user side since root filesystem is not even available etc, so I don't think I can simply just run an OS "system call" from inside kernel in this case.

来源:https://stackoverflow.com/questions/63253217/linux-kernel-c-code-to-simulate-userland-writing-setting-a-value-to-proc-file

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