Re: [PATCH v8 0/4] rust: replace kernel::str::CStr w/ core::ffi::CStr

From: Tamir Duberstein
Date: Fri Mar 14 2025 - 10:15:55 EST


On Fri, Feb 21, 2025 at 10:59 AM Tamir Duberstein <tamird@xxxxxxxxx> wrote:
>
> On Fri, Feb 21, 2025 at 9:28 AM Gary Guo <gary@xxxxxxxxxxx> wrote:
> >
> > I'd want to add that we currently also have our own `BStr` and then we
> > have the `CStr` -> `BStr` -> `[u8]` deref chain which is quite often
> > useful. If we move to the `core::ffi::CStr` then we would lose ability
> > to do so.
>
> True. The best we could do is `impl AsRef<BStr> for CStr`, I think.

BStr now exists upstream (though it is unstable for now). Please see
https://github.com/Rust-for-Linux/linux/issues/1146.

I sent https://github.com/rust-lang/rust/pull/138498 to see whether it
is possible to retain this functionality in the end state where
upstream's BStr is stable and we're able to use it.