Re: [PATCH 1/7] rust: file: add Rust abstraction for `struct file`

From: Benno Lossin
Date: Fri Dec 01 2023 - 10:14:52 EST


On 12/1/23 16:04, Theodore Ts'o wrote:
> On Fri, Dec 01, 2023 at 12:27:40PM +0000, Alice Ryhl wrote:
>>
>> You can import it with a use statement. For example:
>>
>> use kernel::file::flags::O_RDONLY;
>> // use as O_RDONLY
>
> That's good to hear, but it still means that we have to use the XYZ_*
> prefix, because otherwise, after something like
>
> use kernel::file::flags::RDONLY;
> use kernel::uapi::rwf::RDONLY;
>
> that will blow up. So that has to be
>
> use kernel::file::flags::O_RDONLY;
> use kernel::uapi::rwf::RWF_RDONLY;

You can just import the `flags` and `rwf` modules (the fourth option
posted by Alice):

use kernel::file::flags;
use kernel::uapi::rwf;

// usage:

flags::O_RDONLY

rwf::RDONLY

Alternatively if we end up with multiple flags modules you can do this
(the sixth option from Alice):

use kernel::file::flags as file_flags;
use kernel::foo::flags as foo_flags;

// usage:

file_flags::O_RDONLY

foo_flags::O_RDONLY

--
Cheers,
Benno