故意破坏文件系统 [英] Intentionally corrupt the file system
问题描述
如果我的应用程序尝试访问 NTFS 文件系统的某些损坏部分,我必须明确测试它会做什么.我四处寻找类似的问题,但这些问题是关于破坏特定文件(即破坏 xml 文件的语法等).
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).
我需要创建一个场景,其中 chkdsk 将报告特定位置的文件系统中的错误.
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.
推荐答案
由于这里没有更好的解决方案,我采用了艰难的方法:我使用了 Sysinternals NTFSInfo 找到主文件表的位置,启动 Linux Live CD 并在主文件表 (MFT) 的两个位置编辑一些位.花了一些时间来找出正确的位置,但我可以生成一个损坏的文件系统 no 来测试我的应用程序中的错误例程.
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.
这篇关于故意破坏文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!