问题
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