rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Benno Lossin" <lossin@kernel.org>
To: "Viacheslav Dubeyko" <Slava.Dubeyko@ibm.com>,
	"miguel.ojeda.sandonis@gmail.com"
	<miguel.ojeda.sandonis@gmail.com>
Cc: "frank.li@vivo.com" <frank.li@vivo.com>,
	"glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"slava@dubeyko.com" <slava@dubeyko.com>,
	"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>
Subject: Re: [RFC] Should we consider to re-write HFS/HFS+ in Rust?
Date: Fri, 20 Jun 2025 00:00:22 +0200	[thread overview]
Message-ID: <DAQUJ3FZZH2V.1CT5PEW0QCBVV@kernel.org> (raw)
In-Reply-To: <c212d2e1ca41fa0f2e4bc7c6d9fe0186ca5e839e.camel@ibm.com>

On Thu Jun 19, 2025 at 11:48 PM CEST, Viacheslav Dubeyko wrote:
> On Thu, 2025-06-19 at 22:22 +0200, Miguel Ojeda wrote:
>> On Thu, Jun 19, 2025 at 9:35 PM Benno Lossin <lossin@kernel.org> wrote:
>> > 
>> > There are some subsystems that go for a library approach: extract some
>> > self-contained piece of functionality and move it to Rust code and then
>> > call that from C. I personally don't really like this approach, as it
>> > makes it hard to separate the safety boundary, create proper
>> > abstractions & write idiomatic Rust code.
>> 
>> Yeah, that approach works best when the interface surface is
>> small/simple enough relative to the functionality, e.g. the QR code
>> case we have in the kernel already.
>> 
>> So there are some use cases of the approach (codecs have also been
>> discussed as another one). But going, in the extreme, "function by
>> function" replacing C with Rust and having two-way calls everywhere
>> isn't good, and it isn't the goal.
>> 
>> Instead, we aim to write safe Rust APIs ("abstractions") and then
>> ideally having pure Rust modules that take advantage of those.
>> Sometimes you may want to keep certain pieces in C, but still use them
>> from the Rust module until you cover those too eventually.
>> 
>
> Yeah, I completely agree. But I would like to implement the step-by-step
> approach. At first, introduce a Rust "library" that will absorb a "duplicated"
> functionality of HFS/HFS+. And C code of HFS/HFS+ will re-use the functionality
> of Rust "library". Then, elaborate "abstractions" (probably, HFS/HFS+ metadata
> primitives) and test it in Rust "library" by calling from C code. And, finally,
> completely switch to Rust implementation.

So the difficult part is the back and forth between Rust and C. You'll
have to write lots of glue code to make it work and that's why we don't
recommend it.

You can of course still build the driver step-by-step (and I'd recommend
doing that). For example the Nova driver is being built this way.

---
Cheers,
Benno

  reply	other threads:[~2025-06-19 22:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d5ea8adb198eb6b6d2f6accaf044b543631f7a72.camel@ibm.com>
2025-05-28 12:40 ` [RFC] Should we consider to re-write HFS/HFS+ in Rust? Yangtao Li
2025-05-28 16:16   ` Viacheslav Dubeyko
2025-06-19 19:33     ` Benno Lossin
2025-06-19 20:22       ` Miguel Ojeda
2025-06-19 21:48         ` Viacheslav Dubeyko
2025-06-19 22:00           ` Benno Lossin [this message]
2025-06-20  8:17           ` Miguel Ojeda
2025-06-20 18:10             ` Viacheslav Dubeyko
2025-06-20 19:27               ` Miguel Ojeda
2025-06-19 21:39       ` Viacheslav Dubeyko
2025-06-19 22:24         ` Benno Lossin
2025-06-20 17:46           ` Viacheslav Dubeyko
2025-06-20 18:11             ` Miguel Ojeda
2025-06-21 22:38               ` Viacheslav Dubeyko
2025-06-22  7:48                 ` Benno Lossin
2025-06-23 10:25                 ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DAQUJ3FZZH2V.1CT5PEW0QCBVV@kernel.org \
    --to=lossin@kernel.org \
    --cc=Slava.Dubeyko@ibm.com \
    --cc=frank.li@vivo.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=slava@dubeyko.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).