如何使DU命令投入输入/输出错误

发布于 2025-02-11 01:09:57 字数 235 浏览 1 评论 0原文

如何制作du命令投掷输入/输出错误。由于某种原因,我想复制此用例,并想在更改推向生产之前验证我的修复程序。我无法理解如何重现此用例。我尝试了很多事情,但没有运气。任何其他命令也可以罚款文件系统输入/输出错误。

例如

du -sh /data/
du: cannot access '/data/': Input/output error

How to make du command throw input/output error. For some reason, I want to reproduce this use case and want to verify my fix before changes pushed to production. I am not able to understand how to reproduce this use case. I tried so many thing, but no luck. Any other command also fine which throws input/output error for file system.

E.g.

du -sh /data/
du: cannot access '/data/': Input/output error

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

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

发布评论

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

评论(1

The error message appears to be EIO. man page

  EIO输入/输出错误(POSIX.1-2001)。
 

in-turn,

输入/输出错误。发生了一些物理输入或输出错误。可以在同一文件描述符上的后续操作中报告此错误。同一文件描述符上的任何其他引起错误的操作都可能导致[EIO]错误指示丢失。

那么,那留给你的地方呢?好吧,您需要以某种方式模拟从syscall接收eio。您应该能够使用Strace为了使任意的syscall返回eio ,但是哪一个?

首先在Strace下运行DU,以查看哪些SYSCALL可能返回EIO。 FSTAT(2)不会在Linux上返回EIO,因此必须是另一个Syscall。

The error message appears to be EIO. The man page says

EIO    Input/output error (POSIX.1-2001).

In-turn, POSIX says:

Input/output error. Some physical input or output error has occurred. This error may be reported on a subsequent operation on the same file descriptor. Any other error-causing operation on the same file descriptor may cause the [EIO] error indication to be lost.

So, where does that leave you? Well, you need to somehow simulate du receiving EIO from a syscall. You should be able to use strace to make an arbitrary syscall return EIO, but which one?

Start by running du under strace to see which syscalls might return EIO. fstat(2) does not return EIO on Linux, so it must be another syscall.

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