Intentionally corrupt the file system

独自空忆成欢 提交于 2019-12-23 08:54:34

问题


I have to explicitly test the case what my application does if it tries to access some corrupted part of an NTFS file system. I looked around for similar questions but those were about corrupting specific files (i.e. destroy the syntax of an xml file, etc).

I need to create a scenario where chkdsk would report errors in the file system in a specific location.

Does anybody have any idea how I could provoke such a situation to test my application.

Just in case you worry: I wouldn't do that on my production system, I have a VM set up for things like that.


回答1:


If the concern is about what your app would do when encountering corrupt files, then why bother corrupting the filesystem that contains the files? Why not simply corrupt the files themselves?

The operating system does a lot to ensure that filesystems are robust, I'm not sure that intentionally scribbling garbage on the file system will do anything other than fuzz test the filesystem implementation.




回答2:


Since there is no better solution here, I did it the hard way: I used Sysinternals NTFSInfo to find the location of the Master File Table, started a Linux Live CD and edited some bits in both locations of the Master File Table (MFT). Took some time to figure out the right places, but I can produce a corrupted file system no to test the error routines in my application.

Thanks to those contributing ideas, but I will award the answer to myself. If anybody has the same problem in the future, feel free to contact me.




回答3:


I would try to write some random bytes at some random locations of the disk (or disk partition).



来源:https://stackoverflow.com/questions/8296752/intentionally-corrupt-the-file-system

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