故意损坏文件系统

发布于 2024-12-18 17:55:20 字数 319 浏览 4 评论 0原文

我必须明确测试我的应用程序在尝试访问 NTFS 文件系统的某些损坏部分时会执行什么操作。我四处寻找类似的问题,但这些问题都是关于破坏特定文件(即破坏 xml 文件的语法等)。

我需要创建一个场景,其中 chkdsk 将报告特定位置的文件系统中的错误。

有谁知道我如何引发这种情况来测试我的应用程序。

以防万一您担心:我不会在我的生产系统上这样做,我为类似的事情设置了一个虚拟机。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丑疤怪 2024-12-25 17:55:20

如果担心的是您的应用程序在遇到损坏的文件时会做什么,那么为什么还要损坏包含这些文件的文件系统呢?为什么不简单地损坏文件本身呢?

操作系统做了很多工作来确保文件系统的健壮性,我不确定故意在文件系统上乱写垃圾除了对文件系统实现进行模糊测试之外还会做任何事情。

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.

浮生未歇 2024-12-25 17:55:20

由于这里没有更好的解决方案,所以我采用了困难的方法:我使用 Sysinternals NTFSInfo 要找到主文件表的位置,启动 Linux Live CD 并编辑主文件表 (MFT) 的两个位置中的一些位。花了一些时间找出正确的位置,但我可以生成一个损坏的文件系统来测试我的应用程序中的错误例程。

感谢那些提出想法的人,但我会将答案授予我自己。如果以后有人遇到同样的问题,请随时与我联系。

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.

梦回旧景 2024-12-25 17:55:20

我会尝试在磁盘(或磁盘分区)的某些随机位置写入一些随机字节。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文