简体   繁体   English

将更改恢复为内核模块中的文件

[英]Revert changes in to a file in kernel module

I am using vfs_write(...) to write a file in kernel module. 我正在使用vfs_write(...)在内核模块中写入文件。 If an error occurs while writing file I want the changes to get reverted and file should be restored to its original state. 如果在写入文件时发生错误,我希望恢复所做的更改,并且文件应恢复到其原始状态。 Currently I am thinking of maintaining a temp file which contains data of file to be written and in case of faliure replace the temp file with original file but its too much work in kernel module. 目前,我正在考虑维护一个临时文件,其中包含要写入的文件的数据,如果出现故障,请用原始文件替换该临时文件,但在内核模块中它的工作量过多。

I am stuck here anyone know any work around this ? 我被困在这里,有人知道对此有任何解决办法吗?

It might be too much work, but it sounds like the right solution. 这可能是太多的工作,但这听起来像是正确的解决方案。

Alternatively, handle the getting data from the kernel userspace (eg read it from a file in /proc/ or similar), and make this atomically replace the file concerned. 或者,处理从内核用户空间获取的数据(例如,从/proc/或类似文件中读取数据),并用原子方式替换相关文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM