Re: [PATCH v2 1/8] rust: fs: add file::Offset type alias

Miguel Ojeda
2025-10-21T16:47:55Z

On Tue, Oct 21, 2025 at 6:25 PM Danilo Krummrich <dakr@kernel.org> wrote:
>
> We need arithmetic operations (e.g. checked_add()) and type conversions (e.g.
> from/into usize). That'd be quite some code to write that just forwards to the
> inner primitive.

If it is just e.g. add/sub and a few from/into, then it sounds ideal
(i.e. I am worried if it wants to be used as essentially a primitive,
in which case I agree it would need to be automated to some degree).

> So, I think as by now a new type makes sense if there is some reasonable
> additional semantics to capture.

To me, part of that is restricting what can be done with the type to
prevent mistakes.

i.e. a type alias is essentially the wild west, and this kind of
type/concept is common enough that it sounds a good idea to pay the
price to provide a proper type for it.

> Maybe the action to take from this is to add this to the list of (good first)
> issues (not sure this is actually a _good first_ issue though :).

So I don't want to delay real work, and as long as we do it early
enough that we don't have many users, that sounds like a good idea to
me -- done:

https://github.com/Rust-for-Linux/linux/issues/1198

Also took the chance to ask for a couple examples/tests.

I hope that helps.

Cheers,
Miguel