Re: [PATCH v2] fault-inject: rust: add a Rust API for fault-injection

From: Andreas Hindborg

Date: Sat Jun 06 2026 - 13:36:34 EST


Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> writes:

> Hi Andreas,
>
> Some quick comments scanning your patch diagonally since I was here
> for something else.
>
> On Fri, Jun 5, 2026 at 3:27 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>>
>> #include <linux/ethtool.h>
>> #include <linux/fdtable.h>
>> +#include <linux/fault-inject.h>
>> #include <linux/file.h>
>
> Please keep them sorted :)
>
>> +// SAFETY: FaultConfig can be used from any task.
>
> `FaultConfig`
>
>> + // SAFETY: By type invariant, self is always valid.
>
> `self`
>
>> + /// Returns `true` if the operation should fail.
>
> [`true`]

Thanks, I'll correct these for next version.

>
>> + // INVARIANT: `self.inner` is initialized in ffi_init.
>
> I was going to say `ffi_init`, but there is no such call here. Isn't
> it getting initialized by the C side? I guess this got copy-pasted
> from somewhere else?

Thanks for catching this, it is a stale comment. I was using
`Opaque::ffi_init` in an earlier version (pre v1, this was also present
in v1).


Best regards,
Andreas Hindborg